"use client"; import { useState } from "react"; import { X, Plus } from "lucide-react"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; /* * Minimal tag-style editor for a list of party names (appellants / respondents). * Backed by a controlled string[] — submits as the same shape the FastAPI * CaseCreateRequest expects. Enter adds the current draft; X removes a chip. */ export function PartiesField({ label, value, onChange, error, }: { label: string; value: string[]; onChange: (next: string[]) => void; error?: string; }) { const [draft, setDraft] = useState(""); const add = () => { const trimmed = draft.trim(); if (!trimmed) return; if (value.includes(trimmed)) { setDraft(""); return; } onChange([...value, trimmed]); setDraft(""); }; const remove = (name: string) => { onChange(value.filter((v) => v !== name)); }; return (
{value.length > 0 && ( )}
setDraft(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") { e.preventDefault(); add(); } }} placeholder="שם מלא של הצד" dir="rtl" />
{error &&

{error}

}
); }