17 lines
628 B
TypeScript
17 lines
628 B
TypeScript
import type { Candidate } from './dispatchContracts'
|
|
|
|
export type SmartDispatchWarehouseTab = 'ALL' | 'LAX' | 'NYC'
|
|
|
|
export function matchesSmartDispatchWarehouseTab(
|
|
candidate: Pick<Candidate, 'warehouseCode' | 'warehouseName'>,
|
|
tab: SmartDispatchWarehouseTab,
|
|
) {
|
|
if (tab === 'ALL') return true
|
|
const warehouse = [candidate.warehouseCode, candidate.warehouseName]
|
|
.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)
|
|
}
|