"use client"; import { useState } from "react"; import { MoreHorizontal, Plus, Star, Trash2 } from "lucide-react"; import { cn } from "@/lib/utils"; import { type Group, type StageKey } from "@/lib/schema"; import { DeleteConfirmDialog } from "@/components/workspace/DeleteConfirmDialog"; import { Avatar, AvatarFallback } from "@/components/ui/avatar"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { ScrollArea } from "@/components/ui/scroll-area"; import { AddItemDialog } from "@/components/workspace/AddItemDialog"; type CandidateListPaneProps = { groups: Group[]; selectedCandidateId: string; onSelectCandidate: (id: string) => void; onAddCandidate: (stage: StageKey, name: string) => void; onDeleteCandidate: (id: string) => void; }; export function CandidateListPane({ groups, selectedCandidateId, onSelectCandidate, onAddCandidate, onDeleteCandidate, }: CandidateListPaneProps) { const [addDialogStage, setAddDialogStage] = useState<{ stage: StageKey; label: string; } | null>(null); const [deleteTarget, setDeleteTarget] = useState<{ id: string; name: string; } | null>(null); return ( フロントエンドエンジニア {groups.map((group) => ( {group.label} {group.items.length} setAddDialogStage({ stage: group.stage, label: group.label, }) } aria-label={`${group.label} に候補者を追加`} className="text-muted-foreground hover:text-foreground" > {group.items.map((cand) => { const selected = cand.id === selectedCandidateId; return ( onSelectCandidate(cand.id)} className={cn( "flex w-full items-center gap-3 rounded-md px-2.5 py-2.5 text-left transition-colors", "outline-none focus-visible:ring-3 focus-visible:ring-ring/50", selected ? "bg-accent text-accent-foreground" : "text-foreground hover:bg-muted", )} > {cand.name[0] ?? "?"} {cand.name} } /> setDeleteTarget({ id: cand.id, name: cand.name, }) } > 削除 ); })} ))} {addDialogStage && ( { if (!open) setAddDialogStage(null); }} title="候補者を追加" description={`「${addDialogStage.label}」ステージに候補者を追加します`} fieldLabel="氏名" fieldId="candidate-name" placeholder="例: 山田 太郎" onAdd={(name) => onAddCandidate(addDialogStage.stage, name)} /> )} { if (!open) setDeleteTarget(null); }} title="候補者を削除しますか?" itemName={deleteTarget?.name ?? ""} onConfirm={() => { if (deleteTarget) { onDeleteCandidate(deleteTarget.id); setDeleteTarget(null); } }} /> ); } function ScoreBadge({ avg, selected, }: { avg: number | null; selected: boolean; }) { if (avg === null) { return ( — ); } return ( {avg.toFixed(1)} ); }
{cand.name}