ui(precedents): upload sheet routes ערר/בל"מ to internal-decisions endpoint
Some checks failed
Build & Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build & Deploy / build-and-deploy (push) Has been cancelled
Citations starting with ערר/בל"מ/ARAR are committee decisions and must carry chair_name + district. The /precedents upload form previously errored out for these (precedent_library service rejects them) with no in-UI path forward — internal_decision_upload was only reachable via the /missing-precedents flow. The form now auto-detects committee citations, reveals chair_name + district fields, hides the irrelevant source_type/precedent_level (derived server-side), and posts to /api/internal-decisions/upload. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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<CommitteeDistrict | "">("");
|
||||
const isCommittee = isCommitteeCitation(citation);
|
||||
|
||||
const [taskId, setTaskId] = useState<string | null>(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 && (
|
||||
<p className="text-[0.72rem] text-ink-muted">
|
||||
זוהתה כהחלטת ועדת ערר — נדרשים שם יו"ר ומחוז (למטה).
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{isCommittee && (
|
||||
<div className="grid grid-cols-2 gap-3 rounded-md border border-gold/40 bg-gold-wash/40 p-3">
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="chair-name">שם יו"ר (חובה)</Label>
|
||||
<Input
|
||||
id="chair-name" value={chairName}
|
||||
onChange={(e) => setChairName(e.target.value)}
|
||||
placeholder='עו"ד פלוני אלמוני'
|
||||
disabled={isProcessing} dir="rtl"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="district">מחוז (חובה)</Label>
|
||||
<Select
|
||||
value={district || "_none"}
|
||||
onValueChange={(v) =>
|
||||
setDistrict(v === "_none" ? "" : (v as CommitteeDistrict))
|
||||
}
|
||||
disabled={isProcessing}
|
||||
>
|
||||
<SelectTrigger><SelectValue placeholder="—" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="_none">—</SelectItem>
|
||||
{COMMITTEE_DISTRICTS.map((d) => (
|
||||
<SelectItem key={d} value={d}>{d}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<details className="group rounded-md border border-rule bg-rule-soft/30">
|
||||
<summary className="cursor-pointer select-none px-3 py-2 text-[0.78rem] text-ink-muted hover:text-navy">
|
||||
אופציונלי — דריסה ידנית של שדות שיחולצו אוטומטית מהמסמך
|
||||
@@ -206,36 +282,38 @@ export function PrecedentUploadSheet({ open, onOpenChange }: Props) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="source-type">סוג מקור</Label>
|
||||
<Select value={sourceType || "_none"}
|
||||
onValueChange={(v) => setSourceType(v === "_none" ? "" : v as SourceType)}
|
||||
disabled={isProcessing}>
|
||||
<SelectTrigger><SelectValue placeholder="—" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="_none">—</SelectItem>
|
||||
{SOURCE_TYPES.map((s) => (
|
||||
<SelectItem key={s.value} value={s.value}>{s.label}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
{!isCommittee && (
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="source-type">סוג מקור</Label>
|
||||
<Select value={sourceType || "_none"}
|
||||
onValueChange={(v) => setSourceType(v === "_none" ? "" : v as SourceType)}
|
||||
disabled={isProcessing}>
|
||||
<SelectTrigger><SelectValue placeholder="—" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="_none">—</SelectItem>
|
||||
{SOURCE_TYPES.map((s) => (
|
||||
<SelectItem key={s.value} value={s.value}>{s.label}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="precedent-level">רמת תקדים</Label>
|
||||
<Select value={precedentLevel || "_none"}
|
||||
onValueChange={(v) => setPrecedentLevel(v === "_none" ? "" : v)}
|
||||
disabled={isProcessing}>
|
||||
<SelectTrigger><SelectValue placeholder="—" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="_none">—</SelectItem>
|
||||
{PRECEDENT_LEVELS.map((l) => (
|
||||
<SelectItem key={l.value} value={l.value}>{l.label}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="precedent-level">רמת תקדים</Label>
|
||||
<Select value={precedentLevel || "_none"}
|
||||
onValueChange={(v) => setPrecedentLevel(v === "_none" ? "" : v)}
|
||||
disabled={isProcessing}>
|
||||
<SelectTrigger><SelectValue placeholder="—" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="_none">—</SelectItem>
|
||||
{PRECEDENT_LEVELS.map((l) => (
|
||||
<SelectItem key={l.value} value={l.value}>{l.label}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="tags">תגיות נושא (מופרדות בפסיקים)</Label>
|
||||
@@ -286,11 +364,11 @@ export function PrecedentUploadSheet({ open, onOpenChange }: Props) {
|
||||
|
||||
<div className="flex gap-2 justify-end pt-2">
|
||||
<Button type="button" variant="ghost"
|
||||
onClick={() => onOpenChange(false)} disabled={upload.isPending}>
|
||||
onClick={() => onOpenChange(false)} disabled={isSubmitting}>
|
||||
ביטול
|
||||
</Button>
|
||||
<Button type="submit"
|
||||
disabled={upload.isPending || isProcessing}
|
||||
disabled={isSubmitting || isProcessing}
|
||||
className="bg-navy text-parchment hover:bg-navy-soft">
|
||||
<Upload className="w-4 h-4 me-1" />
|
||||
העלה
|
||||
|
||||
Reference in New Issue
Block a user