mirror of
https://github.com/renee-png/acmcc.git
synced 2026-06-21 01:40:01 +00:00
Bill approvals: fix approver column always showing "None"
The list loaded all bills (~1,150) then fetched approvers with
.in("bill_id", [all ids]); that request URL exceeds server limits and
fails silently, so approvalsByBill was always empty. Fetch the small
bill_approvals table directly (RLS scopes per role) and group locally.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -216,15 +216,21 @@ export default function BillApprovalsPage({ boardAssociationIds }: { boardAssoci
|
|||||||
setAccounts(coaRes.data || []);
|
setAccounts(coaRes.data || []);
|
||||||
setVendors(vRes.data || []);
|
setVendors(vRes.data || []);
|
||||||
|
|
||||||
// Fetch approvals for all bills
|
// Fetch approvals for all bills.
|
||||||
|
// NOTE: do NOT filter with .in("bill_id", billIds) — with 1k+ bills the
|
||||||
|
// request URL exceeds server limits and silently fails, leaving every row
|
||||||
|
// showing no approvers. The bill_approvals table is small and RLS already
|
||||||
|
// scopes rows per role, so fetch it directly and group locally.
|
||||||
if (billsList.length > 0) {
|
if (billsList.length > 0) {
|
||||||
const billIds = billsList.map((b: any) => b.id);
|
const billIdSet = new Set(billsList.map((b: any) => b.id));
|
||||||
const { data: approvals } = await supabase
|
const { data: approvals, error: approvalsErr } = await supabase
|
||||||
.from("bill_approvals")
|
.from("bill_approvals")
|
||||||
.select("id, bill_id, approver_name, status")
|
.select("id, bill_id, approver_name, status")
|
||||||
.in("bill_id", billIds);
|
.not("bill_id", "is", null);
|
||||||
|
if (approvalsErr) console.error("Failed to load approvals:", approvalsErr);
|
||||||
const grouped: Record<string, any[]> = {};
|
const grouped: Record<string, any[]> = {};
|
||||||
(approvals || []).forEach((a: any) => {
|
(approvals || []).forEach((a: any) => {
|
||||||
|
if (!a.bill_id || !billIdSet.has(a.bill_id)) return;
|
||||||
if (!grouped[a.bill_id]) grouped[a.bill_id] = [];
|
if (!grouped[a.bill_id]) grouped[a.bill_id] = [];
|
||||||
grouped[a.bill_id].push(a);
|
grouped[a.bill_id].push(a);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user