Skip to content
Source
Sign inSign up
fuko/trytanstackdb.com
Open History to see the last commit

_tutorial.tsx

40 lines1.1 KB

1import { createFileRoute, Outlet } from "@tanstack/react-router";
2import z from "zod";
3import { HomeIntro } from "@/components/HomeIntro";
4import { highlightParamSchema } from "@/components/tutorial";
5import { TutorialWindow } from "@/components/tutorial/TutorialWindow";
6import { getShowIntro } from "@/utils/getShowIntro";
7import { getTutorialDataHandlers } from "@/utils/getTutorialDataHandlers";
8​
9export const Route = createFileRoute("/_tutorial")({
10 validateSearch: z
11 .object({
12 temp_db_missing: z.string().optional(),
13 article: z.string().optional(),
14 })
15 .extend(highlightParamSchema.shape),
16 loader: async () => {
17 const { tutorialData } = await getTutorialDataHandlers();
18 const { showIntroState } = getShowIntro();
19 return {
20 tutorialData,
21 showIntroState,
22 };
23 },
24 component: RouteComponent,
25});
26​
27function RouteComponent() {
28 const { tutorialData, showIntroState } = Route.useLoaderData();
29​
30 return (
31 <>
32 <Outlet />
33 <HomeIntro
34 activeStep={tutorialData.tutorialStep}
35 showIntro={showIntroState === "visible"}
36 />
37 <TutorialWindow tutorialData={tutorialData} />
38 </>
39 );