refactor(stores): added in axios

This commit is contained in:
2025-03-19 17:12:27 -05:00
parent 1cd1d3a3e9
commit 3b8f18093e
3 changed files with 13 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
import {create} from "zustand";
import {useSessionStore} from "./sessionStore";
import {Modules} from "@/types/modules";
import axios from "axios";
interface SettingState {
userRoles: Modules[];
@@ -19,15 +20,8 @@ export const useGetUserRoles = create<SettingState>()((set) => ({
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();
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});
} catch (error) {