File tree Expand file tree Collapse file tree 2 files changed +19
-19
lines changed
Expand file tree Collapse file tree 2 files changed +19
-19
lines changed Original file line number Diff line number Diff line change 1+ import { useQuery } from "@tanstack/react-query" ;
12import { motion } from "motion/react" ;
3+ import { getAllGyms } from "@/generated/climbing-gym/climbing-gym" ;
4+ import type { GymResponse } from "@/generated/model" ;
5+ import { ALL_TAB_ID } from ".." ;
26
3- const TABS = [
4- {
5- id : null ,
6- name : "전체" ,
7- } ,
8- {
9- id : "1" ,
10- name : "강남점" ,
11- } ,
12- {
13- id : "2" ,
14- name : "논현점" ,
15- } ,
16- ] as const ;
17-
18- export type VideoTabId = ( typeof TABS ) [ number ] [ "id" ] ;
7+ export type VideoTabId = GymResponse [ "id" ] ;
198
209interface VideoTabProps {
2110 selectedTab : VideoTabId ;
2211 setSelectedTab : ( tabId : VideoTabId ) => void ;
2312}
2413
2514export const VideoTab = ( { selectedTab, setSelectedTab } : VideoTabProps ) => {
15+ const { data : gyms = [ { id : ALL_TAB_ID , branchName : "전체" } ] } = useQuery ( {
16+ queryKey : [ "gyms" ] ,
17+ queryFn : ( ) => getAllGyms ( ) ,
18+ select : ( data ) => [
19+ { id : ALL_TAB_ID , branchName : "전체" } ,
20+ ...( data . data ?? [ ] ) ,
21+ ] ,
22+ } ) ;
23+
2624 return (
2725 < div className = "flex items-center gap-2" >
28- { TABS . map ( ( { id, name } ) => (
26+ { gyms ? .map ( ( { id, branchName } ) => (
2927 < button
3028 type = "button"
3129 className = "relative flex-center px-4 py-2"
3230 key = { id }
3331 onClick = { ( ) => setSelectedTab ( id ) }
3432 >
35- < span className = "t-p-14-sb text-neutral-500 z-10" > { name } </ span >
33+ < span className = "t-p-14-sb text-neutral-500 z-10" > { branchName } </ span >
3634 { selectedTab === id && (
3735 < motion . div
3836 layoutId = "video-tab-indicator"
Original file line number Diff line number Diff line change @@ -19,8 +19,10 @@ export const Route = createFileRoute("/my/")({
1919const PAGE_SIZE = 10 ;
2020const GOOGLE_FORM_URL = "https://forms.gle/btXobhr7sAHsXjMg9" ;
2121
22+ export const ALL_TAB_ID = 0 ;
23+
2224function RouteComponent ( ) {
23- const [ selectedTab , setSelectedTab ] = useState < VideoTabId > ( null ) ;
25+ const [ selectedTab , setSelectedTab ] = useState < VideoTabId > ( ALL_TAB_ID ) ;
2426 const [ openIndex , setOpenIndex ] = useState < number | null > ( null ) ;
2527
2628 const fetchVideos = async ( { pageParam = 0 } : { pageParam ?: number } ) => {
You can’t perform that action at this time.
0 commit comments