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 { ForisURLs } from "../utils/forisUrls";
import { Spinner } from "../bootstrap/Spinner";
CustomizationContextProvider.propTypes = {
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
@ -28,6 +30,10 @@ function CustomizationContextProvider({ children }) {
getCustomization();
}, [getCustomization]);
if (getCustomizationResponse.state !== "success") {
return <Spinner fullScreen />;
}
const deviceDetails = getCustomizationResponse.data || {};
const isCustomized = !!(
@ -37,7 +43,7 @@ function CustomizationContextProvider({ children }) {
);
return (
<CustomizationContext.Provider value={isCustomized}>
<CustomizationContext.Provider value={{ deviceDetails, isCustomized }}>
{children}
</CustomizationContext.Provider>
);