1
0
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:
Aleksandr Gumroian 2022-06-09 17:28:04 +02:00
parent 2bbdda566c
commit 3fc1388a9f
No known key found for this signature in database
GPG Key ID: 9E77849C64F0A733

View File

@ -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>
); );