|
1 | | -import Token from '@/common/components/Token'; |
2 | 1 | import * as s from './style.css'; |
3 | | -import { PRODUCT_TYPES_MAP } from '@/libs/types/item'; |
| 2 | + |
4 | 3 | import type { ItemInfoInterface } from '@/features/detail/types'; |
| 4 | +import { getKoreanRelativeTime } from '@/common/utils/getKoreanRelativeTime'; |
| 5 | +import { toKST } from '@/common/utils/toKST'; |
| 6 | +import ItemTokenList from '@/common/components/ItemTokenList'; |
5 | 7 |
|
6 | 8 | interface Props { |
7 | 9 | itemInfo: ItemInfoInterface; |
8 | 10 | } |
9 | 11 | const PostContent = ({ itemInfo }: Props) => { |
| 12 | + const isRental = itemInfo.transactionTypes.includes('RENTAL'); |
| 13 | + const isSale = itemInfo.transactionTypes.includes('SALE'); |
| 14 | + |
10 | 15 | return ( |
11 | 16 | <div className={s.Container}> |
12 | 17 | <div className={s.TextContainer}> |
13 | 18 | <div className={s.Header}> |
14 | 19 | <h1 className={s.Title}>{itemInfo.title}</h1> |
15 | 20 | <div className={s.PriceContainer}> |
16 | | - {/* TODO: νλ§€κΈμΈ κ²½μ° μ΄μΊ 보μΌκΉ */} |
17 | | - <div className={s.PriceItem}> |
18 | | - <label>λμ¬λ£</label> |
19 | | - <p>{itemInfo.rentalFee.toLocaleString()}μ</p> |
20 | | - </div> |
21 | | - {itemInfo.deposit !== 0 && ( |
| 21 | + {isRental && ( |
| 22 | + <div> |
| 23 | + <div className={s.PriceItem}> |
| 24 | + <label>λμ¬λ£</label> |
| 25 | + <p>{itemInfo.rentalFee.toLocaleString()}μ</p> |
| 26 | + </div> |
| 27 | + {itemInfo.deposit !== 0 && ( |
| 28 | + <div className={s.PriceItem}> |
| 29 | + <label>보μ¦κΈ</label> |
| 30 | + <p>{itemInfo.deposit.toLocaleString()}μ</p> |
| 31 | + </div> |
| 32 | + )} |
| 33 | + </div> |
| 34 | + )} |
| 35 | + {isSale && ( |
22 | 36 | <div className={s.PriceItem}> |
23 | | - <label>보μ¦κΈ</label> |
24 | | - <p>{itemInfo.deposit.toLocaleString()}μ</p> |
| 37 | + <label>νλ§€κ°</label> |
| 38 | + <p>{itemInfo.salePrice.toLocaleString()}μ</p> |
25 | 39 | </div> |
26 | 40 | )} |
27 | 41 | </div> |
28 | 42 | </div> |
29 | | - {/* TODO: API μΈν°νμ΄μ€ μμ νμ */} |
30 | 43 | <div className={s.PostInfoContainer}> |
31 | | - <p>3μΌ μ </p> |
| 44 | + <p>{getKoreanRelativeTime(toKST(new Date(itemInfo.repostDate)))}</p> |
32 | 45 | <span /> |
33 | 46 | <div className={s.InteractionContainer}> |
34 | 47 | <span className={s.InteractionItem}> |
35 | 48 | <span className="mgc_heart_fill" /> |
36 | | - <p>12</p> |
| 49 | + <p>{itemInfo.likeCount}</p> |
37 | 50 | </span> |
38 | 51 | <span className={s.InteractionItem}> |
39 | 52 | <span className="mgc_chat_2_fill" /> |
40 | | - <p>4</p> |
| 53 | + <p>{itemInfo.chatRoomCount}</p> |
41 | 54 | </span> |
42 | 55 | </div> |
43 | 56 | </div> |
44 | | - <div className={s.TextContent}> |
45 | | - {itemInfo.description.split('\n').map((line, index) => ( |
46 | | - <p key={index}>{line}</p> |
47 | | - ))} |
48 | | - </div> |
| 57 | + <div className={s.TextContent}>{itemInfo.description}</div> |
49 | 58 | </div> |
50 | 59 | <div className={s.TokenContainer}> |
51 | | - {itemInfo.productTypes.map(type => ( |
52 | | - <Token key={type}>{PRODUCT_TYPES_MAP[type]}</Token> |
53 | | - ))} |
| 60 | + <ItemTokenList itemInfo={itemInfo} /> |
54 | 61 | </div> |
55 | 62 | </div> |
56 | 63 | ); |
|
0 commit comments