mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 00:38:11 +00:00
refactor(train-scheduling): rename and restructure container movement logic
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user