Files
admin-web/src/shared/domain/containerSpecifications.ts
T

24 lines
1.1 KiB
TypeScript
Raw Normal View History

2026-08-17 12:31:27 +08:00
export const CONTAINER_SPECIFICATIONS = [
{ type: '20GP', capacityCbm: 33, maxWeightKg: 28000 },
{ type: '40GP', capacityCbm: 67, maxWeightKg: 28000 },
{ type: '40HC', capacityCbm: 76, maxWeightKg: 28000 },
{ type: '40NR', capacityCbm: 67, maxWeightKg: 28000 },
{ type: '45HC', capacityCbm: 86, maxWeightKg: 28000 },
] as const
export type ContainerSpecification = (typeof CONTAINER_SPECIFICATIONS)[number]
export function containerSpecification(containerType: string | null | undefined): ContainerSpecification | null {
const normalized = String(containerType || '').trim().toUpperCase()
return CONTAINER_SPECIFICATIONS.find((item) => item.type === normalized) || null
}
export function applyContainerSpecification<T extends { containerType: string; capacityCbm: number | null; maxWeightKg: number | null }>(target: T, containerType: string) {
const specification = containerSpecification(containerType)
if (!specification) return false
target.containerType = specification.type
target.capacityCbm = specification.capacityCbm
target.maxWeightKg = specification.maxWeightKg
return true
}