Files
admin-web/src/modules/overseas-warehouse/smartDispatchWarehouseTab.ts
T
2026-09-18 11:41:27 +08:00

17 lines
691 B
TypeScript

import type { DispatchPalletCandidateDto } from './api/dispatches'
export type SmartDispatchWarehouseTab = 'ALL' | 'LAX' | 'NYC'
export function matchesSmartDispatchWarehouseTab(
candidate: Pick<DispatchPalletCandidateDto, 'overseasWarehouseCode' | 'overseasWarehouseName'>,
tab: SmartDispatchWarehouseTab,
) {
if (tab === 'ALL') return true
const warehouse = [candidate.overseasWarehouseCode, candidate.overseasWarehouseName]
.map((value) => String(value || '').trim().toLowerCase())
.filter(Boolean)
.join(' ')
if (tab === 'LAX') return /lax|洛杉矶|los angeles/.test(warehouse)
return /nyc|jfk|(?:^|[^a-z])ny(?:[^a-z]|$)|纽约|new[ -]?york/.test(warehouse)
}