"use client"; import { useState } from "react"; import { Link2, Trash2 } from "lucide-react"; import { toast } from "sonner"; import { Button } from "@/components/ui/button"; import { Skeleton } from "@/components/ui/skeleton"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { useDigests, useDeleteDigest, useRelinkDigest, type DigestListFilters, } from "@/lib/api/digests"; import type { PracticeArea } from "@/lib/api/precedent-library"; import { PRACTICE_AREAS } from "@/components/precedents/practice-area"; import { DigestCard } from "./digest-card"; import { DigestUploadDialog } from "./digest-upload-dialog"; type LinkedFilter = "all" | "linked" | "unlinked"; const PUBLICATIONS = [ { value: "_all", label: "כל המקורות" }, { value: "כל יום", label: "כל יום (יומי)" }, { value: 'עו"ד על נדל"ן', label: 'עו"ד על נדל"ן (חודשי)' }, ]; export function DigestListPanel() { const [practiceArea, setPracticeArea] = useState(""); const [linked, setLinked] = useState("all"); const [publication, setPublication] = useState("_all"); const filters: DigestListFilters = { practiceArea: practiceArea || undefined, linked: linked === "all" ? undefined : linked === "linked", publication: publication === "_all" ? undefined : publication, limit: 200, }; const { data, isLoading, error } = useDigests(filters); const del = useDeleteDigest(); const relink = useRelinkDigest(); const onRelink = (id: string) => relink.mutate(id, { onSuccess: (r) => r.linked ? toast.success("קושר לפסק המקורי") : toast.info("הפסק המקורי עדיין לא בקורפוס — העלה אותו לספריית הפסיקה"), onError: (e) => toast.error(e.message), }); const onDelete = (id: string) => { if (!confirm("למחוק את היומון מקורפוס-הגילוי?")) return; del.mutate(id, { onSuccess: () => toast.success("נמחק"), onError: (e) => toast.error(e.message), }); }; return (
{error ? (
{error.message}
) : isLoading ? (
{[...Array(3)].map((_, i) => )}
) : !data?.items.length ? (
אין יומונים עדיין. העלה יומון "כל יום", או הרץ scripts/ingest_digests_batch.py.
) : (

{data.count} יומונים

{data.items.map((d) => ( {!d.linked_case_law_id && ( )} } /> ))}
)}
); }