renaming app directory

This commit is contained in:
2025-02-23 14:55:13 -06:00
parent 5f26c48aba
commit e3f20617e9
43 changed files with 3 additions and 3 deletions

View File

@@ -0,0 +1,32 @@
import {
AuthenticationResult,
InteractionRequiredAuthError
} from '@azure/msal-browser';
import { useMsal } from '@azure/msal-react';
export const useAccessToken = () => {
const { accounts, instance } = useMsal();
const getAccessToken = async () => {
const tokenRequest = {
account: accounts[0],
scopes: [`api://${import.meta.env.VITE_CLIENT_ID}/user_impersonation`]
};
try {
const response: AuthenticationResult =
await instance.acquireTokenSilent(tokenRequest);
return `Bearer ${response.accessToken}`;
} catch (error) {
if (error instanceof InteractionRequiredAuthError) {
await instance.acquireTokenRedirect(tokenRequest);
}
throw error;
}
};
return {
getAccessToken
};
};

View File

@@ -0,0 +1,11 @@
import { useContext } from 'react';
import { AppContext } from '../../context/appContext/AppContext';
export const useAppContext = () => {
const { state, dispatch } = useContext(AppContext);
return {
state,
dispatch
};
};

View File

@@ -0,0 +1,29 @@
import axios, { AxiosInstance, CreateAxiosDefaults } from 'axios';
export const useHttpClient = () => {
let config: CreateAxiosDefaults<any> = {
baseURL: import.meta.env.VITE_API_URL,
headers: {
'Content-Type': 'application/json'
}
};
// if (import.meta.env.DEV) {
// config = {
// baseURL: import.meta.env.VITE_API_URL,
// headers: {
// 'Content-Type': 'application/json'
// }
// };
// } else {
// config = {
// headers: {
// 'Content-Type': 'application/json'
// }
// };
// }
const httpClient: AxiosInstance = axios.create(config);
return httpClient;
};