refactor(auth): added module and submodule access to the user

This commit is contained in:
2025-04-09 17:47:02 -05:00
parent ded074a1ce
commit efc630f5f8
10 changed files with 181 additions and 142 deletions

View File

@@ -19,12 +19,18 @@ export const useGetUserRoles = create<SettingState>()((set) => ({
try {
//const response = await axios.get<{data: Setting[]}>(`${process.env.NEXT_PUBLIC_URL}/api/settings/client`);
const token = localStorage.getItem("auth_token");
const response = await axios.get("/api/auth/getuseraccess", {
headers: { Authorization: `Bearer ${token}` },
});
const data: FetchModulesResponse = response.data; //await response.json();
//console.log(data);
set({ userRoles: data.data });
if (token) {
const response = await axios.get("/api/auth/getuseraccess", {
headers: { Authorization: `Bearer ${token}` },
});
const data: FetchModulesResponse = response.data; //await response.json();
//console.log(data);
set({ userRoles: data.data });
} else {
//console.log(data);
set({ userRoles: [] });
}
} catch (error) {
console.error("Failed to fetch settings:", error);
}