"use client";
import { useEffect, useState } from "react";
import Link from "next/link";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { AppShell } from "@/components/app-shell";
import { LibraryListPanel } from "@/components/precedents/library-list-panel";
import { LibrarySearchPanel } from "@/components/precedents/library-search-panel";
import { HalachaReviewPanel } from "@/components/precedents/halacha-review-panel";
import { PlansReviewPanel } from "@/components/precedents/plans-review-panel";
import { LibraryStatsPanel } from "@/components/precedents/library-stats-panel";
import { useMissingPrecedents } from "@/lib/api/missing-precedents";
/**
* Precedent Library admin page.
*
* Four tabs:
* - ספרייה — browse all uploaded precedents (filters + upload + delete)
* - חיפוש סמנטי — semantic search across halachot + chunks
* - ממתין לאישור — chair review queue (PRIMARY tab; halachot from
* auto-extraction must be approved before agents can use them)
* - סטטיסטיקה — counts and coverage
*
* Distinct from /training (style corpus = Daphna's voice) and the
* per-case precedent attacher (chair-attached quotes scoped to a case).
*/
const PRECEDENT_TABS = new Set(["library", "search", "review", "plans", "incoming", "stats"]);
export default function PrecedentsPage() {
// Controlled so a deep link like /precedents?tab=review (e.g. from a pending
// halacha on a precedent-detail page, #133) lands on the right tab. Read after
// mount to avoid an SSR/CSR mismatch and the useSearchParams Suspense rule.
const [tab, setTab] = useState("library");
useEffect(() => {
// read post-mount (not lazy init) to avoid an SSR/CSR hydration mismatch
const t = new URLSearchParams(window.location.search).get("tab");
// eslint-disable-next-line react-hooks/set-state-in-effect
if (t && PRECEDENT_TABS.has(t)) setTab(t);
}, []);
return (
קורפוס הפסיקה והלכות המערכת — חיפוש סמנטי, תור-אישור והשלמת
פסיקה חסרה. כל קובץ עובר חילוץ הלכות אוטומטי, וההלכות ממתינות
לאישור היו"ר לפני שהן זמינות לסוכני הכתיבה.
ספריית הפסיקה הסמכותית
פסיקה שצוטטה בכתבי-הטענות אך אינה קיימת בקורפוס. השלמתה מאפשרת אימות-הלכה ועיגון-מקור (INV-AH).
לניהול פסיקה חסרה ←