feat(halacha-queue): show panel deliberation + add search on rejected/approved tabs
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 4s
Lint — undefined names / undefined-names (pull_request) Successful in 11s

The 3-judge panel deliberation was only surfaced in the pending queue; the
'rejected'/'approved' tabs hid WHY an item was auto-rejected/approved even
though the data is captured (reviewer='panel:... maj-not-entailed'). And those
tabs had no way to locate a specific item.

- useHalachotByStatus now requests include_panel_round=true and accepts a
  server-side search term (same /api/halachot params the pending queue uses).
- HalachaRestoreCard renders the existing PanelDeliberation component when a
  round exists — same card the chair already sees in pending.
- RestorePanel gains the same locate-bar (debounced, server-side search) +
  a match-count indicator; the bar stays visible on empty/loading so a search
  is always clearable.

Reuses already-approved UI (deliberation = Design card 18, locate-bar = card
19); composition onto a sibling surface, approved directly by chaim. tsc +
eslint clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-19 10:24:54 +00:00
parent f9ef664ac9
commit 8c455d6ef6
2 changed files with 86 additions and 32 deletions

View File

@@ -614,6 +614,8 @@ function HalachaRestoreCard({
))}
</div>
{h.panel_round && <PanelDeliberation round={h.panel_round} />}
<div className="flex items-center gap-2 justify-end pt-1 border-t border-rule-soft">
<Button size="sm" variant="ghost"
onClick={secondaryAction}
@@ -708,7 +710,14 @@ function RestorePanel({
secondaryLabel: string;
getSecondaryStatus: () => "approved" | "rejected" | "pending_review";
}) {
const { data, isPending, error } = useHalachotByStatus(status);
const [searchInput, setSearchInput] = useState("");
const [search, setSearch] = useState("");
useEffect(() => {
const t = setTimeout(() => setSearch(searchInput.trim()), 300);
return () => clearTimeout(t);
}, [searchInput]);
const { data, isPending, error } = useHalachotByStatus(status, { search });
const update = useUpdateHalacha();
const [expandedIds, setExpandedIds] = useState<Set<string>>(new Set());
@@ -716,6 +725,8 @@ function RestorePanel({
() => buildGroups(data?.items ?? []),
[data],
);
const searching = search.length > 0;
const matchCount = data?.count ?? 0;
const restore = async (h: Halacha, newStatus: "approved" | "rejected" | "pending_review") => {
try {
@@ -735,31 +746,19 @@ function RestorePanel({
});
};
if (error) {
return (
<div className="rounded bg-danger-bg border border-danger/40 px-6 py-5 text-danger text-center">
{error.message}
</div>
);
}
if (isPending) {
return (
<div className="space-y-3">
{[...Array(3)].map((_, i) => <Skeleton key={i} className="h-24 w-full" />)}
</div>
);
}
if (!groups.length) {
return (
<div className="text-center text-ink-muted py-16">
<p className="text-lg">אין הלכות בסטטוס זה.</p>
</div>
);
}
return (
const body = error ? (
<div className="rounded bg-danger-bg border border-danger/40 px-6 py-5 text-danger text-center">
{error.message}
</div>
) : isPending ? (
<div className="space-y-3">
{[...Array(3)].map((_, i) => <Skeleton key={i} className="h-24 w-full" />)}
</div>
) : !groups.length ? (
<div className="text-center text-ink-muted py-16">
<p className="text-lg">{searching ? "אין התאמות לחיפוש." : "אין הלכות בסטטוס זה."}</p>
</div>
) : (
<div className="space-y-3">
{groups.map((g) => {
const isOpen = expandedIds.has(g.caseLawId);
@@ -813,6 +812,54 @@ function RestorePanel({
})}
</div>
);
return (
<div className="space-y-4">
{/* Locate bar — reach any item in this status, 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>
{searching && !isPending && !error && (
<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">
· {matchCount} {matchCount === 1 ? "התאמה" : "התאמות"}
</span>
<button
type="button"
onClick={() => setSearchInput("")}
className="ms-auto text-gold-deep font-semibold text-[0.8rem] underline hover:no-underline"
>
נקה חיפוש
</button>
</div>
)}
{body}
</div>
);
}
// ─── Pending queue panel (main review flow) ───────────────────────────────────

View File

@@ -668,14 +668,21 @@ export function isExtractionFixItem(h: Halacha): boolean {
);
}
export function useHalachotByStatus(status: string, limit = 300) {
export function useHalachotByStatus(
status: string,
opts: { limit?: number; search?: string } = {},
) {
const { limit = 300, search = "" } = opts;
const term = search.trim();
// include_panel_round surfaces the 3-judge deliberation on these tabs too
// (same card as the pending queue), so the chair sees WHY an item was
// auto-rejected/approved; search locates an item server-side beyond the window.
const qs = `review_status=${encodeURIComponent(status)}&include_panel_round=true&limit=${limit}`
+ (term ? `&search=${encodeURIComponent(term)}` : "");
return useQuery({
queryKey: libraryKeys.halachot({ review_status: status, limit: String(limit) }),
queryKey: libraryKeys.halachot({ review_status: status, limit: String(limit), search: term }),
queryFn: ({ signal }) =>
apiRequest<{ items: Halacha[]; count: number }>(
`/api/halachot?review_status=${encodeURIComponent(status)}&limit=${limit}`,
{ signal },
),
apiRequest<{ items: Halacha[]; count: number }>(`/api/halachot?${qs}`, { signal }),
staleTime: 10_000,
refetchOnMount: "always",
});