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 b256d50d..d7822721 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 @@ -26,8 +26,29 @@ type TradeStateMap = { } const DescriptionSection = ({ - itemData: { status, cardTitle, category, createdAt, dibs, content, cardId }, + itemData: { + status, + cardTitle, + category, + createdAt, + dibs, + content, + cardId, + userId: authorId, + }, }: DescriptionSectionProps) => { + // FIX : 로그인 관련 완성되면 실제 데이터로 수정 + // const { isLoggedIn } = useAuth() + // const {currentUser} = useAuth(); + + const currentUser = { + imageUrl: 'http://asdf~', + nickname: '병원에 간 미어캣', + userId: 3, + } + const isLoggedIn = true + const isMyItem = currentUser.userId === authorId + const tradeStateMap: TradeStateMap = { TRADE_AVAILABLE: { style: 'primary', @@ -49,7 +70,7 @@ const DescriptionSection = ({ {tradeStateMap[status].text}
{createdAt}
-{content}
diff --git a/src/app/(root)/(routes)/items/[itemId]/components/trade-section/SuggestList.tsx b/src/app/(root)/(routes)/items/[itemId]/components/trade-section/SuggestList.tsx index fb73cd7a..df387c2c 100644 --- a/src/app/(root)/(routes)/items/[itemId]/components/trade-section/SuggestList.tsx +++ b/src/app/(root)/(routes)/items/[itemId]/components/trade-section/SuggestList.tsx @@ -3,7 +3,7 @@ import { Tabs, TabsTrigger, TabsList, TabsContent } from '@/components/ui/Tabs' import { ItemSuggestion } from '@/types' type SuggestListProps = { - suggestionData: [] + suggestionData: ItemSuggestion[] } /** 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 5dcf3a13..ca4adebc 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,3 +1,6 @@ +'use client' + +import { useEffect, useState } from 'react' import Button from '@/components/ui/Button' import { Dialog, @@ -14,6 +17,7 @@ type TradeSectionProps = { priceRange: string tradeType: string tradeArea: string + authorId: number itemId: string } @@ -23,24 +27,27 @@ type TradeInfo = { variant: 'primary' | 'information' } -async function getSuggestionsValue(itemId: string) { - try { - const res = await getSuggestions(itemId) - const data = await res.json() - - return data.data.cardList - } catch (e) { - console.log(e) - } -} - -const TradeSection = async ({ +const TradeSection = ({ priceRange, tradeType, tradeArea, + authorId, itemId, }: TradeSectionProps) => { - const suggestions = await getSuggestionsValue(itemId) + // FIX : 로그인 관련 완성되면 실제 데이터로 수정 + // const { isLoggedIn } = useAuth() + // const {currentUser} = useAuth(); + + const currentUser = { + imageUrl: 'http://asdf~', + nickname: '병원에 간 미어캣', + userId: 3, + } + + const isLoggedIn = true + const isMyItem = currentUser.userId === authorId + const [suggestions, setSuggestions] = useState([]) + const [open, setOpen] = useState(false) const tradeInfo: TradeInfo[] = [ { title: '가격대', content: priceRange, variant: 'primary' }, @@ -48,6 +55,29 @@ const TradeSection = async ({ { title: '거래 지역', content: tradeArea, variant: 'information' }, ] + const onClickButton = () => { + if (isMyItem) { + alert('제안확인 페이지로 이동하기') + } else { + setOpen(true) + } + } + + useEffect(() => { + async function getSuggestionsValue(itemId: string) { + try { + const res = await getSuggestions(itemId) + if (res.status == 200) { + const data = await res.json() + setSuggestions(data.data.cardList) + } + } catch (e) { + console.log(e) + } + } + getSuggestionsValue(itemId) + }, [itemId]) + return (