"use client"; import Link from "next/link"; import { useEffect, useState } from "react"; import { buttonVariants } from "@/components/ui/button"; import { Dialog } from "@/components/ui/dialog"; import { LitGroup, LitLine } from "@/components/ui/lit-line"; import { LitList } from "@/components/ui/lit-list"; import { researchCaseHref } from "@/lib/research/hrefs"; import type { CaseSummary } from "@/lib/research/case-types"; // --------------------------------------------------------------------------- // WHERE A PIN GOES, on the Research page (R2): the board chooser beside the // ask bar, the dialog that asks when nothing is chosen (an existing case, or a // new one named for the query), and the Cases list the page shows before a // search. // --------------------------------------------------------------------------- export function BoardChooser({ cases, value, disabled, onChange, onNew, }: { cases: CaseSummary[]; value: string | null; disabled: boolean; onChange: (id: string | null) => void; onNew: () => void; }) { const current = cases.find((c) => c.id === value); return ( {current && ( Open )} ); } export function PinDialog({ open, mode, cases, query, error, working, onPick, onCreate, onClose, }: { open: boolean; /** "pin": a pin is waiting for its board; "new": only name a new case. */ mode: "pin" | "new"; cases: CaseSummary[]; query: string; error: string | null; working: boolean; onPick: (id: string) => void; onCreate: (title: string) => void; onClose: () => void; }) { const [title, setTitle] = useState(query); useEffect(() => { if (open) setTitle(query); }, [open, query]); return (
{ e.preventDefault(); if (title.trim()) onCreate(title.trim()); }} > setTitle(e.target.value)} placeholder="A new case's title" className="min-w-0 flex-1 rounded-[3px] border border-seam-2 bg-ground px-2.5 py-1.5 text-[13.5px] text-text outline-none focus:border-muted" />
{cases.length > 0 && (
Or an open case {cases.map((c) => ( ))}
)} {error && (

{error}

)}
); } /** The cases, before a search (canvas: Research's Cases). */ export function CaseList({ cases }: { cases: CaseSummary[] }) { if (!cases.length) return null; return ( {cases.map((c) => ( {c.title} {c.error && {c.error}} {c.quotes} {c.quotes === 1 ? "quote" : "quotes"} · {c.sections} {c.sections === 1 ? "section" : "sections"} {c.drifted ? · {c.drifted} drifted : null} {c.updatedAt.slice(0, 10)} ))} ); }