mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-09 10:58:14 +00:00
update joins in repository services to use entity classes and enhance booking form with hazardous/reefer toggles
This commit is contained in:
@@ -73,15 +73,23 @@ export function getPermissionKeys(user: AuthUser | null | undefined): string[] {
|
||||
return [...keys];
|
||||
}
|
||||
|
||||
/** Position keys held by the user (e.g. "ethiopian_gl", "djibouti_gl"). */
|
||||
/**
|
||||
* Position keys held by the user (e.g. "ethiopian_gl", "djibouti_gl").
|
||||
* Tolerates IAM payload shape variants: the key flat on the employee position,
|
||||
* nested under `position.key`, or the GL modeled as a role instead.
|
||||
*/
|
||||
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);
|
||||
if (pos.position?.key) keys.add(pos.position.key);
|
||||
}
|
||||
}
|
||||
for (const role of user.roles ?? []) {
|
||||
if (role.key) keys.add(role.key);
|
||||
}
|
||||
return [...keys];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user