Update Formularium

This commit is contained in:
ivan-sim
2024-05-15 14:44:14 +07:00
parent 8bcc3fe15d
commit c4cf1bc64e
16 changed files with 1742 additions and 25 deletions

View File

@@ -0,0 +1,46 @@
import { Corporate } from '@/@types/corporates';
import axios from '@/utils/axios';
import { ReactNode, createContext, useState, useEffect } from 'react';
import { useParams } from 'react-router';
// hooks
import useResponsive from '../hooks/useResponsive';
// ----------------------------------------------------------------------
export type ConfiguredCorporateContextProps = {
currentCorporate?: Corporate | null;
};
const initialState: ConfiguredCorporateContextProps = {
currentCorporate: null,
};
const ConfiguredCorporateContext = createContext(initialState);
type ConfiguredCorporateProviderProps = {
children: ReactNode;
};
function ConfiguredCorporateProvider({ children }: ConfiguredCorporateProviderProps) {
const { corporate_id } = useParams();
const [corporate, setCorporate] = useState(null);
useEffect(() => {
axios.get(`corporates/${corporate_id}`)
.then((res) => {
setCorporate(res.data)
})
}, []);
return (
<ConfiguredCorporateContext.Provider
value={{
currentCorporate: corporate,
}}
>
{children}
</ConfiguredCorporateContext.Provider>
);
}
export { ConfiguredCorporateProvider, ConfiguredCorporateContext };