Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
061e2b8ab2
commit
6da74c4a88
+26
-16
@@ -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) => ({
|
||||
|
||||
Reference in New Issue
Block a user