diff --git a/src/routes/cases.index.tsx b/src/routes/cases.index.tsx index 064460d..88f2554 100644 --- a/src/routes/cases.index.tsx +++ b/src/routes/cases.index.tsx @@ -173,17 +173,28 @@ function CasesList() { if (selected.size === 0) return; setBusy(true); const ids = Array.from(selected); - const { error } = await supabase + const { data, error } = await supabase .from("cases") .update({ archived_at: archived ? new Date().toISOString() : null }) - .in("id", ids); + .in("id", ids) + .select("id"); setBusy(false); - if (error) toast.error(error.message); - else { - toast.success(`${ids.length} case(s) ${archived ? "archived" : "restored"}`); - setSelected(new Set()); - load(); + if (error) { + toast.error(error.message); + return; } + const updatedCount = data?.length ?? 0; + if (updatedCount === 0) { + toast.error("No cases were updated. You may not have permission."); + return; + } + if (updatedCount < ids.length) { + toast.warning(`${updatedCount} of ${ids.length} case(s) ${archived ? "archived" : "restored"} (others skipped due to permissions)`); + } else { + toast.success(`${updatedCount} case(s) ${archived ? "archived" : "restored"}`); + } + setSelected(new Set()); + load(); }; const bulkAssignAttorney = async () => {