Production

This commit is contained in:
Shubhankar45
2026-09-22 06:23:46 +00:00
commit 8fdd20b29f
217 changed files with 31212 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
import type { AreaManagerMapping, Headquarters, User } from "../types";
/** Headquarters a person works in: an MR has one, an AM has any number, GM and Admin cover all. */
export function headquartersOf(user: User, hqs: Headquarters[], mappings: AreaManagerMapping[]): { all: boolean; items: Headquarters[] } {
if (user.role === "GM" || user.role === "ADMIN") return { all: true, items: [] };
const ids = user.role === "MR"
? (user.headquarters_id ? [user.headquarters_id] : [])
: mappings.filter((m) => m.area_manager_user_id === user.id).map((m) => m.headquarters_id);
const wanted = new Set(ids);
return { all: false, items: hqs.filter((h) => wanted.has(h.id)) };
}