Make subcategory optional, source category picker from real tenant data

Matches the backend: subcategory is no longer a required field in the
import modal (defaults to none/0 instead of blocking submission), and
the Category dropdown now comes from GET gettenantcategories (what
this tenant's own products actually use) instead of the global
categories list, which was missing categoryid 2 despite it being the
category tenant 1135 actually needs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Suriya
2026-07-16 18:19:41 +05:30
parent 32291cddbe
commit 186546f1fe
3 changed files with 33 additions and 13 deletions

View File

@@ -122,3 +122,18 @@ export async function getProductSubcategories(tenantid: number, categoryid?: num
const { items } = await apiGet<{ subcategoryid: number; subcategoryname: string }>(url);
return items;
}
export interface TenantCategory {
categoryid: number;
categoryname: string;
}
// Categories this tenant's own products actually use — not the global
// productcategories list, which is missing categoryids that are nonetheless
// in real use (e.g. categoryid 2), which would make the picker unusable.
export async function getTenantCategories(tenantid: number) {
const url = new URL(`${API_BASE}/products/gettenantcategories`);
url.searchParams.set("tenantid", String(tenantid));
const { items } = await apiGet<TenantCategory>(url);
return items;
}