From 09c008a0420def670736bebd9fd9771c32023c33 Mon Sep 17 00:00:00 2001 From: sunpaaaa Date: Thu, 26 Oct 2023 14:35:47 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Fix=20:=20=EC=A2=8B=EC=95=84=EC=9A=94=20?= =?UTF-8?q?=EC=9C=A0=EB=AC=B4=20=ED=99=95=EC=9D=B8=20=EB=B6=88=EA=B0=80?= =?UTF-8?q?=EB=8A=A5=ED=95=9C=20=EA=B2=BD=EC=9A=B0=20=ED=95=B4=EB=8B=B9=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=20=EC=88=A8=EA=B8=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/productItem.tsx | 18 ++++++++++++------ src/templates/mypage/mypageWish.tsx | 1 - src/types/interface.ts | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/components/productItem.tsx b/src/components/productItem.tsx index 638bc8e..d7ded2b 100644 --- a/src/components/productItem.tsx +++ b/src/components/productItem.tsx @@ -24,12 +24,18 @@ export default function ProductItem({ product }: { product: IProduct }) { {product.status === '거래완료' && ( )} -
- {product.like ? : } -

- {product.likes > 0 ? product.likes : ' '} -

-
+ {product.like !== undefined && ( +
+ {product.like ? ( + + ) : ( + + )} +

+ {product.likes > 0 ? product.likes : ' '} +

+
+ )} ); diff --git a/src/templates/mypage/mypageWish.tsx b/src/templates/mypage/mypageWish.tsx index bf4bd70..76023b4 100644 --- a/src/templates/mypage/mypageWish.tsx +++ b/src/templates/mypage/mypageWish.tsx @@ -18,7 +18,6 @@ export default function MypageWish() { useEffect(() => { const fetchData = async () => { const res: AXIOSResponse = await getMyWishList(); - console.log(res); if (res.statusCode === 200) { setProducts(() => { return res.data.filter((product) => { diff --git a/src/types/interface.ts b/src/types/interface.ts index a855c72..6057605 100644 --- a/src/types/interface.ts +++ b/src/types/interface.ts @@ -4,7 +4,7 @@ export interface IProduct { title: string; price: number; likes: number; - like: boolean; + like?: boolean; status: string; thumbnail: string; } From fca6b89a315e06756a83effe9d6dffb938a1ec5b Mon Sep 17 00:00:00 2001 From: sunpaaaa Date: Fri, 27 Oct 2023 19:07:41 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Fix=20:=20=EA=B4=80=EC=8B=AC=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EC=97=90=20=EC=A2=8B=EC=95=84=EC=9A=94=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/templates/mypage/mypageWish.tsx | 40 +++++++++++++++++------------ 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/templates/mypage/mypageWish.tsx b/src/templates/mypage/mypageWish.tsx index 76023b4..d63f23c 100644 --- a/src/templates/mypage/mypageWish.tsx +++ b/src/templates/mypage/mypageWish.tsx @@ -19,27 +19,33 @@ export default function MypageWish() { const fetchData = async () => { const res: AXIOSResponse = await getMyWishList(); if (res.statusCode === 200) { - setProducts(() => { - return res.data.filter((product) => { - if (filter === 'all') { - return product; - } else if ( - filter === 'completed' && - product.status === '거래완료' - ) { - return product; - } else if (filter === 'sale' && product.status === '판매중') { - return product; - } else { - return; - } - }); - }); + switch (filter) { + case 'all': + setProducts(() => { + return res.data.map((product) => ({ ...product, like: true })); + }); + break; + case 'completed': + setProducts(() => { + return res.data + .filter((product) => product.status === '거래완료') + .map((product) => ({ ...product, like: true })); + }); + break; + case 'sale': + setProducts(() => { + return res.data + .filter((product) => product.status === '판매중') + .map((product) => ({ ...product, like: true })); + }); + break; + default: + return; + } } }; fetchData(); }, [filter]); - return ( <>
From 8875aa674dc737b0ba36f24c1bc879ecdd24bb12 Mon Sep 17 00:00:00 2001 From: sunpaaaa Date: Sun, 29 Oct 2023 23:09:39 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Design=20:=20=EB=82=B4=20=ED=8C=90=EB=A7=A4?= =?UTF-8?q?=EB=82=B4=EC=97=AD=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=ED=97=A4?= =?UTF-8?q?=EB=8D=94=20=EB=94=94=EC=9E=90=EC=9D=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/templates/mypage/mypageSale.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/mypage/mypageSale.tsx b/src/templates/mypage/mypageSale.tsx index 4823e09..6aacf71 100644 --- a/src/templates/mypage/mypageSale.tsx +++ b/src/templates/mypage/mypageSale.tsx @@ -43,7 +43,7 @@ export default function MypageSale() { }, [productList, reLoad]); return (
-
+
    {myProducts.map((product) => (