"use client"; import { use } from "react"; import Link from "next/link"; import { AppShell } from "@/components/app-shell"; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Skeleton } from "@/components/ui/skeleton"; import { SubsectionCard } from "@/components/compose/subsection-card"; import { PrecedentsSection } from "@/components/compose/precedents-section"; import { useCase } from "@/lib/api/cases"; import { useResearchAnalysis } from "@/lib/api/research"; import { useCasePrecedents } from "@/lib/api/precedents"; function ProseSection({ title, content }: { title: string; content?: string }) { if (!content?.trim()) return null; return (

{title}

{content.trim()}

); } export default function ComposePage({ params, }: { params: Promise<{ caseNumber: string }>; }) { const { caseNumber } = use(params); const caseQuery = useCase(caseNumber); const analysis = useResearchAnalysis(caseNumber); const precedentsQuery = useCasePrecedents(caseNumber); /* Partition the flat list into scopes so each child renders its own slice * without re-fetching. Done once at the page level. */ const allPrecedents = precedentsQuery.data ?? []; const caseLevelPrecedents = allPrecedents.filter((p) => p.section_id === null); const precedentsBySection = new Map(); for (const p of allPrecedents) { if (p.section_id) { const existing = precedentsBySection.get(p.section_id) ?? []; existing.push(p); precedentsBySection.set(p.section_id, existing); } } const practiceArea = caseQuery.data?.practice_area ?? null; const isNotFound = analysis.error instanceof Error && /404|לא נמצא|טרם בוצע/.test(analysis.error.message); return (
{/* Header strip */}

ניתוח משפטי וכתיבת עמדה

{caseQuery.data?.title && (

{caseQuery.data.title}

)}
{analysis.isPending ? ( ) : isNotFound ? (

טרם בוצע ניתוח משפטי לתיק זה

לאחר שקובץ analysis-and-research.md ייווצר, תוכלי לערוך כאן את עמדת הוועדה לכל טענת סף וסוגיה.

) : analysis.error ? (

{analysis.error.message}

) : analysis.data ? (
{/* Case-level general precedents */}

פסיקה כללית לדיון

ציטוטים התומכים בעמדה באופן רוחבי — ישולבו בפתיחת בלוק י (דיון).

{/* Threshold claims */} {analysis.data.threshold_claims && analysis.data.threshold_claims.length > 0 && (

טענות סף

{analysis.data.threshold_claims.length}
{analysis.data.threshold_claims.map((tc) => ( ))}
)} {/* Issues */} {analysis.data.issues && analysis.data.issues.length > 0 && (

סוגיות להכרעה

{analysis.data.issues.length}
{analysis.data.issues.map((iss) => ( ))}
)} {(!analysis.data.threshold_claims?.length && !analysis.data.issues?.length) && ( לא נמצאו טענות סף או סוגיות בניתוח זה. )} {/* Background prose — moved below the issues so it reads as supporting context after the chair has seen the main decision points, not as a wall of text beside them. */}

רקע לניתוח

{analysis.data.conclusions?.trim() && (

מסקנות

{analysis.data.conclusions.trim()}

)}
) : null}
); }