From 3f0ddf89d0f21644ee6d916bb774d60579175047 Mon Sep 17 00:00:00 2001 From: Gordon Grund <80682839+ggrund-tsi@users.noreply.github.com> Date: Tue, 21 Feb 2023 12:00:01 +0100 Subject: [PATCH] disable usermanagement by config; update (C) 2023 (#337) * disable usermanagement by config; update (C) 2023 * remove unused imports * adjust imprint, rename to Tenant --- src/api.tsx | 56 ++- src/components/LandingPage/LandingButton.tsx | 9 +- .../LandingPage/LandingDisclaimerButton.tsx | 13 +- .../LandingPage/landing-page.component.tsx | 24 +- .../modals/confirm-modal.component.tsx | 145 +++--- .../modals/dataprivacy.component.tsx | 427 ++++++++++------- .../modals/error-page.component.tsx | 26 +- .../modals/group-modal.component.tsx | 2 +- src/components/modals/imprint.component.tsx | 251 +++++----- .../modals/notification-toast.component.tsx | 57 +-- .../modals/process-input.component.tsx | 208 +++++---- .../modals/user-modal.component.tsx | 438 ++++++++++-------- src/components/modules/address-inputs.tsx | 171 ++++--- .../modules/card-footer.component.tsx | 29 +- .../modules/card-header.component.tsx | 26 +- .../modules/disclamer-btn.component.tsx | 31 +- src/components/modules/footer.component.tsx | 17 +- .../modules/form-group.component.tsx | 181 ++++++-- .../modules/group-table.component.tsx | 2 +- src/components/modules/header.component.tsx | 2 +- .../modules/paged-list.component.tsx | 390 ++++++++-------- src/components/modules/person-data-inputs.tsx | 2 +- .../modules/private-route.component.tsx | 7 +- .../modules/statistic-data.component.tsx | 353 +++++++------- src/components/modules/test-result-inputs.tsx | 53 +-- .../modules/user-table.component.tsx | 2 +- src/components/qr-scan.component.tsx | 2 +- .../record-patient-data.component.tsx | 73 +-- .../record-test-result.component.tsx | 29 +- src/components/reports.tsx | 85 +++- .../show-patient-data.component.tsx | 35 +- src/components/spinner/spinner.component.tsx | 32 +- src/components/statistics.component.tsx | 49 +- src/components/user-management.component.tsx | 36 +- src/i18n.js | 2 +- src/index.tsx | 2 +- src/login-interceptor.component.tsx | 2 +- src/misc/enum.tsx | 25 +- src/misc/error.tsx | 2 +- src/misc/qr-code-value.tsx | 185 ++++---- src/misc/qt-archiv.tsx | 30 +- src/misc/quick-test.tsx | 51 +- src/misc/statistic-data.tsx | 20 +- src/misc/test-result.tsx | 16 +- src/misc/useCancellation.ts | 21 + src/misc/useDisabledTenant.ts | 45 ++ src/misc/useLocalStorage.tsx | 67 ++- src/misc/useNavigation.tsx | 2 +- src/misc/useOnUnload.tsx | 35 +- src/misc/useTransliterate.tsx | 9 +- src/misc/useValueSet.tsx | 10 +- src/misc/user.tsx | 63 ++- src/misc/utils.tsx | 2 +- src/react-app-env.d.ts | 2 +- src/reportWebVitals.ts | 2 +- src/root.component.tsx | 2 +- src/routing.component.tsx | 29 +- src/setupTests.ts | 2 +- src/store/app-context.tsx | 2 +- 59 files changed, 2263 insertions(+), 1628 deletions(-) create mode 100644 src/misc/useDisabledTenant.ts diff --git a/src/api.tsx b/src/api.tsx index 2a7c0f2..3dd4dde 100644 --- a/src/api.tsx +++ b/src/api.tsx @@ -1,7 +1,7 @@ /* * Corona-Warn-App / cwa-quick-test-frontend * - * (C) 2022, T-Systems International GmbH + * (C) 2023, T-Systems International GmbH * * Deutsche Telekom AG and all other contributors / * copyright owners license this file to you under the Apache @@ -145,7 +145,11 @@ export const useGetPendingProcessIds = (onSuccess?: () => void, onError?: (error return result; }; -export const useGetQuicktest = (processId?: string, onSuccess?: () => void, onError?: (error: any) => void) => { +export const useGetQuicktest = ( + processId?: string, + onSuccess?: () => void, + onError?: (error: any) => void +) => { const { keycloak, initialized } = useKeycloak(); const [result, setResult] = React.useState(); @@ -190,8 +194,12 @@ export const usePostTestResult = ( React.useEffect(() => { if (testResult && processId) { // shorten the manufactorer name for display purposes (PDF) - if (testResult.dccTestManufacturerDescription && testResult.dccTestManufacturerDescription.length > 100) { - testResult.dccTestManufacturerDescription = testResult.dccTestManufacturerDescription.substring(0, 100); + if ( + testResult.dccTestManufacturerDescription && + testResult.dccTestManufacturerDescription.length > 100 + ) { + testResult.dccTestManufacturerDescription = + testResult.dccTestManufacturerDescription.substring(0, 100); } const uri = '/api/quicktest/' + processId + '/testResult'; @@ -235,7 +243,9 @@ export const usePostQuickTest = ( firstName: quickTest.personData.givenName, standardisedFamilyName: quickTest.personData.standardisedFamilyName, standardisedGivenName: quickTest.personData.standardisedGivenName, - birthday: quickTest.personData.dateOfBirth ? quickTest.personData.dateOfBirth.toISOString().split('T')[0] : '', + birthday: quickTest.personData.dateOfBirth + ? quickTest.personData.dateOfBirth.toISOString().split('T')[0] + : '', sex: quickTest.personData.sex, street: quickTest.addressData.street, @@ -386,7 +396,10 @@ export const useGetTests = (onError?: (error: any) => void) => { return result; }; -export const useStatistics = (onSuccess?: (status: number) => void, onError?: (error: any) => void) => { +export const useStatistics = ( + onSuccess?: (status: number) => void, + onError?: (error: any) => void +) => { const { keycloak, initialized } = useKeycloak(); const [statisticData, setStatisticData] = React.useState(); const [thisWeekStatisticData, setThisWeekStaticData] = React.useState(); @@ -475,7 +488,10 @@ export const useStatistics = (onSuccess?: (status: number) => void, onError?: (e return [statisticData, thisWeekStatisticData, thisMonthStatisticData] as const; }; -export const useGetStatisticsFromTo = (onSuccess?: (status: number) => void, onError?: (error: any) => void) => { +export const useGetStatisticsFromTo = ( + onSuccess?: (status: number) => void, + onError?: (error: any) => void +) => { const { keycloak, initialized } = useKeycloak(); const [result, setResult] = React.useState(); @@ -491,7 +507,8 @@ export const useGetStatisticsFromTo = (onSuccess?: (status: number) => void, onE return; } - let requestUri = balseUri + '?dateFrom=' + dateFrom.toISOString() + '&dateTo=' + dateTo.toISOString(); + let requestUri = + balseUri + '?dateFrom=' + dateFrom.toISOString() + '&dateTo=' + dateTo.toISOString(); api .get(requestUri, { headers: header }) @@ -511,7 +528,10 @@ export const useGetStatisticsFromTo = (onSuccess?: (status: number) => void, onE return [result, getStatisticsFromTo] as const; }; -export const useGetKeycloakConfig = (onSuccess?: (status: number) => void, onError?: (error: any) => void) => { +export const useGetKeycloakConfig = ( + onSuccess?: (status: number) => void, + onError?: (error: any) => void +) => { const [result, setResult] = React.useState(); const header = { @@ -542,7 +562,10 @@ export const useGetKeycloakConfig = (onSuccess?: (status: number) => void, onErr return result; }; -export const useGetContextConfig = (onSuccess?: (status: number) => void, onError?: (error: any) => void) => { +export const useGetContextConfig = ( + onSuccess?: (status: number) => void, + onError?: (error: any) => void +) => { const [result, setResult] = React.useState(); const header = { @@ -593,7 +616,13 @@ export const useGetPositiveForTimeRange = ( if (testResult) { tp = 'testResult=' + testResult + '&'; } - const uri = '/api/quicktestarchive?' + tp + 'dateFrom=' + start.toISOString() + '&dateTo=' + end.toISOString(); + const uri = + '/api/quicktestarchive?' + + tp + + 'dateFrom=' + + start.toISOString() + + '&dateTo=' + + end.toISOString(); api .get(uri, { headers: header }) @@ -790,7 +819,10 @@ export const useGetGroups = (onSuccess?: () => void, onError?: (error: any) => v return [result, refreshGroups, createGroup, updateGroup, deleteGroup] as const; }; -export const useGetGroupDetails = (groupReloaded: (group: IGroupDetails) => void, onError?: (error: any) => void) => { +export const useGetGroupDetails = ( + groupReloaded: (group: IGroupDetails) => void, + onError?: (error: any) => void +) => { const { keycloak, initialized } = useKeycloak(); const [result, setResult] = React.useState(); diff --git a/src/components/LandingPage/LandingButton.tsx b/src/components/LandingPage/LandingButton.tsx index ccade61..aaed67e 100644 --- a/src/components/LandingPage/LandingButton.tsx +++ b/src/components/LandingPage/LandingButton.tsx @@ -1,7 +1,7 @@ /* * Corona-Warn-App / cwa-quick-test-frontend * - * (C) 2022, T-Systems International GmbH + * (C) 2023, T-Systems International GmbH * * Deutsche Telekom AG and all other contributors / * copyright owners license this file to you under the Apache @@ -26,7 +26,12 @@ const LandingButton = (props: any) => { return ( <> {props.hasRole && ( - )} diff --git a/src/components/LandingPage/LandingDisclaimerButton.tsx b/src/components/LandingPage/LandingDisclaimerButton.tsx index 97db154..9c0b524 100644 --- a/src/components/LandingPage/LandingDisclaimerButton.tsx +++ b/src/components/LandingPage/LandingDisclaimerButton.tsx @@ -1,7 +1,7 @@ /* * Corona-Warn-App / cwa-quick-test-frontend * - * (C) 2022, T-Systems International GmbH + * (C) 2023, T-Systems International GmbH * * Deutsche Telekom AG and all other contributors / * copyright owners license this file to you under the Apache @@ -25,8 +25,10 @@ import DisclamerButton from '../modules/disclamer-btn.component'; const LandingDisclaimerButton = (props: any) => { const { t } = useTranslation(); - const [storedLandingDisclaimerShow, setStoredLandingDisclaimerShow] = - useLocalStorage('landingDisclaimerShow', true); + const [storedLandingDisclaimerShow, setStoredLandingDisclaimerShow] = useLocalStorage( + 'landingDisclaimerShow', + true + ); return ( <> @@ -40,7 +42,10 @@ const LandingDisclaimerButton = (props: any) => { disclaimerText={ <> {t('translation:disclaimer-text1-part1')} - + {t('translation:disclaimer-link')} {t('translation:disclaimer-text1-part2')} diff --git a/src/components/LandingPage/landing-page.component.tsx b/src/components/LandingPage/landing-page.component.tsx index 422c808..f80b15d 100644 --- a/src/components/LandingPage/landing-page.component.tsx +++ b/src/components/LandingPage/landing-page.component.tsx @@ -1,7 +1,7 @@ /* * Corona-Warn-App / cwa-quick-test-frontend * - * (C) 2022, T-Systems International GmbH + * (C) 2023, T-Systems International GmbH * * Deutsche Telekom AG and all other contributors / * copyright owners license this file to you under the Apache @@ -26,13 +26,14 @@ import { useTranslation } from 'react-i18next'; import '../../i18n'; import { useKeycloak } from '@react-keycloak/web'; +import CancellationSteps from '../../misc/CancellationSteps'; +import useCancallation from '../../misc/useCancellation'; import AppContext from '../../store/app-context'; import CwaSpinner from '../spinner/spinner.component'; import LandingButton from './LandingButton'; -import LandingDisclaimerButton from './LandingDisclaimerButton'; import LandingCancellationText from './LandingCancellationText'; -import CancellationSteps from '../../misc/CancellationSteps'; -import useCancallation from '../../misc/useCancellation'; +import LandingDisclaimerButton from './LandingDisclaimerButton'; +import useDisabledTenant from '../../misc/useDisabledTenant'; const LandingPage = (props: any) => { const context = React.useContext(AppContext); @@ -41,8 +42,11 @@ const LandingPage = (props: any) => { const { t } = useTranslation(); const { keycloak } = useKeycloak(); const [, , , getDownloadLink] = useCancallation(); + const disabledUserManagement = useDisabledTenant(); - const [cancellationStep, setCancellationStep] = React.useState(CancellationSteps.NO_CANCEL); + const [cancellationStep, setCancellationStep] = React.useState( + CancellationSteps.NO_CANCEL + ); const [downloadLink, setDownloadLink] = React.useState(''); React.useEffect(() => { @@ -70,7 +74,10 @@ const LandingPage = (props: any) => { {!context && } {context && utils && navigation && ( - +

{t('translation:welcome')} @@ -114,14 +121,15 @@ const LandingPage = (props: any) => { /> { - const { t } = useTranslation(); - const [btnOkDisabled, setBtnOkDisabled] = React.useState(true); + const { t } = useTranslation(); + const [btnOkDisabled, setBtnOkDisabled] = React.useState(true); - const handleEnter = () => { - setBtnOkDisabled(false); - } + const handleEnter = () => { + setBtnOkDisabled(false); + }; - const handleOk = () => { - if (props.handleOk) { - setBtnOkDisabled(true); - props.handleOk(); - } + const handleOk = () => { + if (props.handleOk) { + setBtnOkDisabled(true); + props.handleOk(); } + }; - return ( - + + - - {props.title} - - - {props.message} - - - - - - - - - - + + + - - - - - - ) -} +