mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2025-08-01 20:03:28 +02:00
Fix linting issues
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React, { useState, useContext, useCallback } from "react";
|
||||
import React, { useState, useContext, useCallback, useMemo } from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import { Alert, ALERT_TYPES } from "../../bootstrap/Alert";
|
||||
import { Portal } from "../../utils/Portal";
|
||||
import Alert, { ALERT_TYPES } from "../../bootstrap/Alert";
|
||||
import Portal from "../../utils/Portal";
|
||||
|
||||
AlertContextProvider.propTypes = {
|
||||
children: PropTypes.oneOfType([
|
||||
@@ -30,6 +31,10 @@ function AlertContextProvider({ children }) {
|
||||
);
|
||||
|
||||
const dismissAlert = useCallback(() => setAlert(null), [setAlert]);
|
||||
const contextValue = useMemo(
|
||||
() => [setAlertWrapper, dismissAlert],
|
||||
[setAlertWrapper, dismissAlert]
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -40,7 +45,7 @@ function AlertContextProvider({ children }) {
|
||||
</Alert>
|
||||
</Portal>
|
||||
)}
|
||||
<AlertContext.Provider value={[setAlertWrapper, dismissAlert]}>
|
||||
<AlertContext.Provider value={contextValue}>
|
||||
{children}
|
||||
</AlertContext.Provider>
|
||||
</>
|
||||
|
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React, { useContext, useEffect } from "react";
|
||||
import React, { useContext, useEffect, useMemo } from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import { useAPIGet } from "../../api/hooks";
|
||||
import { ForisURLs } from "../../utils/forisUrls";
|
||||
|
||||
import { Spinner } from "../../bootstrap/Spinner";
|
||||
import { ForisURLs } from "../../utils/forisUrls";
|
||||
|
||||
CustomizationContextProvider.propTypes = {
|
||||
children: PropTypes.oneOfType([
|
||||
@@ -30,20 +30,31 @@ function CustomizationContextProvider({ children }) {
|
||||
getCustomization();
|
||||
}, [getCustomization]);
|
||||
|
||||
const deviceDetails = useMemo(
|
||||
() => getCustomizationResponse.data || {},
|
||||
[getCustomizationResponse.data]
|
||||
);
|
||||
|
||||
const isCustomized = useMemo(
|
||||
() =>
|
||||
!!(
|
||||
deviceDetails.customization !== undefined &&
|
||||
deviceDetails.customization === "shield"
|
||||
),
|
||||
[deviceDetails.customization]
|
||||
);
|
||||
|
||||
const contextValue = useMemo(
|
||||
() => ({ deviceDetails, isCustomized }),
|
||||
[deviceDetails, isCustomized]
|
||||
);
|
||||
|
||||
if (getCustomizationResponse.state !== "success") {
|
||||
return <Spinner fullScreen />;
|
||||
}
|
||||
|
||||
const deviceDetails = getCustomizationResponse.data || {};
|
||||
|
||||
const isCustomized = !!(
|
||||
deviceDetails &&
|
||||
deviceDetails.customization !== undefined &&
|
||||
deviceDetails.customization === "shield"
|
||||
);
|
||||
|
||||
return (
|
||||
<CustomizationContext.Provider value={{ deviceDetails, isCustomized }}>
|
||||
<CustomizationContext.Provider value={contextValue}>
|
||||
{children}
|
||||
</CustomizationContext.Provider>
|
||||
);
|
||||
|
Reference in New Issue
Block a user