fix(#77 frontend): separate מספר-תיק field on committee upload + editable case_number in edit sheet

Pairs with the backend PR. Stops the citation (מראה-מקום) from being stored
as the identifier, and lets a wrong identifier be corrected after the fact.

- upload sheet: new required 'מספר תיק (מזהה ייחודי)' field for committee
  decisions → sent as case_number; the citation field is now sent as the
  separate citation (→ citation_formatted) instead of as case_number.
- edit sheet: the case_number block is now an editable input (was read-only).
  Halachot/chunks key off case_law_id (UUID), so renaming case_number is safe.
- precedent-library.ts: InternalDecisionUploadInput += citation; PrecedentPatch
  += case_number.
- types.ts: regenerated (api:types) — PrecedentUpdateRequest now carries
  case_number.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-02 12:17:16 +00:00
parent fc0c36b2f8
commit 7be1c3162c
4 changed files with 1065 additions and 24 deletions

View File

@@ -35,7 +35,7 @@ type Props = {
* each time the sheet opens so the form reflects any auto-fill that
* happened in the background. */
type FormState = {
citation: string;
case_number: string;
citation_formatted: string;
case_name: string;
court: string;
@@ -54,7 +54,7 @@ type FormState = {
};
const EMPTY: FormState = {
citation: "", citation_formatted: "",
case_number: "", citation_formatted: "",
case_name: "", court: "", district: "", chair_name: "",
decision_date: "", practice_area: "", appeal_subtype: "", source_type: "",
precedent_level: "", is_binding: true, subject_tags: "",
@@ -76,7 +76,7 @@ export function PrecedentEditSheet({ caseLawId, onOpenChange }: Props) {
if (record && record.id !== syncedRecordId) {
setSyncedRecordId(record.id as string);
setForm({
citation: record.case_number || "",
case_number: record.case_number || "",
citation_formatted: record.citation_formatted || "",
case_name: record.case_name || "",
court: record.court || "",
@@ -117,8 +117,10 @@ export function PrecedentEditSheet({ caseLawId, onOpenChange }: Props) {
key_quote: form.key_quote.trim(),
};
if (form.decision_date) patch.decision_date = form.decision_date;
// citation (case_number) is the unique key; we don't allow editing it
// here to avoid orphaning halachot. To rename, delete + re-upload.
// case_number is the canonical identifier. Editing it is safe —
// halachot/chunks reference case_law_id (UUID), not the case_number
// text — so a wrong id captured at upload can be corrected here.
if (form.case_number.trim()) patch.case_number = form.case_number.trim();
await update.mutateAsync({ id: caseLawId, patch });
toast.success("נשמר");
onOpenChange(false);
@@ -148,7 +150,7 @@ export function PrecedentEditSheet({ caseLawId, onOpenChange }: Props) {
<DialogHeader className="px-6 pt-6">
<DialogTitle className="text-navy">עריכת פרטי פסיקה</DialogTitle>
<DialogDescription className="text-ink-muted">
כל השדות ניתנים לעריכה חוץ ממספר התיק (מזהה ייחודי במערכת).
כל השדות ניתנים לעריכה, כולל מספר התיק (המזהה הייחודי).
כפתור &quot;חלץ מטא-דאטה&quot; שולח בקשה לתור מקומי שאני מרוקן
מ-Claude Code (ה-LLM רץ מקומית עם <code>claude session</code>,
לא ב-API).
@@ -162,12 +164,17 @@ export function PrecedentEditSheet({ caseLawId, onOpenChange }: Props) {
) : (
<>
<form onSubmit={onSubmit} className="px-6 pb-6 space-y-4 mt-4">
<div className="rounded-lg border border-rule bg-rule-soft/40 p-3 flex items-start gap-3">
<div className="flex-1 min-w-0">
<div className="text-[0.78rem] text-ink-muted">מספר תיק (מזהה ייחודי לא ניתן לעריכה)</div>
<div className="text-navy font-mono text-sm break-all" dir="ltr">
{record.case_number}
</div>
<div className="rounded-lg border border-rule bg-rule-soft/40 p-3 flex items-end gap-3">
<div className="flex-1 min-w-0 space-y-1">
<Label htmlFor="case-number" className="text-[0.78rem] text-ink-muted">
מספר תיק (מזהה ייחודי)
</Label>
<Input
id="case-number" value={form.case_number}
onChange={(e) => setForm({ ...form, case_number: e.target.value })}
className="font-mono text-sm" dir="ltr"
placeholder="8027-25"
/>
</div>
<Button
type="button" size="sm" variant="outline"