feat: add add new config strategy to frontend
This commit is contained in:
14
frontend/src/hooks/config.hook.ts
Normal file
14
frontend/src/hooks/config.hook.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { createContext, useContext } from "react";
|
||||
import configService from "../services/config.service";
|
||||
import Config from "../types/config.type";
|
||||
|
||||
export const ConfigContext = createContext<Config[] | null>(null);
|
||||
|
||||
const useConfig = () => {
|
||||
const configVariables = useContext(ConfigContext) as Config[];
|
||||
return {
|
||||
get: (key: string) => configService.get(key, configVariables),
|
||||
};
|
||||
};
|
||||
|
||||
export default useConfig;
|
||||
Reference in New Issue
Block a user