feat(site-scope): scope the supplier ledger, keep the list global
This commit is contained in:
parent
3cb34c5aad
commit
5edea14105
1 changed files with 6 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ import { notFound } from "next/navigation";
|
|||
import { pbAdmin } from "@/lib/pb";
|
||||
import { Topbar } from "@/components/layout/sidebar";
|
||||
import { EditSupplierButton } from "@/components/supplier-form-dialog";
|
||||
import { composeFilter, getSiteScope, siteFilter, type SearchParams } from "@/lib/site-scope";
|
||||
import { computeSupplierLedger } from "@/lib/supplier-ledger";
|
||||
import { SupplierDetailView, type SupplierPoRow } from "./supplier-detail-view";
|
||||
|
||||
|
|
@ -10,10 +11,14 @@ export const dynamic = "force-dynamic";
|
|||
|
||||
export default async function SupplierDetailPage({
|
||||
params,
|
||||
searchParams,
|
||||
}: {
|
||||
params: Promise<{ supplierId: string }>;
|
||||
searchParams: Promise<SearchParams>;
|
||||
}) {
|
||||
const { supplierId } = await params;
|
||||
const scope = await getSiteScope(await searchParams);
|
||||
const siteF = siteFilter(scope);
|
||||
const pb = await pbAdmin();
|
||||
|
||||
let supplier: { id: string; name: string };
|
||||
|
|
@ -25,7 +30,7 @@ export default async function SupplierDetailPage({
|
|||
|
||||
const [pos, items, deliveryLines] = await Promise.all([
|
||||
pb.collection("purchase_orders").getFullList({
|
||||
filter: `supplier_ref = "${supplierId}"`,
|
||||
filter: composeFilter(siteF, `supplier_ref = "${supplierId}"`),
|
||||
sort: "-date_uploaded",
|
||||
}),
|
||||
pb.collection("purchase_order_items").getFullList({
|
||||
|
|
|
|||
Loading…
Reference in a new issue