"use client"; import { use, useState } from "react"; import Link from "next/link"; import { Pencil, Check, X } from "lucide-react"; import { toast } from "sonner"; import { AppShell } from "@/components/app-shell"; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Skeleton } from "@/components/ui/skeleton"; import { Textarea } from "@/components/ui/textarea"; import { usePrecedent, useUpdatePrecedent, type Precedent, } from "@/lib/api/precedent-library"; import { PrecedentEditSheet } from "@/components/precedents/precedent-edit-sheet"; import { FormattedCitation, CitationCopyButton, } from "@/components/precedents/formatted-citation"; import { ExtractedHalachotSection } from "@/components/precedents/extracted-halachot"; import { RelatedCasesSection } from "@/components/precedents/link-related-dialog"; const PRACTICE_AREA_LABELS: Record = { rishuy_uvniya: "רישוי ובנייה", betterment_levy: "היטל השבחה", compensation_197: "פיצויים (197)", }; const SOURCE_TYPE_LABELS: Record = { court_ruling: "פסק דין", appeals_committee: "ועדת ערר", }; /* Next 16 breaking change: route params are now a Promise. * The `use()` hook unwraps them inside a client component. */ export default function PrecedentDetailPage({ params, }: { params: Promise<{ id: string }>; }) { const { id } = use(params); const [editing, setEditing] = useState(false); const { data, isPending, error } = usePrecedent(id); const update = useUpdatePrecedent(); const [editingCitation, setEditingCitation] = useState(false); const [citationDraft, setCitationDraft] = useState(""); return (
{error ? (

שגיאה בטעינת הפסיקה

{error.message}

) : isPending || !data ? (
{[...Array(5)].map((_, i) => )}
) : ( <>

{data.case_name || "—"}

{data.case_number}
{/* Citation per Israeli unified citation rules. The LLM extractor composes this from the document; the chair can override below. */} { setCitationDraft(data.citation_formatted ?? ""); setEditingCitation(true); }} onCancel={() => setEditingCitation(false)} onChange={setCitationDraft} onSave={async () => { try { await update.mutateAsync({ id, patch: { citation_formatted: citationDraft.trim() }, }); toast.success("מראה מקום עודכן"); setEditingCitation(false); } catch (e) { toast.error( e instanceof Error ? e.message : "שמירה נכשלה", ); } }} saving={update.isPending} />
{data.practice_area ? ( {PRACTICE_AREA_LABELS[data.practice_area] ?? data.practice_area} ) : null} {data.source_type ? ( {SOURCE_TYPE_LABELS[data.source_type] ?? data.source_type} ) : null} {data.precedent_level ? ( {data.precedent_level} ) : null} {data.is_binding ? ( הלכה מחייבת ) : null} {data.court ? ( {data.court} ) : null} {data.date ? ( {data.date.slice(0, 10)} ) : null}
{data.headnote ? (

Headnote

{data.headnote}

) : null} {data.summary ? (

תקציר

{data.summary}

) : null} {(data as { key_quote?: string }).key_quote ? (

ציטוט מרכזי

{(data as { key_quote?: string }).key_quote}
) : null} {data.subject_tags?.length ? (
{data.subject_tags.map((t) => ( {t} ))}
) : null}
)} setEditing(open)} />
); } function CitationBlock({ precedent, editing, draft, onStartEdit, onCancel, onChange, onSave, saving, }: { precedent: Precedent; editing: boolean; draft: string; onStartEdit: () => void; onCancel: () => void; onChange: (v: string) => void; onSave: () => void; saving: boolean; }) { const citation = (precedent.citation_formatted ?? "").trim(); if (editing) { return (
עריכת מראה מקום הקף את שמות הצדדים בכפול-כוכבית **שם** להדגשה