Skip to content

Commit 8bfefeb

Browse files
committed
[WRFE-66](feat): 카테고리별 상품 리스트 구현
1 parent 4fb0ce2 commit 8bfefeb

File tree

2 files changed

+102
-4
lines changed

2 files changed

+102
-4
lines changed

apps/front/wraffle-webview/app/category/page.tsx

Lines changed: 100 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,65 @@ import {Header} from '@/shared/ui';
88
import {CategoryList} from '@/widgets/category-list/ui';
99
import {CategoryMenu} from '@/widgets/category-list/ui';
1010
import {BottomNavigation, Icon, Typography} from '@wraffle/ui';
11+
import {RaffleCard} from '@wraffle/ui';
12+
13+
const sampleProducts = [
14+
{
15+
id: 2,
16+
name: '럭셔리 시계 경품 래플',
17+
price: 10000,
18+
thumbnailUrl:
19+
'https://github.com/user-attachments/assets/4a104905-0106-4b8a-8dcd-06926162e2e6',
20+
scrapCount: 89,
21+
isBookmarked: false,
22+
categoryId: 17,
23+
hashtags: [{id: 8, name: '사진'}],
24+
},
25+
{
26+
id: 3,
27+
name: '최신형 무선 이어버드 래플',
28+
price: 3000,
29+
thumbnailUrl:
30+
'https://github.com/user-attachments/assets/4a104905-0106-4b8a-8dcd-06926162e2e6',
31+
scrapCount: 75,
32+
isBookmarked: false,
33+
categoryId: 17,
34+
hashtags: [{id: 50, name: '엔터테인먼트'}],
35+
},
36+
{
37+
id: 4,
38+
name: '다목적 스마트워치 래플',
39+
price: 7000,
40+
thumbnailUrl:
41+
'https://github.com/user-attachments/assets/4a104905-0106-4b8a-8dcd-06926162e2e6',
42+
scrapCount: 50,
43+
isBookmarked: false,
44+
categoryId: 17,
45+
hashtags: [{id: 70, name: '지속가능성'}],
46+
},
47+
{
48+
id: 1,
49+
name: '한정판 레트로 스니커즈 래플',
50+
price: 5000,
51+
thumbnailUrl:
52+
'https://github.com/user-attachments/assets/4a104905-0106-4b8a-8dcd-06926162e2e6',
53+
scrapCount: 120,
54+
isBookmarked: true,
55+
categoryId: 17,
56+
hashtags: [{id: 34, name: '웨어러블'}],
57+
},
58+
{
59+
id: 5,
60+
name: '에코 전동 스쿠터 래플',
61+
price: 15000,
62+
thumbnailUrl:
63+
'https://github.com/user-attachments/assets/4a104905-0106-4b8a-8dcd-06926162e2e6',
64+
scrapCount: 65,
65+
isBookmarked: false,
66+
categoryId: 17,
67+
hashtags: [{id: 63, name: '친환경'}],
68+
},
69+
];
1170

1271
const CategoryPage = () => {
1372
const searchParams = useSearchParams();
@@ -26,6 +85,12 @@ const CategoryPage = () => {
2685
? categories.filter(category => category.parentId === currentCategory?.id) // 하위 카테고리 필터링
2786
: categories.filter(category => category.parentId === null); // 상위 카테고리 필터링
2887

88+
const filteredProducts = selectedCategory
89+
? sampleProducts.filter(
90+
sampleProducts => sampleProducts.categoryId === selectedCategory,
91+
)
92+
: [];
93+
2994
const handleSelectCategory = (category: CategoryItem) => {
3095
setSelectedCategory(category.id); // 선택된 카테고리 상태만 업데이트
3196
};
@@ -46,18 +111,51 @@ const CategoryPage = () => {
46111
</Header.Right>
47112
</Header>
48113
{currentCategory ? (
49-
<section className='mb-4 flex justify-center'>
114+
<section className='flex flex-col justify-center'>
115+
<Header withUnderline>
116+
<Header.Middle>
117+
<Typography size='h4'>{currentCategory.name}</Typography>
118+
</Header.Middle>
119+
</Header>
50120
<CategoryMenu
51121
categories={filteredCategories}
52122
selectedCategory={selectedCategory}
53123
onSelectCategory={handleSelectCategory}
54124
/>
55125
</section>
56126
) : (
57-
<section className='mb-4 flex justify-center'>
127+
<section className='flex justify-center'>
58128
<CategoryList categories={filteredCategories} />
59129
</section>
60130
)}
131+
{selectedCategory && (
132+
<section className='p-4'>
133+
<div
134+
className='grid justify-center gap-[20px]'
135+
style={{
136+
gridTemplateColumns: 'repeat(auto-fit, 160px)',
137+
}}
138+
>
139+
{filteredProducts.length > 0 ? (
140+
filteredProducts.map(product => (
141+
<RaffleCard
142+
key={product.id}
143+
name={product.name}
144+
thumbnailUrl={product.thumbnailUrl}
145+
price={product.price.toString()}
146+
scrapCount={product.scrapCount}
147+
isBookmarked={product.isBookmarked}
148+
hashtags={product.hashtags}
149+
/>
150+
))
151+
) : (
152+
<Typography size='h5' className='text-gray-500'>
153+
상품 추가 예정입니다.
154+
</Typography>
155+
)}
156+
</div>
157+
</section>
158+
)}
61159
<BottomNavigation />
62160
</div>
63161
);

apps/front/wraffle-webview/src/widgets/category-list/ui/CategoryMenu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ export const CategoryMenu = ({
1212
onSelectCategory,
1313
}: CategoryMenuProps) => {
1414
return (
15-
<nav className='mb-[21px] mt-[21px] flex h-[34px] w-full items-center gap-5 overflow-x-auto whitespace-nowrap px-5 scrollbar-hide'>
15+
<nav className='my-2 flex h-[34px] w-full items-center gap-5 overflow-x-auto whitespace-nowrap px-5 scrollbar-hide'>
1616
{categories.map(category => (
1717
<div
1818
key={category.id}
1919
onClick={() => onSelectCategory(category)}
20-
className={`relative cursor-pointer px-1 pb-3 text-sm font-semibold ${
20+
className={`relative cursor-pointer px-1 text-sm font-semibold ${
2121
selectedCategory === category.id ? 'text-black' : 'text-[#8D95A1]'
2222
}`}
2323
>

0 commit comments

Comments
 (0)