Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
disable usermanagement by config; update (C) 2023 (#337)
Browse files Browse the repository at this point in the history
* disable usermanagement by config; update (C) 2023

* remove unused imports

* adjust imprint, rename to Tenant
  • Loading branch information
ggrund-tsi authored Feb 21, 2023
1 parent 056a4b9 commit 3f0ddf8
Show file tree
Hide file tree
Showing 59 changed files with 2,263 additions and 1,628 deletions.
56 changes: 44 additions & 12 deletions src/api.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<IQuickTestDccAPIResponseModel>();

Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<StatisticData>();
const [thisWeekStatisticData, setThisWeekStaticData] = React.useState<StatisticData>();
Expand Down Expand Up @@ -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<StatisticData>();

Expand All @@ -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 })
Expand All @@ -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<Keycloak.KeycloakConfig>();

const header = {
Expand Down Expand Up @@ -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<any>();

const header = {
Expand Down Expand Up @@ -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 })
Expand Down Expand Up @@ -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<any>();

Expand Down
9 changes: 7 additions & 2 deletions src/components/LandingPage/LandingButton.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -26,7 +26,12 @@ const LandingButton = (props: any) => {
return (
<>
{props.hasRole && (
<Button block className='landing-btn' onClick={props.onClick} disabled={props.disabled}>
<Button
block
className='landing-btn'
onClick={props.onClick}
disabled={props.disabled}
>
{props.title}
</Button>
)}
Expand Down
13 changes: 9 additions & 4 deletions src/components/LandingPage/LandingDisclaimerButton.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 (
<>
Expand All @@ -40,7 +42,10 @@ const LandingDisclaimerButton = (props: any) => {
disclaimerText={
<>
{t('translation:disclaimer-text1-part1')}
<a href={t('translation:disclaimer-link')} target='blank'>
<a
href={t('translation:disclaimer-link')}
target='blank'
>
{t('translation:disclaimer-link')}
</a>
{t('translation:disclaimer-text1-part2')}
Expand Down
24 changes: 16 additions & 8 deletions src/components/LandingPage/landing-page.component.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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);
Expand All @@ -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>(CancellationSteps.NO_CANCEL);
const [cancellationStep, setCancellationStep] = React.useState<CancellationSteps>(
CancellationSteps.NO_CANCEL
);
const [downloadLink, setDownloadLink] = React.useState('');

React.useEffect(() => {
Expand Down Expand Up @@ -70,7 +74,10 @@ const LandingPage = (props: any) => {
{!context && <CwaSpinner />}

{context && utils && navigation && (
<Fade appear={true} in={true}>
<Fade
appear={true}
in={true}
>
<Container className='center-content'>
<h1 className='mx-auto mb-5 d-flex'>
{t('translation:welcome')}
Expand Down Expand Up @@ -114,14 +121,15 @@ const LandingPage = (props: any) => {
/>

<LandingButton
hasRole={utils.hasRole(keycloak, 'c19_quick_test_admin')}
hasRole={utils.hasRole(keycloak, 'c19_quick_test_admin') && !disabledUserManagement}
title={t('translation:user-management')}
onClick={navigation.toUserManagement}
/>

<LandingButton
hasRole={
utils.hasRole(keycloak, 'c19_quick_test_admin') && cancellationStep !== CancellationSteps.NO_CANCEL
utils.hasRole(keycloak, 'c19_quick_test_admin') &&
cancellationStep !== CancellationSteps.NO_CANCEL
}
title={t('translation:record-download')}
onClick={handleDownload}
Expand Down
Loading

0 comments on commit 3f0ddf8

Please sign in to comment.