|
| 1 | +import ItemTokenList from '@/common/components/ItemTokenList'; |
| 2 | +import PriceToken from '@/features/home/components/ItemCard/PriceToken'; |
| 3 | +import { Link } from 'react-router'; |
| 4 | +import * as s from './style.css'; |
| 5 | +import getImageUrl from '@/common/utils/getImageUrl'; |
| 6 | +import { cx } from '@styled-system/css'; |
| 7 | +import type { NotificationInterface } from '../../types'; |
| 8 | +import { parsePickDate, parsePickTime } from '@/common/utils/parseDate'; |
| 9 | + |
| 10 | +interface Props { |
| 11 | + data: NotificationInterface; |
| 12 | +} |
| 13 | + |
| 14 | +const NotificationItemCard = ({ data }: Props) => { |
| 15 | + const isRental = data.item.transactionTypes.includes('RENTAL'); |
| 16 | + const isSale = data.item.transactionTypes.includes('SALE'); |
| 17 | + const type = data.type; |
| 18 | + const isRemind = type === 'APPOINTMENT_REMIND'; |
| 19 | + |
| 20 | + const label = (() => { |
| 21 | + if (type === 'APPOINTMENT_CANCEL') return '๋์ Pick์ด ์ทจ์๋์ด์.'; |
| 22 | + if (type === 'APPOINTMENT_EXPIRE') return '๋์ Pick ์์ฒญ์ด ๋ง๋ฃ๋์ด์.'; |
| 23 | + if (type === 'APPOINTMENT_PROPOSAL') return 'Pick ์์ฒญ์ ๋ฐ์์ด์.'; |
| 24 | + if (type === 'APPOINTMENT_REJECT') return '๋์ Pick ์์ฒญ์ด ๊ฑฐ์ ๋์ด์.'; |
| 25 | + if (type === 'APPOINTMENT_REMIND') return '์ค๋์ ์๋ ์ํ์ ๊ฑฐ๋ ๋ ์ด์์!'; |
| 26 | + if (type === 'APPOINTMENT_CONFIRM') return '๋์ Pick์ด ํ์ ๋์ด์.'; |
| 27 | + })(); |
| 28 | + |
| 29 | + const icon = (() => { |
| 30 | + if (type === 'APPOINTMENT_CANCEL') return 'mgc_sob_fill'; |
| 31 | + if (type === 'APPOINTMENT_EXPIRE') return 'mgc_sob_fill'; |
| 32 | + if (type === 'APPOINTMENT_PROPOSAL') return 'mgc_emoji_fill'; |
| 33 | + if (type === 'APPOINTMENT_REJECT') return 'mgc_sob_fill'; |
| 34 | + if (type === 'APPOINTMENT_REMIND') return 'mgc_t_shirt_fill'; |
| 35 | + if (type === 'APPOINTMENT_CONFIRM') return 'mgc_emoji_fill'; |
| 36 | + })(); |
| 37 | + |
| 38 | + return ( |
| 39 | + <div className={s.Wrapper({ isRemind })}> |
| 40 | + <div className={s.RemindTime}> |
| 41 | + <div className={s.Type}> |
| 42 | + <div className={cx(`${icon}`, s.Icon({ icon }))} /> |
| 43 | + <div className={s.Label}>{label}</div> |
| 44 | + </div> |
| 45 | + {/* {isRemind && */} |
| 46 | + <div className={s.Date}> |
| 47 | + <h1>{parsePickDate(data.createdAt)}</h1> |
| 48 | + <h1>{parsePickTime(data.createdAt)}</h1> |
| 49 | + </div> |
| 50 | + {/*} */} |
| 51 | + </div> |
| 52 | + <Link className={s.Container} to={`/pick-detail/${data.appointmentId}`}> |
| 53 | + <img className={s.Image} src={getImageUrl(data.item.thumbnail)} aria-hidden /> |
| 54 | + <div className={s.Info}> |
| 55 | + <div className={s.Header}> |
| 56 | + <h2 className={s.Title}>{data.item.title}</h2> |
| 57 | + <div className={s.Price}> |
| 58 | + {isRental && <PriceToken price={data.item.rentalFee} deposit={data.item.deposit} />} |
| 59 | + {isSale && <PriceToken price={data.item.salePrice} />} |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + <div className={s.Footer}> |
| 63 | + <div className={s.Tokens}> |
| 64 | + <ItemTokenList |
| 65 | + showCount={3} |
| 66 | + itemInfo={{ |
| 67 | + productTypes: data.item.productTypes, |
| 68 | + quality: data.item.quality, |
| 69 | + size: data.item.size, |
| 70 | + color: data.item.color, |
| 71 | + tradeMethods: data.item.tradeMethods, |
| 72 | + }} |
| 73 | + /> |
| 74 | + </div> |
| 75 | + <div className={s.Interactions}> |
| 76 | + <div className={s.InteractionItem}> |
| 77 | + <span className="mgc_heart_fill" /> |
| 78 | + <p>{data.item.likeCount}</p> |
| 79 | + </div> |
| 80 | + <div className={s.InteractionItem}> |
| 81 | + <span className="mgc_chat_2_fill" /> |
| 82 | + <p>{data.item.chatRoomCount}</p> |
| 83 | + </div> |
| 84 | + </div> |
| 85 | + </div> |
| 86 | + </div> |
| 87 | + </Link> |
| 88 | + </div> |
| 89 | + ); |
| 90 | +}; |
| 91 | + |
| 92 | +export default NotificationItemCard; |
0 commit comments