"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() { const [open, setOpen] = useState(false); const [file, setFile] = useState(null); const [yomonNumber, setYomonNumber] = useState(""); const [digestDate, setDigestDate] = useState(""); const [practiceArea, setPracticeArea] = useState(""); 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 ( העלאת יומון "כל יום" סיכום-עמוד של פסק דין. המערכת תחלץ אוטומטית את תג-המושג, ההלכה, ומראה-המקום של הפסק המקורי. היומון משמש כ-radar בלבד — אינו מצוטט בהחלטה.
setFile(e.target.files?.[0] ?? null)} />
setYomonNumber(e.target.value)} placeholder="5163" dir="ltr" />
setDigestDate(e.target.value)} />
); }