Merge pull request 'feat(halacha-queue): panel deliberation + search on rejected/approved tabs' (#303) from worktree-halacha-restore-panel-search into main
This commit was merged in pull request #303.
This commit is contained in:
@@ -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 (
|
||||
const body = error ? (
|
||||
<div className="rounded bg-danger-bg border border-danger/40 px-6 py-5 text-danger text-center">
|
||||
{error.message}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (isPending) {
|
||||
return (
|
||||
) : isPending ? (
|
||||
<div className="space-y-3">
|
||||
{[...Array(3)].map((_, i) => <Skeleton key={i} className="h-24 w-full" />)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!groups.length) {
|
||||
return (
|
||||
) : !groups.length ? (
|
||||
<div className="text-center text-ink-muted py-16">
|
||||
<p className="text-lg">אין הלכות בסטטוס זה.</p>
|
||||
<p className="text-lg">{searching ? "אין התאמות לחיפוש." : "אין הלכות בסטטוס זה."}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
) : (
|
||||
<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) ───────────────────────────────────
|
||||
|
||||
@@ -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",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user