mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 12:30:58 +00:00
feat: implement 20ft container weight-pairing validation
- Added ContainerValidationService to handle 20ft weight-pairing logic. - Introduced validate20ftWeightPairing utility function to check weight differences. - Updated BookingPricingService to include overweight line details and pairing errors in price response. - Enhanced BookingTransitionService to reject submissions with unpairable 20ft containers. - Created ShipmentValidation interface for pre-submit validation of container contracts. - Integrated shipment validation into the contract booking process, providing warnings for overweight containers and hard blocks for pairing errors. - Updated front-end components to display validation results and prevent submission when errors are present.
This commit is contained in:
@@ -73,6 +73,38 @@ export function getPermissionKeys(user: AuthUser | null | undefined): string[] {
|
||||
return [...keys];
|
||||
}
|
||||
|
||||
/** Position keys held by the user (e.g. "ethiopian_gl", "djibouti_gl"). */
|
||||
export function getPositionKeys(user: AuthUser | null | undefined): string[] {
|
||||
if (!user) return [];
|
||||
const keys = new Set<string>();
|
||||
for (const emp of user.employee ?? []) {
|
||||
for (const pos of emp.positions ?? []) {
|
||||
if (pos.key) keys.add(pos.key);
|
||||
}
|
||||
}
|
||||
return [...keys];
|
||||
}
|
||||
|
||||
export function hasPosition(
|
||||
user: AuthUser | null | undefined,
|
||||
positionKey: string,
|
||||
): boolean {
|
||||
return getPositionKeys(user).includes(positionKey);
|
||||
}
|
||||
|
||||
export const POSITION_KEYS = {
|
||||
ethiopianGl: "ethiopian_gl",
|
||||
djiboutiGl: "djibouti_gl",
|
||||
} as const;
|
||||
|
||||
export function isEthiopianGl(user: AuthUser | null | undefined): boolean {
|
||||
return hasPosition(user, POSITION_KEYS.ethiopianGl);
|
||||
}
|
||||
|
||||
export function isDjiboutiGl(user: AuthUser | null | undefined): boolean {
|
||||
return hasPosition(user, POSITION_KEYS.djiboutiGl);
|
||||
}
|
||||
|
||||
export function isSuperAdmin(user: AuthUser | null | undefined): boolean {
|
||||
if (user?.isSuperAdmin) return true;
|
||||
return Boolean(user?.roles?.some((r) => r.key === "super_admin"));
|
||||
|
||||
Reference in New Issue
Block a user