From faad41039aa297464f16fc176e619548ba1133a6 Mon Sep 17 00:00:00 2001 From: cfngc4594 Date: Mon, 3 Mar 2025 13:56:25 +0800 Subject: [PATCH] feat(problem): add tabs state management with zustand and loading skeleton --- src/app/(app)/playground/@problem/layout.tsx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/app/(app)/playground/@problem/layout.tsx b/src/app/(app)/playground/@problem/layout.tsx index 23a2af6..2d93f1e 100644 --- a/src/app/(app)/playground/@problem/layout.tsx +++ b/src/app/(app)/playground/@problem/layout.tsx @@ -1,3 +1,7 @@ +"use client"; + +import { Skeleton } from "@/components/ui/skeleton"; +import { useTabsStore } from "@/store/useTabsStore"; import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { CircleCheckBigIcon, FileTextIcon, FlaskConicalIcon } from "lucide-react"; @@ -13,8 +17,22 @@ export default function ProblemLayout({ solution, submission, }: ProblemLayoutProps) { + const { hydrated, problemTab, setProblemTab } = useTabsStore(); + + if (!hydrated) return ( +
+ + + +
+ ) + + const handleTabChange = (value: string) => { + setProblemTab(value); + }; + return ( - +