Files
admin-web/src/modules/overseas-warehouse/smartDispatchWarehouseTab.ts
T

17 lines
628 B
TypeScript
Raw Normal View History

2026-10-19 17:56:31 +08:00
import type { Candidate } from './dispatchContracts'
2026-09-18 11:41:27 +08:00
export type SmartDispatchWarehouseTab = 'ALL' | 'LAX' | 'NYC'
export function matchesSmartDispatchWarehouseTab(
2026-10-19 17:56:31 +08:00
candidate: Pick<Candidate, 'warehouseCode' | 'warehouseName'>,
2026-09-18 11:41:27 +08:00
tab: SmartDispatchWarehouseTab,
) {
if (tab === 'ALL') return true
2026-10-19 17:56:31 +08:00
const warehouse = [candidate.warehouseCode, candidate.warehouseName]
2026-09-18 11:41:27 +08:00
.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)
}