import { useState } from "react" import { toast } from "sonner" import { useQuery } from "@tanstack/react-query" import type { ItemDetail } from "@workspace/types" import { Button } from "@workspace/ui/components/button" import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@workspace/ui/components/collapsible" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@workspace/ui/components/select" import { optionsQuery, useItemAction } from "@/lib/api" import { words } from "@/lib/format" function Choice({ label, value, options, onChange }: { label: string; value: string; options: Record; onChange: (v: string) => void }) { const items = Object.keys(options).map((k) => ({ value: k, label: words(k) })) return ( ) } /** "Triaged: bug · upload · ios · severity 2.0", with a way to correct it. */ export function TriageLine({ item }: { item: ItemDetail }) { const t = item.triage const options = useQuery(optionsQuery) const act = useItemAction(item.id) const [draft, setDraft] = useState({ kind: t?.kind ?? "", area: t?.area ?? "", platform: t?.platform ?? "" }) if (!t) { return item.status === "new" ?

Waiting for triage

: null } const reason = item.routeReason && !item.routeReason.startsWith(t.kind) ? ` · ${item.routeReason}` : "" const summary = [words(t.kind), t.area, t.platform !== "unknown" ? t.platform : "", `severity ${t.severity.toFixed(1)}`] .filter(Boolean) .join(" · ") return (

Triaged: {summary} {reason} {" · "} correct

{options.data && (
setDraft({ ...draft, kind })} /> setDraft({ ...draft, area })} /> setDraft({ ...draft, platform })} />
)}
) }