This commit is contained in:
2026-08-19 09:42:12 +08:00
parent 80cfca5056
commit 0cd13f0b4d
18 changed files with 86 additions and 50 deletions
@@ -54,7 +54,9 @@ export interface InboundFeeSupplierOption { id: string; supplierName: string; ca
const supplierCategories: SupplierCategory[] = ['BOOKING', 'CUSTOMS', 'TRUCKING', 'CERTIFICATE']
function supplierCategory(value: unknown): SupplierCategory | null {
return supplierCategories.includes(value as SupplierCategory) ? value as SupplierCategory : null
if (value == null || value === '') return null
if (supplierCategories.includes(value as SupplierCategory)) return value as SupplierCategory
throw new TypeError(`Unsupported supplierCategory: ${String(value)}`)
}
function basePath(inboundId: string) {
@@ -115,9 +117,9 @@ export async function listInboundFeeItemOptions() {
}))
}
export async function listInboundFeeSupplierOptions(category: SupplierCategory) {
const page = await listSuppliers({ status: 'ACTIVE', category, page: 1, size: 200 })
return page.records.filter((supplier) => supplier.status === 'ACTIVE' && supplier.category === category).map((supplier): InboundFeeSupplierOption => ({
export async function listInboundFeeSupplierOptions(category: SupplierCategory | null) {
const page = await listSuppliers({ status: 'ACTIVE', category: category ?? undefined, page: 1, size: 200 })
return page.records.filter((supplier) => supplier.status === 'ACTIVE' && (!category || supplier.category === category)).map((supplier): InboundFeeSupplierOption => ({
id: supplier.id, supplierName: supplier.name, category: supplier.category,
}))
}