import { createFileRoute, Link } from "@tanstack/react-router"; import { AnimatePresence, motion } from "framer-motion"; import { useRef } from "react"; import { z } from "zod"; import { CollectionView } from "../../components/CollectionView"; import { PlanningView } from "../../components/PlanningView"; const searchSchema = z.object({ tab: z.enum(["gear", "planning"]).catch("gear"), }); export const Route = createFileRoute("/collection/")({ validateSearch: searchSchema, component: CollectionPage, }); const TAB_ORDER = ["gear", "planning"] as const; const TAB_LABELS: Record<(typeof TAB_ORDER)[number], string> = { gear: "Gear", planning: "Planning", }; const slideVariants = { enter: (dir: number) => ({ x: `${dir * 15}%`, opacity: 0 }), center: { x: 0, opacity: 1 }, exit: (dir: number) => ({ x: `${dir * -15}%`, opacity: 0 }), }; function CollectionPage() { const { tab } = Route.useSearch(); const prevTab = useRef(tab); const direction = TAB_ORDER.indexOf(tab) >= TAB_ORDER.indexOf(prevTab.current) ? 1 : -1; prevTab.current = tab; return (