Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
6faff88438
commit
e6c16af364
@@ -35,11 +35,25 @@ function ClientsList() {
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
const load = async () => {
|
||||
const [{ data: cli }, { data: usr }] = await Promise.all([
|
||||
supabase.from("clients").select("*").order("name", { ascending: true }),
|
||||
supabase.from("profiles").select("id, full_name, email").order("full_name", { ascending: true }),
|
||||
]);
|
||||
setClients(cli ?? []);
|
||||
// Page through clients so we never silently hit Supabase's 1000-row cap.
|
||||
const pageSize = 1000;
|
||||
const all: any[] = [];
|
||||
for (let from = 0; ; from += pageSize) {
|
||||
const { data, error } = await supabase
|
||||
.from("clients")
|
||||
.select("*")
|
||||
.order("name", { ascending: true })
|
||||
.range(from, from + pageSize - 1);
|
||||
if (error) { toast.error(error.message); break; }
|
||||
const batch = data ?? [];
|
||||
all.push(...batch);
|
||||
if (batch.length < pageSize) break;
|
||||
}
|
||||
const { data: usr } = await supabase
|
||||
.from("profiles")
|
||||
.select("id, full_name, email")
|
||||
.order("full_name", { ascending: true });
|
||||
setClients(all);
|
||||
setUsers(usr ?? []);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user