test(frontend): work on the frontend to have better admin
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import {create} from "zustand";
|
||||
import {useSessionStore} from "./sessionStore";
|
||||
import {Modules} from "@/types/modules";
|
||||
import { create } from "zustand";
|
||||
import { Modules } from "@/types/modules";
|
||||
import axios from "axios";
|
||||
|
||||
interface SettingState {
|
||||
@@ -15,15 +14,17 @@ interface FetchModulesResponse {
|
||||
|
||||
export const useGetUserRoles = create<SettingState>()((set) => ({
|
||||
userRoles: [],
|
||||
setUserRoles: (userRoles) => set({userRoles}),
|
||||
setUserRoles: (userRoles) => set({ userRoles }),
|
||||
fetchUserRoles: async () => {
|
||||
try {
|
||||
//const response = await axios.get<{data: Setting[]}>(`${process.env.NEXT_PUBLIC_URL}/api/settings/client`);
|
||||
const {token} = useSessionStore();
|
||||
const response = await axios.get("/api/auth/getuseraccess", {headers: {Authorization: `Bearer ${token}`}});
|
||||
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});
|
||||
set({ userRoles: data.data });
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch settings:", error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user