feat: make automatisch info available

This commit is contained in:
Ali BARIN
2023-03-06 18:04:47 +00:00
parent 66be6d1e89
commit 26d8e5856a
5 changed files with 77 additions and 5 deletions

View File

@@ -0,0 +1,38 @@
import * as React from 'react';
import { useQuery } from '@apollo/client';
import { GET_AUTOMATISCH_INFO } from 'graphql/queries/get-automatisch-info';
export type AutomatischInfoContextParams = {
isCloud: boolean;
};
export const AutomatischInfoContext =
React.createContext<AutomatischInfoContextParams>({
isCloud: false,
});
type AutomatischInfoProviderProps = {
children: React.ReactNode;
};
export const AutomatischInfoProvider = (
props: AutomatischInfoProviderProps
): React.ReactElement => {
const { children } = props;
const { data } = useQuery(GET_AUTOMATISCH_INFO);
const isCloud = data?.getAutomatischInfo?.isCloud || false;
const value = React.useMemo(() => {
return {
isCloud,
};
}, [isCloud]);
return (
<AutomatischInfoContext.Provider value={value}>
{children}
</AutomatischInfoContext.Provider>
);
};