Skip to content

Commit

Permalink
Merge pull request #286 from ODOICHON/feat/#285
Browse files Browse the repository at this point in the history
๋†๊ฐ€ ๊ฑฐ๋ž˜ ์ƒ์„ธ ํŽ˜์ด์ง€์—์„œ ์œ ํ˜• ์ •๋ณด ์ถ”๊ฐ€ ๋ฐ ๊ฒŒ์‹œ๊ธ€ ์ œ๋ชฉ ๋ง๋จธ๋ฆฌ์— ์œ ํ˜• ์ถ”๊ฐ€
  • Loading branch information
JunJongHun authored Aug 18, 2024
2 parents 0c3cefc + 0f46d9c commit 011d6e4
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 23 deletions.
7 changes: 5 additions & 2 deletions src/components/Trade/Board/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import { useEffect, useRef, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import dayjs from 'dayjs';
import { RentalType, TradeBoardType } from '@/types/Board/tradeType';
import { convertRentalTypeName, priceCount } from '@/utils/utils';
import { convertRentalTypeName, getHouseName, priceCount } from '@/utils/utils';
import styles from './styles.module.scss';

type TradeBoardProps = Omit<TradeBoardType, 'recommendedTag'>;

export default function TradeBoard({
houseId,
houseType,
rentalType,
city,
price,
Expand Down Expand Up @@ -97,7 +98,9 @@ export default function TradeBoard({
)}
</div>
<div className={styles.contentsWrapper}>
<h1>{title}</h1>
<h1>
[{getHouseName(houseType)}] {title}
</h1>
<p>
<strong>์œ„์น˜</strong> : {city}
</p>
Expand Down
35 changes: 16 additions & 19 deletions src/components/Trade/Info/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dayjs from 'dayjs';
import { TradeBoardDetailType } from '@/types/Board/tradeType';
import { getRentalName } from '@/utils/utils';
import { getHouseName, getRentalName } from '@/utils/utils';
import styles from './styles.module.scss';

// TODO: undefined ์ฒ˜๋ฆฌํ•˜๊ธฐ
Expand All @@ -12,28 +12,13 @@ function TradeBoardInfo({ info }: TradeBoardInfoProps) {
return (
<section className={styles.infoContainer}>
<article>
<span>๊ธฐ๋ณธ์ •๋ณด</span>
<div>
์œ„์น˜ <p>{info?.city}</p>
</div>
<div>
๋ฉด์ {' '}
<p>
{info?.size}m<sup>2</sup>
</p>
</div>
<div>
์šฉ๋„ <p>{info?.purpose}</p>
</div>
<span>์ž„๋Œ€์ •๋ณด ๋ฐ ํŒ๋งค์ž ์ •๋ณด</span>
<div>
์ค€๊ณต์—ฐ๋„ <p>{dayjs(info?.createdDate).format('YYYY')}๋…„</p>
์œ ํ˜• <p>{info?.houseType && getHouseName(info?.houseType)}</p>
</div>
<div>
์ธต์ˆ˜ <p>{info?.floorNum === 0 ? '-' : `${info?.floorNum}์ธต`}</p>
์œ„์น˜ <p>{info?.city}</p>
</div>
</article>
<article>
<span>์ž„๋Œ€์ •๋ณด ๋ฐ ํŒ๋งค์ž ์ •๋ณด</span>
<div>
๊ฐ€๊ฒฉ{' '}
<p>
Expand All @@ -50,6 +35,18 @@ function TradeBoardInfo({ info }: TradeBoardInfoProps) {
</div>
)}
</article>
<article>
<span>๊ธฐ๋ณธ์ •๋ณด</span>
<div>
๋ฉด์  <p>{info?.size}ใŽก</p>
</div>
<div>
์ค€๊ณต์—ฐ๋„ <p>{dayjs(info?.createdDate).format('YYYY')}๋…„</p>
</div>
<div>
์šฉ๋„ <p>{info?.purpose}</p>
</div>
</article>
</section>
);
}
Expand Down
7 changes: 5 additions & 2 deletions src/pages/Trade/Board/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { DeleteHouseAPI } from '@/apis/houses';
import userStore from '@/store/userStore';
import useModalState from '@/hooks/useModalState';
import useToastMessageType from '@/hooks/useToastMessageType';
import { getMoveInType, getUserType } from '@/utils/utils';
import { getHouseName, getMoveInType, getUserType } from '@/utils/utils';
import { ApiResponseWithDataType } from '@/types/apiResponseType';
import { opacityVariants } from '@/constants/variants';
import styles from './styles.module.scss';
Expand Down Expand Up @@ -104,7 +104,10 @@ export default function TradeBoardPage() {
{getUserType(data?.data.userType || 'NONE')}
</li>
</ul>
<h1>{data?.data.title}</h1>
<h1>
{data?.data.houseType && `[${getHouseName(data?.data.houseType)}]`}{' '}
{data?.data.title}
</h1>
<div>
<p>
{data?.data.nickName}
Expand Down
1 change: 1 addition & 0 deletions src/pages/Trade/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export default function TradePage() {
<TradeBoard
key={content.houseId}
houseId={content.houseId}
houseType={content.houseType}
rentalType={content.rentalType}
city={content.city}
price={content.price}
Expand Down
1 change: 1 addition & 0 deletions src/types/Board/tradeType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type TradeBoardForm = {

export type TradeBoardType = {
houseId: number;
houseType: HouseType;
rentalType: RentalType;
city: string;
price: number;
Expand Down
14 changes: 14 additions & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ export const getPrefixCategoryName = (category: string) => {
}
};

// ๋งค๋งค ํƒ€์ž… ์ด๋ฆ„ ๊ฐ€์ ธ์˜ค๊ธฐ
export const getHouseName = (house: HouseType) => {
switch (house) {
case 'LAND':
return 'ํ† ์ง€';
case 'HOUSE':
return '์ฃผํƒ';
case 'FARM_HOUSE':
return '๋†๊ฐ€';
default:
return '';
}
};

// ๋งค๋งค ํƒ€์ž… ์ด๋ฆ„ ๊ฐ€์ ธ์˜ค๊ธฐ
export const getRentalName = (rental: RentalType) => {
switch (rental) {
Expand Down

0 comments on commit 011d6e4

Please sign in to comment.