优化
This commit is contained in:
@@ -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,
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user