diff --git a/src/components/LandingPage/landing-page.component.tsx b/src/components/LandingPage/landing-page.component.tsx index f80b15d..3bff281 100644 --- a/src/components/LandingPage/landing-page.component.tsx +++ b/src/components/LandingPage/landing-page.component.tsx @@ -33,7 +33,7 @@ import CwaSpinner from '../spinner/spinner.component'; import LandingButton from './LandingButton'; import LandingCancellationText from './LandingCancellationText'; import LandingDisclaimerButton from './LandingDisclaimerButton'; -import useDisabledTenant from '../../misc/useDisabledTenant'; +import useEnabledTenant from '../../misc/useEnabledTenant'; const LandingPage = (props: any) => { const context = React.useContext(AppContext); @@ -42,7 +42,7 @@ const LandingPage = (props: any) => { const { t } = useTranslation(); const { keycloak } = useKeycloak(); const [, , , getDownloadLink] = useCancallation(); - const disabledUserManagement = useDisabledTenant(); + const enabledUserManagement = useEnabledTenant(); const [cancellationStep, setCancellationStep] = React.useState( CancellationSteps.NO_CANCEL @@ -121,7 +121,7 @@ const LandingPage = (props: any) => { /> diff --git a/src/components/modules/private-route.component.tsx b/src/components/modules/private-route.component.tsx index 4ec4eaf..bd445c7 100644 --- a/src/components/modules/private-route.component.tsx +++ b/src/components/modules/private-route.component.tsx @@ -28,7 +28,7 @@ import AppContext from '../../store/app-context'; interface PrivateRouteProps { roles?: string[]; - disabled?: boolean; + enabled?: boolean; } const PrivateRoute = (props: PrivateRouteProps) => { @@ -38,7 +38,7 @@ const PrivateRoute = (props: PrivateRouteProps) => { const [isInit, setIsInit] = React.useState(false); const [isAuthorized, setIsAuthorized] = React.useState(false); - const { roles, disabled } = props; + const { roles, enabled } = props; React.useEffect(() => { if (keycloak) { @@ -66,7 +66,7 @@ const PrivateRoute = (props: PrivateRouteProps) => { return ( <> {isInit && - (isAuthorized && !disabled ? ( + (isAuthorized && enabled ? ( ) : ( { +const useEnabledTenant = () => { const { contextConfig } = React.useContext(AppContext); - const [isDisbled, setIsDisabled] = React.useState(false); - const [disabledList, setDisabledList] = React.useState(['']); + const [isEnbled, setIsEnabled] = React.useState(false); + const [enabledFlag, setEnabledFlag] = React.useState(''); const [storedTenant] = useLocalStorage('mandant', ''); // get disabled list from context config useEffect(() => { - contextConfig && setDisabledList(contextConfig['disable-user-management']); + contextConfig && setEnabledFlag(contextConfig['enable-user-management']); }, [contextConfig]); // set disabled state if current tenant is in disabled-list React.useEffect(() => { - setIsDisabled(!!(storedTenant && disabledList && disabledList.includes(storedTenant))); - }, [storedTenant, disabledList]); + setIsEnabled(!!(storedTenant && enabledFlag && enabledFlag === storedTenant)); + }, [storedTenant, enabledFlag]); - return isDisbled; + return isEnbled; }; -export default useDisabledTenant; +export default useEnabledTenant; diff --git a/src/routing.component.tsx b/src/routing.component.tsx index 9c8317f..149b72e 100644 --- a/src/routing.component.tsx +++ b/src/routing.component.tsx @@ -43,14 +43,14 @@ import ErrorPage from './components/modals/error-page.component'; import NotificationToast from './components/modals/notification-toast.component'; import PrivateRoute from './components/modules/private-route.component'; import AppContext from './store/app-context'; -import useDisabledTenant from './misc/useDisabledTenant'; +import useEnabledTenant from './misc/useEnabledTenant'; const Routing = () => { const { t } = useTranslation(); const context = React.useContext(AppContext); const [quickTest, setQuickTest] = React.useState(); const [notificationShow, setNotificationShow] = React.useState(false); - const userManagementRouteIsDisabled = useDisabledTenant(); + const userManagementRouteIsEnabled = useEnabledTenant(); document.title = t('translation:title'); @@ -133,7 +133,7 @@ const Routing = () => { element={ } >