From 6da74c4a884965cf485e44bef29baef38827c278 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 19 Apr 2026 17:28:38 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/routes/cases.index.tsx | 42 +++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/routes/cases.index.tsx b/src/routes/cases.index.tsx index 88f2554..423c392 100644 --- a/src/routes/cases.index.tsx +++ b/src/routes/cases.index.tsx @@ -201,30 +201,40 @@ function CasesList() { if (selected.size === 0 || !assignAttorney) return; setBusy(true); const ids = Array.from(selected); - const { error } = await supabase.from("cases").update({ assigned_attorney_id: assignAttorney }).in("id", ids); + const { data, error } = await supabase + .from("cases") + .update({ assigned_attorney_id: assignAttorney }) + .in("id", ids) + .select("id"); setBusy(false); - if (error) toast.error(error.message); - else { - toast.success(`${ids.length} case(s) reassigned`); - setSelected(new Set()); - setAssignAttorney(""); - load(); - } + if (error) { toast.error(error.message); return; } + const n = data?.length ?? 0; + if (n === 0) { toast.error("No cases were updated. You may not have permission."); return; } + if (n < ids.length) toast.warning(`${n} of ${ids.length} case(s) reassigned (others skipped)`); + else toast.success(`${n} case(s) reassigned`); + setSelected(new Set()); + setAssignAttorney(""); + load(); }; const bulkAssignClient = async () => { if (selected.size === 0 || !assignClient) return; setBusy(true); const ids = Array.from(selected); - const { error } = await supabase.from("cases").update({ client_id: assignClient }).in("id", ids); + const { data, error } = await supabase + .from("cases") + .update({ client_id: assignClient }) + .in("id", ids) + .select("id"); setBusy(false); - if (error) toast.error(error.message); - else { - toast.success(`${ids.length} case(s) re-linked to client`); - setSelected(new Set()); - setAssignClient(""); - load(); - } + if (error) { toast.error(error.message); return; } + const n = data?.length ?? 0; + if (n === 0) { toast.error("No cases were updated. You may not have permission."); return; } + if (n < ids.length) toast.warning(`${n} of ${ids.length} case(s) re-linked (others skipped)`); + else toast.success(`${n} case(s) re-linked to client`); + setSelected(new Set()); + setAssignClient(""); + load(); }; const userOptions = users.map((u) => ({