Skip to content

Commit

Permalink
Merge pull request #283 from ODOICHON/feat/#281
Browse files Browse the repository at this point in the history
feat: ๋†๊ฐ€ ๊ฑฐ๋ž˜ ํŽ˜์ด์ง€ ๊ฒ€์ƒ‰ ํ•„ํ„ฐ์—์„œ ์ƒˆ๋กœ์šด ์œ ํ˜• ํƒ€์ž… ์ถ”๊ฐ€ & ๊ธฐ์กด ์œ ํ˜• ํƒ€์ž…์„ ๊ฑฐ๋ž˜ ํƒ€์ž…์œผ๋กœ ๋ณ€๊ฒฝ
  • Loading branch information
JunJongHun authored Aug 18, 2024
2 parents 0f33cf9 + 2fef03f commit bc1def8
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/components/Trade/Dropdown/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { motion } from 'framer-motion';
import { MenuType } from '@/types/Board/tradeType';
import { TradeCategoryType, TradeCityType } from '@/constants/trade';
import {
TradeCategoryType,
TradeCityType,
TradeHouseType,
} from '@/constants/trade';
import { tradeDropdownVariants } from '@/constants/variants';
import styles from './styles.module.scss';

type DropdownProps = {
menu: TradeCategoryType[] | TradeCityType[];
menu: TradeHouseType[] | TradeCategoryType[] | TradeCityType[];
setMenu: React.Dispatch<React.SetStateAction<string>>;
setSelectedMenu: React.Dispatch<React.SetStateAction<MenuType>>;
};
Expand Down
46 changes: 40 additions & 6 deletions src/components/Trade/SearchBar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { useEffect, useRef, useState } from 'react';
import { GoTriangleDown } from 'react-icons/go';
import { AnimatePresence } from 'framer-motion';
import { MenuType, RentalType } from '@/types/Board/tradeType';
import { convertRentalTypeName } from '@/utils/utils';
import { tradeCategory, tradeCity } from '@/constants/trade';
import { HouseType, MenuType, RentalType } from '@/types/Board/tradeType';
import { convertHouseTypeName, convertRentalTypeName } from '@/utils/utils';
import { houseCategory, tradeCategory, tradeCity } from '@/constants/trade';
import styles from './styles.module.scss';
import Dropdown from '../Dropdown';

type SearchBarProps = {
houseType: string;
rentalType: string;
city: string;
search: string;
setHouseType: React.Dispatch<React.SetStateAction<string>>;
setRentalType: React.Dispatch<React.SetStateAction<string>>;
setCity: React.Dispatch<React.SetStateAction<string>>;
setSearch: React.Dispatch<React.SetStateAction<string>>;
Expand All @@ -19,9 +21,11 @@ type SearchBarProps = {
};

export default function SearchBar({
houseType,
rentalType,
city,
search,
setHouseType,
setRentalType,
setCity,
setSearch,
Expand Down Expand Up @@ -60,8 +64,38 @@ export default function SearchBar({
<section
ref={dropdownRef}
className={styles.selectItem}
style={{ flexGrow: '2' }}
style={{ flexGrow: '1' }}
>
<span
role="presentation"
className={
selectedMenu === 'houseType'
? styles.selectedSearchItem
: styles.searchItem
}
onClick={() => setSelectedMenu('houseType')}
>
<div>
<p style={{ color: houseType !== '' ? 'black' : '' }}>
{houseType === ''
? '์œ ํ˜•'
: convertHouseTypeName(houseType as HouseType)}
</p>
<GoTriangleDown color="#d9d9d9" size="1.25rem" />
</div>
<AnimatePresence>
{selectedMenu === 'houseType' && (
<Dropdown
menu={houseCategory}
setMenu={setHouseType}
setSelectedMenu={setSelectedMenu}
/>
)}
</AnimatePresence>
</span>

<div className={styles.divider} />

<span
role="presentation"
className={
Expand All @@ -74,7 +108,7 @@ export default function SearchBar({
<div>
<p style={{ color: rentalType !== '' ? 'black' : '' }}>
{rentalType === ''
? '์œ ํ˜•'
? '๊ฑฐ๋ž˜'
: convertRentalTypeName(rentalType as RentalType)}
</p>
<GoTriangleDown color="#d9d9d9" size="1.25rem" />
Expand Down Expand Up @@ -126,7 +160,7 @@ export default function SearchBar({
? styles.selectedSearchItem
: styles.searchItem
}
style={{ flexGrow: '3' }}
style={{ flexGrow: '1' }}
onClick={() => setSelectedMenu('search')}
>
<form onSubmit={handleSubmit}>
Expand Down
18 changes: 17 additions & 1 deletion src/constants/trade.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
import { RecommendedTagType, RentalType } from '@/types/Board/tradeType';
import {
HouseType,
RecommendedTagType,
RentalType,
} from '@/types/Board/tradeType';

export type TradeCategoryType = {
content: string;
type: RentalType | '';
};

export type TradeHouseType = {
content: string;
type: HouseType | '';
};

export const houseCategory: TradeHouseType[] = [
{ content: '์ „์ฒด', type: '' },
{ content: 'ํ† ์ง€', type: 'LAND' },
{ content: '์ฃผํƒ', type: 'HOUSE' },
{ content: '๋†๊ฐ€', type: 'FARM_HOUSE' },
];

export const tradeCategory: TradeCategoryType[] = [
{ content: '์ „์ฒด', type: '' },
{ content: '๋งค๋งค', type: 'SALE' },
Expand Down
3 changes: 3 additions & 0 deletions src/pages/Trade/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function TradePage() {
const [currentPage, setCurrentPage] = useState(0);
const [isLastPage, setIsLastPage] = useState(false);

const [houseType, setHouseType] = useState('');
const [rentalType, setRentalType] = useState('');
const [city, setCity] = useState('');
const [search, setSearch] = useState('');
Expand Down Expand Up @@ -98,9 +99,11 @@ export default function TradePage() {
</section>
<section className={styles.contentWrapper}>
<SearchBar
houseType={houseType}
rentalType={rentalType}
city={city}
search={search}
setHouseType={setHouseType}
setRentalType={setRentalType}
setCity={setCity}
setSearch={setSearch}
Expand Down
4 changes: 3 additions & 1 deletion src/types/Board/tradeType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ export type RecommendedTagType =
| 'WANT_TO_LOOK_A_GOOD_VIEW'
| 'WANT_TO_FARM';

export type HouseType = 'LAND' | 'HOUSE' | 'FARM_HOUSE';

export type RentalType = 'SALE' | 'JEONSE' | 'MONTHLYRENT';

export type MenuType = 'none' | 'rentalType' | 'city' | 'search';
export type MenuType = 'none' | 'houseType' | 'rentalType' | 'city' | 'search';

export type DealStateType = 'APPLYING' | 'ONGOING' | 'COMPLETED';

Expand Down
7 changes: 7 additions & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from 'axios';
import {
DealStateType,
HouseType,
RecommendedTagType,
RentalType,
TradeBoardForm,
Expand Down Expand Up @@ -271,6 +272,12 @@ export const convertRentalTypeName = (typeName: RentalType) => {
if (typeName === 'MONTHLYRENT') return '์›”์„ธ';
};

export const convertHouseTypeName = (typeName: HouseType) => {
if (typeName === 'LAND') return 'ํ† ์ง€';
if (typeName === 'HOUSE') return '์ฃผํƒ';
if (typeName === 'FARM_HOUSE') return '๋†๊ฐ€';
};

// ๋ฌธ์ž๊ฐ€ ์ž์Œ์ด๊ฑฐ๋‚˜ ๋ชจ์Œ์ธ์ง€ ํ™•์ธํ•˜๋Š” ํ•จ์ˆ˜
export const isConsonant = (char: string) => {
const pattern = /[ใ„ฑ-ใ…Ž|ใ…-ใ…ฃ]/;
Expand Down

0 comments on commit bc1def8

Please sign in to comment.