refactor(train-scheduling): rename and restructure container movement logic

This commit is contained in:
Marshal
2026-07-21 23:49:10 +00:00
parent d25612c2f0
commit ed3c8307bb
13 changed files with 470 additions and 523 deletions

View File

@@ -353,12 +353,38 @@ export const POSITION_KEYS = {
djiboutiGl: "djibouti_gl",
} as const;
/** Position-type keys held by the user (e.g. "djibouti-gl-officer"). */
export function getPositionTypeKeys(
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.positionType?.key) keys.add(pos.positionType.key);
}
}
return [...keys];
}
// GL staff are identified by the root position key (department heads) OR by
// their position-type key (sub-positions: director/chief/officer) — both
// forms get the clearance-only locked view.
const ET_GL_TYPE_PREFIX = "commercial-global-logistics-(et)";
const DJ_GL_TYPE_PREFIX = "djibouti-gl";
export function isEthiopianGl(user: AuthUser | null | undefined): boolean {
return hasPosition(user, POSITION_KEYS.ethiopianGl);
return (
hasPosition(user, POSITION_KEYS.ethiopianGl) ||
getPositionTypeKeys(user).some((k) => k.startsWith(ET_GL_TYPE_PREFIX))
);
}
export function isDjiboutiGl(user: AuthUser | null | undefined): boolean {
return hasPosition(user, POSITION_KEYS.djiboutiGl);
return (
hasPosition(user, POSITION_KEYS.djiboutiGl) ||
getPositionTypeKeys(user).some((k) => k.startsWith(DJ_GL_TYPE_PREFIX))
);
}
export function isSuperAdmin(user: AuthUser | null | undefined): boolean {