Files
legal-ai/web-ui/src/components/digests/digest-upload-dialog.tsx
Chaim f3b075d282
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 6s
feat(ui): IA redesign → production · יישום נאמן של 16 הדפים הנותרים למוקאפים
תיקון הגישה: יישום מלא ונאמן של עיצוב-המוקאפים המאושרים (Claude Design) על כל
הדפים — שינוי-הרכב אמיתי פר-מוקאפ, לא ליטוש-טוקנים. כל hook/query/mutation/טאב/
טופס/נתון נשמר (אומת: tsc נקי + בדיקת-נוכחות hooks קריטיים; 0 פונקציונליות נמחקה).

דפים (← מוקאפ):
- בית — לוח: KPI + "תיקים לפי סטטוס" (bars) + כרטיס-אישורים + CTA כפול.
- ארכיון — filter-bar שטוח + טבלה נקייה + צ'יפי-סוג/תוצאה.
- הערות יו״ר — פריסה דו-טורית + טופס-הוספה חי + כרטיסי-הערה.
- ספריית-פסיקה — tabs קו-תחתון + כרטיסי-תוצאה halacha/קטע + AuthorityBadge.
- דף-תקדים — באנר-meta parchment + דו-טורי + provenance pills.
- פסיקה-חסרה — pill פתוחים + צ'יפי-סטטוס + CTA העלאה.
- יומונים — אזור-העלאה מקווקו + כרטיסי-digest + "ממתין" כתווית פסיבית.
- גרף — פאנל-צד שכבות/אנליטיקה + canvas parchment.
- אימון-סגנון — פורטרט: banner + KPI + אנטומיה + ביטויי-חתימה.
- מתודולוגיה — עורך-צ'קליסט + "חל על:" + canon chip.
- מיומנויות/סקריפטים — טבלאות אמיתיות + צ'יפי-סטטוס.
- הגדרות — sidenav דו-טורי + env-rows עם "ממתין ל-redeploy".
- דף-תיק — באנר-תיק parchment + tabs + timeline + "פתח עורך החלטה".
- תפעול — SectionHeaders + טבלת-שירותים + כרטיסי-שער gold-wash.
- compose — באנר-תיק + SOT pill + פריסה דו-טורית + "השלמה והעברה".

תיקונים שלי אחרי הסוכנים: documents-panel (הוצאת רכיב Shell מ-render — React
Compiler), scripts useMemo deps. /approvals כבר נבנה מחדש נאמנה (commit קודם).

בדיקות: npx tsc --noEmit ✓ · eslint ✓ (לבד מ-learning-panel:109 קיים-מראש).
שימור-פונקציונליות אומת. CI Docker build = שער סופי לפני deploy.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-11 23:00:25 +00:00

155 lines
5.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import { useState } from "react";
import { Upload } from "lucide-react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import {
Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader,
DialogTitle, DialogTrigger,
} from "@/components/ui/dialog";
import {
Select, SelectContent, SelectItem, SelectTrigger, SelectValue,
} from "@/components/ui/select";
import { useUploadDigest, type DigestUploadInput } from "@/lib/api/digests";
import type { PracticeArea } from "@/lib/api/precedent-library";
import { PRACTICE_AREAS } from "@/components/precedents/practice-area";
/**
* Upload a "כל יום" digest PDF. The endpoint is container-safe: it only
* stages + extracts text, creating a row with status='pending'. The LLM
* enrichment (concept/headline/citation + embedding + autolink) runs locally
* via the MCP drainer ``digest_process_pending`` — so the toast tells the
* user the digest is queued, not yet searchable.
*/
export function DigestUploadDialog({ trigger }: { trigger?: React.ReactNode } = {}) {
const [open, setOpen] = useState(false);
const [file, setFile] = useState<File | null>(null);
const [yomonNumber, setYomonNumber] = useState("");
const [digestDate, setDigestDate] = useState("");
const [practiceArea, setPracticeArea] = useState<PracticeArea>("");
const upload = useUploadDigest();
const reset = () => {
setFile(null);
setYomonNumber("");
setDigestDate("");
setPracticeArea("");
};
const onSubmit = (e: React.FormEvent) => {
e.preventDefault();
if (!file) {
toast.error("בחר קובץ יומון (PDF)");
return;
}
const input: DigestUploadInput = { file };
if (yomonNumber.trim()) input.yomon_number = yomonNumber.trim();
if (digestDate) input.digest_date = digestDate;
if (practiceArea) input.practice_area = practiceArea;
upload.mutate(input, {
onSuccess: (res) => {
if (res.status === "exists") {
toast.info("יומון זהה כבר קיים — לא נוצר כפל");
} else {
toast.success(
"היומון נקלט וממתין לעיבוד מקומי (LLM). הרץ digest_process_pending " +
"או scripts/ingest_digests_batch.py כדי להשלים חילוץ + חיפוש.",
);
}
reset();
setOpen(false);
},
onError: (err) => {
toast.error(`שגיאה בהעלאה: ${err.message}`);
},
});
};
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
{trigger ?? (
<Button className="bg-gold text-white hover:bg-gold-deep border-transparent">
<Upload className="w-4 h-4 me-1" />
העלאת יומון
</Button>
)}
</DialogTrigger>
<DialogContent dir="rtl">
<DialogHeader>
<DialogTitle>העלאת יומון &quot;כל יום&quot;</DialogTitle>
<DialogDescription>
סיכום-עמוד של פסק דין. המערכת תחלץ אוטומטית את תג-המושג, ההלכה, ומראה-המקום
של הפסק המקורי. היומון משמש כ-radar בלבד אינו מצוטט בהחלטה.
</DialogDescription>
</DialogHeader>
<form onSubmit={onSubmit} className="space-y-4">
<div>
<Label htmlFor="digest-file">קובץ יומון (PDF)</Label>
<Input
id="digest-file"
type="file"
accept=".pdf,.docx,.doc,.rtf,.txt,.md"
onChange={(e) => setFile(e.target.files?.[0] ?? null)}
/>
</div>
<div className="grid grid-cols-2 gap-3">
<div>
<Label htmlFor="digest-num">מספר יומון (אופציונלי)</Label>
<Input
id="digest-num"
value={yomonNumber}
onChange={(e) => setYomonNumber(e.target.value)}
placeholder="5163"
dir="ltr"
/>
</div>
<div>
<Label htmlFor="digest-date">תאריך גיליון (אופציונלי)</Label>
<Input
id="digest-date"
type="date"
value={digestDate}
onChange={(e) => setDigestDate(e.target.value)}
/>
</div>
</div>
<div>
<Label>תחום (אופציונלי יחולץ אם ריק)</Label>
<Select
value={practiceArea || "_auto"}
onValueChange={(v) => setPracticeArea(v === "_auto" ? "" : (v as PracticeArea))}
>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="_auto">חילוץ אוטומטי</SelectItem>
{PRACTICE_AREAS.map((a) => (
<SelectItem key={a.value} value={a.value}>
{a.label}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
<DialogFooter>
<Button
type="submit"
disabled={upload.isPending}
className="bg-gold text-white hover:bg-gold-deep border-transparent"
>
{upload.isPending ? "מעלה…" : "העלה"}
</Button>
</DialogFooter>
</form>
</DialogContent>
</Dialog>
);
}