diff --git a/src/app/(root)/(routes)/items/[itemId]/components/description-section/DescriptionSection.tsx b/src/app/(root)/(routes)/items/[itemId]/components/description-section/DescriptionSection.tsx index 4b5ae1e7..22eec179 100644 --- a/src/app/(root)/(routes)/items/[itemId]/components/description-section/DescriptionSection.tsx +++ b/src/app/(root)/(routes)/items/[itemId]/components/description-section/DescriptionSection.tsx @@ -10,36 +10,64 @@ import { } from '@/components/ui/DropdownMenu' import Assets from '@/config/assets' import { TYPHOGRAPHY } from '@/styles/sizes' +import { ItemDetail } from '@/types' import Dibs from './Dibs' -type DescriptionSectionProps = {} +type DescriptionSectionProps = { + itemData: ItemDetail +} + +type TradeStateMap = { + [key: string]: { + style: + | 'primary' + | 'secondary' + | 'gradation' + | 'information' + | null + | undefined + text: string + } +} -const DescriptionSection = ({}: DescriptionSectionProps) => { +const DescriptionSection = ({ + itemData: { status, cardTitle, category, createdAt, dibsCount, content }, +}: DescriptionSectionProps) => { + const tradeStateMap: TradeStateMap = { + TRADE_AVAILABLE: { + style: 'primary', + text: '거래가능', + }, + RESERVED: { + style: 'secondary', + text: '예약중', + }, + TRADE_COMPLETE: { + style: 'gradation', + text: '거래성사', + }, + } return (
- - 거래가능 + + {tradeStateMap[status].text} -

스위치 교환가능합니다

+

{cardTitle}

- 전자기기 + {category}

- 25분 전 + {createdAt}

- +
-

- 닌텐도 스위치 팝니다. 구매 후에 쭉 투명케이스 쓰고 사용해서 상태 정말 - 좋아요~ 박스는 이사가면서 버려서 없지만 구성품은 다 있고 스위치 프로콘 - 같이 드립니다. -

+

{content}

) } diff --git a/src/app/(root)/(routes)/items/[itemId]/components/description-section/Dibs.tsx b/src/app/(root)/(routes)/items/[itemId]/components/description-section/Dibs.tsx index 929f84da..4a04bb42 100644 --- a/src/app/(root)/(routes)/items/[itemId]/components/description-section/Dibs.tsx +++ b/src/app/(root)/(routes)/items/[itemId]/components/description-section/Dibs.tsx @@ -2,13 +2,16 @@ import Image from 'next/image' import Button from '@/components/ui/Button' import Assets from '@/config/assets' -const Dibs = () => { +type DibsProps = { + count: number +} +const Dibs = ({ count }: DibsProps) => { return (
-

12

+

{count}

) } diff --git a/src/app/(root)/(routes)/items/[itemId]/components/trade-section/TradeInfo.tsx b/src/app/(root)/(routes)/items/[itemId]/components/trade-section/TradeInfo.tsx index cdd6f2fd..51ba4fe9 100644 --- a/src/app/(root)/(routes)/items/[itemId]/components/trade-section/TradeInfo.tsx +++ b/src/app/(root)/(routes)/items/[itemId]/components/trade-section/TradeInfo.tsx @@ -2,13 +2,19 @@ import Image from 'next/image' import Badge from '@/components/ui/Badge' import Assets from '@/config/assets' -const TradeInfo = () => { +type TradeInfoProps = { + title: string + content: string + variant: 'primary' | 'information' +} + +const TradeInfo = ({ title, content, variant }: TradeInfoProps) => { return (
infoImg -
가격대
- - 30만원대 +
{title}
+ + {content}
) diff --git a/src/app/(root)/(routes)/items/[itemId]/components/trade-section/TradeSection.tsx b/src/app/(root)/(routes)/items/[itemId]/components/trade-section/TradeSection.tsx index 13a053ee..344fdfde 100644 --- a/src/app/(root)/(routes)/items/[itemId]/components/trade-section/TradeSection.tsx +++ b/src/app/(root)/(routes)/items/[itemId]/components/trade-section/TradeSection.tsx @@ -1,14 +1,40 @@ import Button from '@/components/ui/Button' import TradeInfo from './TradeInfo' -type TradeSectionProps = {} +type TradeSectionProps = { + priceRange: string + tradeType: string + tradeArea: string +} + +type TradeInfo = { + title: string + content: string + variant: 'primary' | 'information' +} + +const TradeSection = ({ + priceRange, + tradeType, + tradeArea, +}: TradeSectionProps) => { + const tradeInfo: TradeInfo[] = [ + { title: '가격대', content: priceRange, variant: 'primary' }, + { title: '거래 방식', content: tradeType, variant: 'information' }, + { title: '거래 지역', content: tradeArea, variant: 'information' }, + ] -const TradeSection = ({}: TradeSectionProps) => { return (
- - - + {tradeInfo.map((v, i) => ( + + ))} + diff --git a/src/app/(root)/(routes)/items/[itemId]/page.tsx b/src/app/(root)/(routes)/items/[itemId]/page.tsx index cc99de7c..1131394f 100644 --- a/src/app/(root)/(routes)/items/[itemId]/page.tsx +++ b/src/app/(root)/(routes)/items/[itemId]/page.tsx @@ -13,24 +13,29 @@ async function getItemValue(itemId: string) { try { const res = await getItemInfo(itemId) const data = await res.json() - return data + + return data.data.cardResponseDto } catch (e) { - console.log(e) - return null + console.error(e) } } const ItemPage = async ({ params }: ItemPageProps) => { const data = await getItemValue(params.itemId) console.log(data) + const { userName, priceRange, tradeType, tradeArea } = data return (
이미지 슬라이더 영역
- - - + + +
) diff --git a/src/lib/msw/mocks/handlers.ts b/src/lib/msw/mocks/handlers.ts index 4b768f03..c573633a 100644 --- a/src/lib/msw/mocks/handlers.ts +++ b/src/lib/msw/mocks/handlers.ts @@ -1,4 +1,4 @@ -import { itemHandler } from './itemHandlers' +import { itemHandlers } from './itemHandlers' import { testHandlers } from './testHandler' -export const handlers = [...testHandlers, ...itemHandler] +export const handlers = [...testHandlers, ...itemHandlers] diff --git a/src/lib/msw/mocks/itemHandlers.ts b/src/lib/msw/mocks/itemHandlers.ts index 0bfe186f..57042e92 100644 --- a/src/lib/msw/mocks/itemHandlers.ts +++ b/src/lib/msw/mocks/itemHandlers.ts @@ -4,7 +4,7 @@ import ApiEndPoint from '@/config/apiEndPoint' const baseUrl = Environment.apiAddress() -export const itemHandler = [ +export const itemHandlers = [ rest.get(`${baseUrl}${ApiEndPoint.item('3')}`, async (_req, res, ctx) => { return res( ctx.status(200), @@ -15,15 +15,15 @@ export const itemHandler = [ "cardResponseDto": { "cardId": 1, "cardTitle": "아이폰 16 팝니다", - "category": "electro", + "category": "전자기기", "itemName": "아이폰 16", "pokeAvailable": true, "createdAt": '2023-10-23-20:08', "modifiedAt": '2023-10-24-20:08', "viewCount": 19, - "priceRange": "10000-50000", + "priceRange": "10만원대", "content": "이거 진짜 쩔어요", - "status": "can_exchange", + "status": "TRADE_AVAILABLE", "images": [ { "_id": 1, @@ -34,7 +34,7 @@ export const itemHandler = [ "image": "이미지 url" } ], - "dibsCount": 1, + "dibsCount": 14, "userId": 1, "userName": "왕쩌는 구범모", "tradeType": "직거래", diff --git a/src/services/item/item.ts b/src/services/item/item.ts index 076ecc5e..17e99ae4 100644 --- a/src/services/item/item.ts +++ b/src/services/item/item.ts @@ -2,12 +2,7 @@ import apiClient from "../apiClient" import ApiEndPoint from "@/config/apiEndPoint" const getItemInfo = async(itemId:string) =>{ - console.log(itemId) - const response = await apiClient.get(ApiEndPoint.item(itemId), { next: { revalidate: 10 } }, - { - 'Content-Type': 'application/json', - } - ) + const response = await apiClient.get(ApiEndPoint.item(itemId)) return response }