filters
This commit is contained in:
@@ -52,15 +52,23 @@ export function ProductsPanel({
|
||||
const [publishing, setPublishing] = useState<Product[] | null>(null);
|
||||
|
||||
/**
|
||||
* One branch, always.
|
||||
* The branch in scope, or all of them.
|
||||
*
|
||||
* `getlocationproducts` takes a single `locationid` and there is no
|
||||
* tenant-wide product read. Under "All branches" this reads the first.
|
||||
* Publishing is tenant-wide regardless, so the choice affects what is
|
||||
* LISTED, not what is changed.
|
||||
* `current` is undefined under "All branches", and that now means what it
|
||||
* says: `getlocationproducts` answers a tenant-wide read with one row per
|
||||
* product and stock summed across outlets.
|
||||
*
|
||||
* It used to fall back to `scoped[0]` — the FIRST branch — so "All branches"
|
||||
* listed one outlet's products and called them the catalogue. A merchant with
|
||||
* five outlets saw four products instead of six, and picking a single branch
|
||||
* showed MORE than picking all of them.
|
||||
*
|
||||
* Publishing is tenant-wide regardless, so this affects what is LISTED, not
|
||||
* what is changed.
|
||||
*/
|
||||
const branch = current ?? scoped[0];
|
||||
const products = useLocationProducts(tenantid || undefined, branch?.locationid, 0);
|
||||
const products = useLocationProducts(tenantid || undefined, current?.locationid, 0, {
|
||||
allBranches: true,
|
||||
});
|
||||
const categories = useTenantCategories(tenantid || undefined);
|
||||
|
||||
/**
|
||||
@@ -123,7 +131,12 @@ export function ProductsPanel({
|
||||
{isUploading ? (
|
||||
<SheetUploadDrawer
|
||||
tenantid={tenantid || undefined}
|
||||
locationid={branch?.locationid}
|
||||
/* `current`, never a fallback to the first branch. An upload becomes
|
||||
opening stock on ONE shelf, so under "All branches" there is no
|
||||
answer to guess — passing nothing leaves the drawer's own branch
|
||||
picker to ask, and it blocks the upload until it is answered.
|
||||
Defaulting here would load a shelf nobody chose. */
|
||||
locationid={current?.locationid}
|
||||
onClose={onCloseUpload}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
Reference in New Issue
Block a user