Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 104x 32x 27x 23x 146x 17x 17x 146x 32x | import { useMemo } from "react";
import { UserRole } from "shared-types/events/legacy-user";
import { isStateRole } from "shared-utils";
import { StateAccess } from "@/api";
type StateAccessMap = Record<string, Set<UserRole>>;
export const useStateAccessMap = (stateAccessList: StateAccess[]): StateAccessMap => {
const accessMap = useMemo(() => {
if (!stateAccessList) return {};
return stateAccessList.reduce<Record<string, Set<UserRole>>>((map, access) => {
if (access.status === "active" && isStateRole(access.role)) {
Eif (!map[access.territory]) map[access.territory] = new Set();
map[access.territory].add(access.role);
}
return map;
}, {});
}, [stateAccessList]);
return accessMap;
};
|