feat(halachot): חיפוש/איתור בתור-ההלכות + הערת חלון-תצוגה (פסיקה מחוץ ל-500 נגישה)
תור-ההלכות שלף רק 500 ממתינות בעלות-עדיפות מתוך ~1,372, בלי שום דרך לאתר פס"ד מסוים. הלכה מדורגת מתחת לחלון (למשל 1180-11-25, מקומות 921/1305) פשוט נעלמה — הספירה בספרייה הציגה "2 ממתינות" אך התור לא הראה אותן. - list_halachot: פרמטר search (case_number/case_name/rule_statement, ILIKE) — סינון בצד-השרת כך שפריט מתחת לחלון נשאר נגיש. מרחיב את מסלול-השליפה היחיד, לא יוצר מסלול מקביל (G2). - count_halachot: ספירה מלאה לאותו פילטר (ל-"N מתוך TOTAL"). - /api/halachot: search + with_total (ברירת-מחדל off; קוראים קיימים לא מושפעים). - UI (תור-הלכות): שורת-חיפוש מהוקצבת (debounce 300ms), הערת "חלון התצוגה" (500 מתוך הסך), ושורת-הקשר-תוצאה עם ניקוי. בחיפוש — כל הקבוצות התואמות נפתחות; הניווט המקלדתי והשערים (G10) ללא שינוי. מאומת מול ה-DB: search='1180-11-25' → 2 הממתינות (index 20 נקייה→להכרעתך, index 23 nli_unsupported→דורש תיקון-חילוץ); count=2. עיצוב: עבר שער Claude Design (X17, כרטיס 19-halacha-queue-unified) ואושר. Invariants: מקיים G2 (מסלול-שליפה יחיד), INV-G10 (שער-יו"ר ללא שינוי), INV-IA (מקור-אמת יחיד לתור). ללא בליעת-שגיאות. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useMemo, useState, type ReactNode } from "react";
|
||||
import { Check, X, Edit2, ChevronDown, ChevronLeft, AlertTriangle, Clock, RotateCcw, Info } from "lucide-react";
|
||||
import { Check, X, Edit2, ChevronDown, ChevronLeft, AlertTriangle, Clock, RotateCcw, Info, Search } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
@@ -669,13 +669,25 @@ function PendingPanel() {
|
||||
// "judgment" = items the panel deliberated (or clean) → chair approves/rejects;
|
||||
// "fix" = flagged-but-never-adjudicated → extraction repair. (No empty "תור נקי".)
|
||||
const [view, setView] = useState<"judgment" | "fix">("judgment");
|
||||
const { data, isPending, error } = useHalachotPending({ limit: 500 });
|
||||
// Locate a pending halacha by decision/text — server-side, so an item ranked
|
||||
// below the 500-item display window is still reachable (the chair's core ask).
|
||||
const [searchInput, setSearchInput] = useState("");
|
||||
const [search, setSearch] = useState("");
|
||||
useEffect(() => {
|
||||
const t = setTimeout(() => setSearch(searchInput.trim()), 300);
|
||||
return () => clearTimeout(t);
|
||||
}, [searchInput]);
|
||||
const searching = search.length > 0;
|
||||
|
||||
const { data, isPending, error } = useHalachotPending({ limit: 500, search });
|
||||
const update = useUpdateHalacha();
|
||||
const batch = useBatchReviewHalachot();
|
||||
const [expandedIds, setExpandedIds] = useState<Set<string>>(new Set());
|
||||
const [focusedId, setFocusedId] = useState<string | null>(null);
|
||||
|
||||
const allItems = useMemo(() => data?.items ?? [], [data]);
|
||||
// Full pending count for this filter (incl. items beyond the display window).
|
||||
const pendingTotal = data?.total ?? allItems.length;
|
||||
const judgmentCount = useMemo(
|
||||
() => allItems.filter((h) => !isExtractionFixItem(h)).length, [allItems]);
|
||||
const fixCount = useMemo(
|
||||
@@ -692,10 +704,11 @@ function PendingPanel() {
|
||||
const visibleItems = useMemo<ReviewItem[]>(() => {
|
||||
const out: ReviewItem[] = [];
|
||||
for (const g of groups) {
|
||||
if (expandedIds.has(g.caseLawId)) out.push(...g.items);
|
||||
// a search narrows to a handful of cases — show them all open
|
||||
if (searching || expandedIds.has(g.caseLawId)) out.push(...g.items);
|
||||
}
|
||||
return out;
|
||||
}, [groups, expandedIds]);
|
||||
}, [groups, expandedIds, searching]);
|
||||
|
||||
useEffect(() => {
|
||||
if (focusedId === null) return;
|
||||
@@ -846,7 +859,16 @@ function PendingPanel() {
|
||||
</div>
|
||||
);
|
||||
} else if (!groups.length) {
|
||||
body = (
|
||||
body = searching ? (
|
||||
<div className="text-center text-ink-muted py-16">
|
||||
<p className="text-lg">לא נמצאו הלכות ממתינות התואמות ל״{search}״.</p>
|
||||
<p className="text-sm mt-2">
|
||||
נסה מספר-פס״ד, שם-תיק או מילה מנוסח-ההלכה — או נקה את החיפוש.
|
||||
{view === "judgment" && fixCount > 0 && " ייתכן שההתאמות נמצאות ב״דורש תיקון-חילוץ״."}
|
||||
{view === "fix" && judgmentCount > 0 && " ייתכן שההתאמות נמצאות ב״להכרעתך״."}
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-center text-ink-muted py-16">
|
||||
<p className="text-lg">
|
||||
{view === "fix"
|
||||
@@ -888,7 +910,7 @@ function PendingPanel() {
|
||||
|
||||
<div className="space-y-3">
|
||||
{groups.map((g) => {
|
||||
const isOpen = expandedIds.has(g.caseLawId);
|
||||
const isOpen = searching || expandedIds.has(g.caseLawId);
|
||||
return (
|
||||
<div key={g.caseLawId} className="rounded-lg border border-rule bg-surface overflow-hidden">
|
||||
<button
|
||||
@@ -979,8 +1001,64 @@ function PendingPanel() {
|
||||
);
|
||||
}
|
||||
|
||||
const overWindow = !searching && pendingTotal > allItems.length;
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
{/* Locate bar — reach any pending halacha, not only the top window */}
|
||||
<div className="flex items-center gap-2.5 rounded-lg border border-rule bg-surface px-3.5 py-2.5 shadow-sm">
|
||||
<Search className="w-4 h-4 text-ink-muted shrink-0" />
|
||||
<input
|
||||
value={searchInput}
|
||||
onChange={(e) => setSearchInput(e.target.value)}
|
||||
placeholder="חיפוש בתור — מספר פס״ד, שם-תיק או נוסח-הלכה"
|
||||
dir="rtl"
|
||||
className="flex-1 bg-transparent border-0 outline-none text-sm text-ink placeholder:text-ink-muted"
|
||||
/>
|
||||
{searchInput && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setSearchInput("")}
|
||||
className="shrink-0 w-5 h-5 rounded-full bg-rule-soft text-ink-muted hover:text-navy
|
||||
flex items-center justify-center text-[0.7rem]"
|
||||
title="נקה"
|
||||
>
|
||||
<X className="w-3 h-3" />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{overWindow && (
|
||||
<p className="flex items-center gap-2 text-[0.78rem] text-ink-muted px-1 leading-relaxed">
|
||||
<span className="bg-info-bg text-info rounded-full px-2 py-0.5 font-semibold text-[0.72rem] shrink-0">
|
||||
חלון התצוגה
|
||||
</span>
|
||||
<span>
|
||||
התור מציג את <b className="text-navy">{allItems.length}</b> ההלכות בעלות-העדיפות מתוך{" "}
|
||||
<b className="text-navy">{pendingTotal}</b> הממתינות. הלכה מחוץ לחלון — אתר אותה בחיפוש.
|
||||
</span>
|
||||
</p>
|
||||
)}
|
||||
|
||||
{searching && (
|
||||
<div className="flex items-center gap-2 flex-wrap rounded-lg border border-gold/50 bg-gold-wash px-3.5 py-2.5 text-sm text-navy">
|
||||
<span>מציג ממתינות עבור</span>
|
||||
<span className="rounded bg-navy text-parchment text-[0.78rem] font-semibold px-2 py-0.5">
|
||||
{search}
|
||||
</span>
|
||||
<span className="text-ink-muted">
|
||||
· {pendingTotal} {pendingTotal === 1 ? "התאמה" : "התאמות"}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setSearchInput("")}
|
||||
className="ms-auto text-gold-deep font-semibold text-[0.8rem] underline hover:no-underline"
|
||||
>
|
||||
נקה חיפוש · חזרה לכל התור
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{viewToggle}
|
||||
{body}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user