refactor(frontend): moved types to global types and successfull build

This commit is contained in:
2025-03-03 06:32:46 -06:00
parent 89a2b3ea9e
commit f3b92e94e3
11 changed files with 91 additions and 50 deletions

View File

@@ -4,12 +4,13 @@ type User = {
user_id: string;
email: string;
username: string;
roles: keyof Roles[];
roles: Roles[];
role: string;
};
interface Roles {
role: string;
module_id: string;
}
// user will need access to the module.
@@ -17,9 +18,8 @@ interface Roles {
export function hasAccess(user: User | null, moduleName: string | null, modules: Modules[]): boolean {
// get the modules for the id
const filteredModule = modules?.filter((f) => f.name === moduleName);
console.log(filteredModule);
//console.log(filteredModule[0].module_id);
// userroles and filter out by the module id,
console.log(user);
return false;
return user?.roles.find((role) => role.module_id === filteredModule[0].module_id) ? true : false;
}