diff --git a/web-ui/src/components/precedents/precedent-upload-sheet.tsx b/web-ui/src/components/precedents/precedent-upload-sheet.tsx index 90c9799..b7cdacf 100644 --- a/web-ui/src/components/precedents/precedent-upload-sheet.tsx +++ b/web-ui/src/components/precedents/precedent-upload-sheet.tsx @@ -16,8 +16,9 @@ import { } from "@/components/ui/select"; import { Progress } from "@/components/ui/progress"; import { - useUploadPrecedent, libraryKeys, - type PracticeArea, type SourceType, + useUploadPrecedent, useUploadInternalDecision, libraryKeys, + isCommitteeCitation, COMMITTEE_DISTRICTS, + type PracticeArea, type SourceType, type CommitteeDistrict, } from "@/lib/api/precedent-library"; import { useProgress } from "@/lib/api/documents"; import { @@ -45,8 +46,15 @@ export function PrecedentUploadSheet({ open, onOpenChange }: Props) { const [headnote, setHeadnote] = useState(""); const [isBinding, setIsBinding] = useState(true); + // Appeals-committee decisions go to /api/internal-decisions/upload and + // require chair_name + district. Routing is by citation prefix. + const [chairName, setChairName] = useState(""); + const [district, setDistrict] = useState(""); + const isCommittee = isCommitteeCitation(citation); + const [taskId, setTaskId] = useState(null); const upload = useUploadPrecedent(); + const uploadInternal = useUploadInternalDecision(); const progress = useProgress(taskId); const qc = useQueryClient(); @@ -63,6 +71,8 @@ export function PrecedentUploadSheet({ open, onOpenChange }: Props) { setPracticeArea(""); setAppealSubtype(""); setSubjectTags(""); // eslint-disable-next-line react-hooks/set-state-in-effect setHeadnote(""); setIsBinding(true); setTaskId(null); + // eslint-disable-next-line react-hooks/set-state-in-effect + setChairName(""); setDistrict(""); }, [open]); // Auto-close on completion + refresh library list/stats so the new @@ -93,11 +103,39 @@ export function PrecedentUploadSheet({ open, onOpenChange }: Props) { toast.error("מראה המקום (citation) חובה"); return; } + const tags = subjectTags + .split(",") + .map((t) => t.trim()) + .filter(Boolean); + try { - const tags = subjectTags - .split(",") - .map((t) => t.trim()) - .filter(Boolean); + if (isCommittee) { + if (!chairName.trim()) { + toast.error("שם יו\"ר חובה להחלטת ועדת ערר"); + return; + } + if (!district) { + toast.error("מחוז חובה להחלטת ועדת ערר"); + return; + } + const res = await uploadInternal.mutateAsync({ + file, + case_number: citation.trim(), + chair_name: chairName.trim(), + district, + case_name: caseName.trim(), + court: court.trim(), + decision_date: decisionDate || undefined, + practice_area: practiceArea, + appeal_subtype: appealSubtype.trim(), + subject_tags: tags, + is_binding: isBinding, + summary: headnote.trim(), + }); + setTaskId(res.task_id); + return; + } + const res = await upload.mutateAsync({ file, citation: citation.trim(), @@ -119,6 +157,7 @@ export function PrecedentUploadSheet({ open, onOpenChange }: Props) { }; const isProcessing = taskId !== null && progress?.status !== "completed" && progress?.status !== "failed"; + const isSubmitting = upload.isPending || uploadInternal.isPending; const stage = (progress as { stage?: string; percent?: number; step?: string } | null)?.stage; const percent = (progress as { percent?: number } | null)?.percent ?? 0; @@ -154,8 +193,45 @@ export function PrecedentUploadSheet({ open, onOpenChange }: Props) { placeholder={`עע"מ 3975/22 ב. קרן-נכסים נ' ועדה מקומית`} disabled={isProcessing} dir="rtl" /> + {isCommittee && ( +

+ זוהתה כהחלטת ועדת ערר — נדרשים שם יו"ר ומחוז (למטה). +

+ )} + {isCommittee && ( +
+
+ + setChairName(e.target.value)} + placeholder='עו"ד פלוני אלמוני' + disabled={isProcessing} dir="rtl" + /> +
+
+ + +
+
+ )} +
אופציונלי — דריסה ידנית של שדות שיחולצו אוטומטית מהמסמך @@ -206,36 +282,38 @@ export function PrecedentUploadSheet({ open, onOpenChange }: Props) { -
-
- - + {!isCommittee && ( +
+
+ + +
+
+ + +
-
- - -
-
+ )}
@@ -286,11 +364,11 @@ export function PrecedentUploadSheet({ open, onOpenChange }: Props) {