Skip to content

Commit

Permalink
Merge branch 'dev' into feature/#94
Browse files Browse the repository at this point in the history
  • Loading branch information
LeHiHo authored Nov 21, 2023
2 parents b83a31a + 5bd2a08 commit 46e2ca0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 26 deletions.
18 changes: 12 additions & 6 deletions src/components/productItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ export default function ProductItem({ product }: { product: IProduct }) {
{product.status === '거래완료' && (
<ProductBadge productStatus={product.status} state={'sold'} />
)}
<div className="like">
{product.like ? <AiFillHeart /> : <AiOutlineHeart />}
<p className="like__counter">
{product.likes > 0 ? product.likes : ' '}
</p>
</div>
{product.like !== undefined && (
<div className="like">
{product.like ? (
<AiFillHeart color="#ff0000" />
) : (
<AiOutlineHeart />
)}
<p className="like__counter">
{product.likes > 0 ? product.likes : ' '}
</p>
</div>
)}
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/templates/mypage/mypageSale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function MypageSale() {
}, [productList, reLoad]);
return (
<div className="saleList">
<Header goBack={true} border={true} title={'판매내역'} />
<Header goBack={true} title={'판매내역'} />
<ProductStateList onChangeList={handleChangeList} />
<ul className="product-list">
{myProducts.map((product) => (
Expand Down
41 changes: 23 additions & 18 deletions src/templates/mypage/mypageWish.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,34 @@ export default function MypageWish() {
useEffect(() => {
const fetchData = async () => {
const res: AXIOSResponse<IProduct[]> = await getMyWishList();
console.log(res);
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 (
<>
<Header goBack={true} title="관심상품" />
Expand Down
2 changes: 1 addition & 1 deletion src/types/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export interface IProduct {
title: string;
price: number;
likes: number;
like: boolean;
like?: boolean;
status: string;
thumbnail: string;
}
Expand Down

0 comments on commit 46e2ca0

Please sign in to comment.