import {create} from "zustand"; import {useSessionStore} from "./sessionStore"; import {Modules} from "@/types/modules"; interface SettingState { userRoles: Modules[]; fetchUserRoles: () => Promise; setUserRoles: (userRoles: Modules[]) => void; } interface FetchModulesResponse { data: Modules[]; } export const useGetUserRoles = create()((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 fetch(`/api/auth/getuseraccess`, { method: "GET", headers: { "Content-Type": "application/json", Authentication: `Beaer ${token}`, // You can add other headers here if necessary }, }); const data: FetchModulesResponse = await response.json(); //console.log(data); set({userRoles: data.data}); } catch (error) { console.error("Failed to fetch settings:", error); } }, }));