Skip to content

Commit 10cb1b2

Browse files
committed
fix: 마이페이지 카테고리 필터에 하드코딩 제거, 데이터 호출
1 parent 2e80cde commit 10cb1b2

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/routes/my/-components/VideoTab.tsx

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1+
import { useQuery } from "@tanstack/react-query";
12
import { 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

209
interface VideoTabProps {
2110
selectedTab: VideoTabId;
2211
setSelectedTab: (tabId: VideoTabId) => void;
2312
}
2413

2514
export 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"

src/routes/my/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ export const Route = createFileRoute("/my/")({
1919
const PAGE_SIZE = 10;
2020
const GOOGLE_FORM_URL = "https://forms.gle/btXobhr7sAHsXjMg9";
2121

22+
export const ALL_TAB_ID = 0;
23+
2224
function 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 }) => {

0 commit comments

Comments
 (0)