22
33import { Suspense } from "@suspensive/react" ;
44import { useSuspenseQuery } from "@tanstack/react-query" ;
5- import { chunk } from "es-toolkit" ;
5+ import { at , chunk , compact } from "es-toolkit" ;
6+ import { isEmpty } from "es-toolkit/compat" ;
67import Image from "next/image" ;
78import Link from "next/link" ;
89import { type HTMLAttributes , useState } from "react" ;
@@ -13,8 +14,10 @@ import ResetIcon from "@/assets/reset-20.svg";
1314import { Button } from "@/components/ui/Button" ;
1415import { Skeleton } from "@/components/ui/Skeleton" ;
1516import { HStack , VStack } from "@/components/ui/Stack" ;
17+ import { Tag } from "@/components/ui/Tag" ;
1618import { Text } from "@/components/ui/Text" ;
1719import { TextButton } from "@/components/ui/TextButton" ;
20+ import { ALL_TAGS } from "@/constants/tag.constants" ;
1821import { colors } from "@/styles" ;
1922
2023import { cheerQueryOptions } from "../../_api/cheer" ;
@@ -66,23 +69,24 @@ const RecentSupportCardContent = () => {
6669 } }
6770 store = { {
6871 name : cheer . storeName ,
69- imageUrl : cheer . imageUrl ,
72+ imageUrl : cheer . images [ 0 ] ?. url ?? "" ,
7073 location : `${ cheer . storeDistrict } ${ cheer . storeNeighborhood } ` ,
7174 category : cheer . storeCategory ,
7275 } }
7376 content = { cheer . cheerDescription }
77+ tags = { cheer . tags }
7478 />
7579 </ Link >
7680 ) ) }
7781 </ VStack >
78- < Link href = '/stores ' >
82+ < Link href = '/cheer ' >
7983 < Button
8084 variant = 'custom'
8185 size = 'large'
8286 className = { styles . showAllButton }
8387 fullWidth
8488 >
85- 가게 전체보기
89+ 응원 전체보기
8690 </ Button >
8791 </ Link >
8892 </ VStack >
@@ -98,13 +102,19 @@ type RecentSupportCardProps = {
98102 category : string ;
99103 } ;
100104 content : string ;
105+ tags : string [ ] ;
101106} & HTMLAttributes < HTMLDivElement > ;
102107
103108const RecentSupportCard = ( {
104109 store,
105110 content,
111+ tags,
106112 ...restProps
107113} : RecentSupportCardProps ) => {
114+ const selectedTags = ALL_TAGS . filter ( tag => tags ?. includes ( tag . name ) ) ;
115+
116+ const visibleTags = compact ( at ( selectedTags , [ 0 , 1 ] ) ) ;
117+
108118 return (
109119 < VStack gap = { 8 } className = { styles . recentSupportCard } { ...restProps } >
110120 < HStack gap = { 12 } >
@@ -114,7 +124,6 @@ const RecentSupportCard = ({
114124 height = { 40 }
115125 alt = { `${ store . name } 가게 이미지` }
116126 className = { styles . storeImage }
117- objectFit = 'cover'
118127 src = { store . imageUrl }
119128 // TODO: 추후 제거
120129 unoptimized
@@ -152,6 +161,18 @@ const RecentSupportCard = ({
152161 >
153162 { content }
154163 </ Text >
164+
165+ { isEmpty ( selectedTags ) ? null : (
166+ < HStack gap = { 8 } >
167+ { visibleTags . map ( tag => (
168+ < Tag key = { tag . name } >
169+ < Image src = { tag . iconUrl } alt = { tag . label } width = { 14 } height = { 14 } />
170+ { tag . label }
171+ </ Tag >
172+ ) ) }
173+ { selectedTags . length > 2 && < Tag > +{ selectedTags . length - 2 } </ Tag > }
174+ </ HStack >
175+ ) }
155176 </ VStack >
156177 ) ;
157178} ;
0 commit comments