import { createFileRoute, Link } from "@tanstack/react-router"; import { CandidateCard } from "../../components/CandidateCard"; import { useUpdateCandidate } from "../../hooks/useCandidates"; import { useThread } from "../../hooks/useThreads"; import { LucideIcon } from "../../lib/iconData"; import { useUIStore } from "../../stores/uiStore"; export const Route = createFileRoute("/threads/$threadId")({ component: ThreadDetailPage, }); function ThreadDetailPage() { const { threadId: threadIdParam } = Route.useParams(); const threadId = Number(threadIdParam); const { data: thread, isLoading, isError } = useThread(threadId); const openCandidateAddPanel = useUIStore((s) => s.openCandidateAddPanel); const updateCandidate = useUpdateCandidate(threadId); if (isLoading) { return (
{[1, 2, 3].map((i) => (
))}
); } if (isError || !thread) { return (

Thread not found

Back to planning
); } const isActive = thread.status === "active"; const winningCandidate = thread.resolvedCandidateId ? thread.candidates.find((c) => c.id === thread.resolvedCandidateId) : null; return (
{/* Header */}
← Back to planning

{thread.name}

{isActive ? "Active" : "Resolved"}
{/* Resolution banner */} {!isActive && winningCandidate && (

{winningCandidate.name} was picked as the winner and added to your collection.

)} {/* Add candidate button */} {isActive && (
)} {/* Candidate grid */} {thread.candidates.length === 0 ? (

No candidates yet

Add your first candidate to start comparing.

) : (
{thread.candidates.map((candidate) => ( updateCandidate.mutate({ candidateId: candidate.id, status: newStatus, }) } pros={candidate.pros} cons={candidate.cons} /> ))}
)}
); }