mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2024-11-14 17:35:35 +01:00
fixup! Add CustomizationContext and custom hook
This commit is contained in:
parent
2bbdda566c
commit
3fc1388a9f
|
@ -11,6 +11,8 @@ import PropTypes from "prop-types";
|
||||||
import { useAPIGet } from "../api/hooks";
|
import { useAPIGet } from "../api/hooks";
|
||||||
import { ForisURLs } from "../utils/forisUrls";
|
import { ForisURLs } from "../utils/forisUrls";
|
||||||
|
|
||||||
|
import { Spinner } from "../bootstrap/Spinner";
|
||||||
|
|
||||||
CustomizationContextProvider.propTypes = {
|
CustomizationContextProvider.propTypes = {
|
||||||
children: PropTypes.oneOfType([
|
children: PropTypes.oneOfType([
|
||||||
PropTypes.arrayOf(PropTypes.node),
|
PropTypes.arrayOf(PropTypes.node),
|
||||||
|
@ -28,6 +30,10 @@ function CustomizationContextProvider({ children }) {
|
||||||
getCustomization();
|
getCustomization();
|
||||||
}, [getCustomization]);
|
}, [getCustomization]);
|
||||||
|
|
||||||
|
if (getCustomizationResponse.state !== "success") {
|
||||||
|
return <Spinner fullScreen />;
|
||||||
|
}
|
||||||
|
|
||||||
const deviceDetails = getCustomizationResponse.data || {};
|
const deviceDetails = getCustomizationResponse.data || {};
|
||||||
|
|
||||||
const isCustomized = !!(
|
const isCustomized = !!(
|
||||||
|
@ -37,7 +43,7 @@ function CustomizationContextProvider({ children }) {
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CustomizationContext.Provider value={isCustomized}>
|
<CustomizationContext.Provider value={{ deviceDetails, isCustomized }}>
|
||||||
{children}
|
{children}
|
||||||
</CustomizationContext.Provider>
|
</CustomizationContext.Provider>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user