11"use client" ;
22
3+ import { useQuery } from "@tanstack/react-query" ;
4+ import Image from "next/image" ;
5+ import Link from "next/link" ;
6+ import { useRouter } from "next/navigation" ;
7+
8+ import { storeDetailQueryOptions } from "@/app/(store)/_api/shop" ;
9+ import { Avatar } from "@/app/member/_components/Avatar" ;
10+ import { storiesByKakaoIdQueryOptions } from "@/app/story/_api" ;
311import CameraIcon from "@/assets/camera.svg" ;
412import { Button } from "@/components/ui/Button" ;
513import { Spacer } from "@/components/ui/Spacer" ;
@@ -10,35 +18,77 @@ import { colors } from "@/styles";
1018import * as styles from "./StoreStories.css" ;
1119
1220export const StoreStories = ( { storeId } : { storeId : number } ) => {
13- void storeId ;
21+ const router = useRouter ( ) ;
22+ const { data : store } = useQuery ( storeDetailQueryOptions ( Number ( storeId ) ) ) ;
23+
24+ if ( ! store ) {
25+ return (
26+ < VStack className = { styles . storeStoriesContainer } >
27+ < Text > 가게 정보를 불러오는 중...</ Text >
28+ </ VStack >
29+ ) ;
30+ }
1431
15- const isEmpty = true ;
32+ const handleClick = ( ) => {
33+ router . push ( "/" ) ;
34+ } ;
1635
1736 return (
1837 < VStack className = { styles . storeStoriesContainer } >
19- { isEmpty ? < EmptyStoreStories /> : < StoreStoriesContent /> }
38+ < StoreStoriesContent kakaoId = { store . kakaoId } />
2039
2140 < Spacer size = { 20 } />
2241
2342 < Button variant = 'assistive' size = 'large' fullWidth >
24- < HStack gap = { 6 } align = 'center' >
25- 방문 스토리 남기기 < CameraIcon color = { colors . neutral [ 10 ] } />
43+ < HStack gap = { 6 } align = 'center' onClick = { handleClick } >
44+ < Text typo = 'body1Sb' > 방문 스토리 남기기</ Text >
45+ < CameraIcon color = { colors . neutral [ 10 ] } />
2646 </ HStack >
2747 </ Button >
2848 </ VStack >
2949 ) ;
3050} ;
3151
32- const StoreStoriesContent = ( ) => {
52+ const StoreStoriesContent = ( { kakaoId } : { kakaoId : string } ) => {
53+ const { data : stories } = useQuery ( storiesByKakaoIdQueryOptions ( kakaoId , 20 ) ) ;
54+
55+ if ( ! stories || stories . stories . length === 0 ) {
56+ return < EmptyStoreStories /> ;
57+ }
58+
3359 return (
3460 < VStack >
3561 < Text as = 'h3' typo = 'title2Sb' color = 'text.normal' >
3662 가게에 담긴 스토리
3763 </ Text >
3864
3965 < Spacer size = { 16 } />
40-
41- < div > 스토리들</ div >
66+ < HStack gap = { 4 } >
67+ { stories . stories . map ( data => (
68+ < Link href = { `/story/${ data . storyId } ` } key = { data . storyId } >
69+ < div className = { styles . storyWrapper } >
70+ < Image
71+ src = { data . imageUrl }
72+ alt = '스토리 이미지'
73+ className = { styles . image }
74+ width = { 124 }
75+ height = { 220 }
76+ />
77+ < div className = { styles . overlay } />
78+ < HStack align = 'center' gap = { 4 } className = { styles . memberWrapper } >
79+ < Avatar memberId = { data . memberId } />
80+ < Text
81+ typo = 'label1Sb'
82+ color = 'text.white'
83+ className = { styles . nickname }
84+ >
85+ { data . memberNickname }
86+ </ Text >
87+ </ HStack >
88+ </ div >
89+ </ Link >
90+ ) ) }
91+ </ HStack >
4292 </ VStack >
4393 ) ;
4494} ;
0 commit comments