import { useState } from "react"; import { createFileRoute } from "@tanstack/react-router"; import { useSetups, useCreateSetup } from "../../hooks/useSetups"; import { SetupCard } from "../../components/SetupCard"; export const Route = createFileRoute("/setups/")({ component: SetupsListPage, }); function SetupsListPage() { const [newSetupName, setNewSetupName] = useState(""); const { data: setups, isLoading } = useSetups(); const createSetup = useCreateSetup(); function handleCreateSetup(e: React.FormEvent) { e.preventDefault(); const name = newSetupName.trim(); if (!name) return; createSetup.mutate( { name }, { onSuccess: () => setNewSetupName("") }, ); } return (
{/* Create setup form */}
setNewSetupName(e.target.value)} placeholder="New setup name..." className="flex-1 px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent" />
{/* Loading skeleton */} {isLoading && (
{[1, 2].map((i) => (
))}
)} {/* Empty state */} {!isLoading && (!setups || setups.length === 0) && (
🏕️

No setups yet

Create one to plan your loadout.

)} {/* Setup grid */} {!isLoading && setups && setups.length > 0 && (
{setups.map((setup) => ( ))}
)}
); }