diff --git a/administration/src/Router.tsx b/administration/src/Router.tsx index 2a8e504b8..27727329c 100644 --- a/administration/src/Router.tsx +++ b/administration/src/Router.tsx @@ -12,8 +12,9 @@ import Login from './bp-modules/auth/Login' import ResetPasswordController from './bp-modules/auth/ResetPasswordController' import CreateCardsController from './bp-modules/cards/CreateCardsController' import HomeController from './bp-modules/home/HomeController' -import DataPrivacyPolicy from './bp-modules/regions/DataPrivacyPolicy' import RegionsController from './bp-modules/regions/RegionController' +import DataPrivacyController from './bp-modules/regions/data-privacy-policy/DataPrivacyController' +import DataPrivacyPolicy from './bp-modules/regions/data-privacy-policy/DataPrivacyPolicy' import UserSettingsController from './bp-modules/user-settings/UserSettingsController' import ManageUsersController from './bp-modules/users/ManageUsersController' import ApplicationApplicantController from './mui-modules/application-verification/ApplicationApplicantController' @@ -68,6 +69,7 @@ const Router = () => { ...(projectConfig.applicationFeatureEnabled ? [ { path: 'applications', element: }, + { path: 'region/data-privacy-policy', element: }, // Currently, '/region' only allows to set the data privacy text for the application form { path: 'region', element: }, ] diff --git a/administration/src/bp-modules/regions/ActivatedForApplicationCard.tsx b/administration/src/bp-modules/regions/ActivatedForApplicationCard.tsx new file mode 100644 index 000000000..cef4087e0 --- /dev/null +++ b/administration/src/bp-modules/regions/ActivatedForApplicationCard.tsx @@ -0,0 +1,71 @@ +import { Button, Checkbox, H2 } from '@blueprintjs/core' +import React, { ReactElement, useEffect, useState } from 'react' +import styled from 'styled-components' + +import getMessageFromApolloError from '../../errors/getMessageFromApolloError' +import { useGetActivatedForApplicationQuery, useUpdateActivatedForApplicationMutation } from '../../generated/graphql' +import { useAppToaster } from '../AppToaster' +import SettingsCard from '../user-settings/SettingsCard' +import getQueryResult from '../util/getQueryResult' + +const ButtonContainer = styled.div` + text-align: right; + padding: 10px 0; +` + +const ActivatedForApplicationCard = ({ regionId }: { regionId: number }): ReactElement => { + const [activatedForApplication, setActivatedForApplication] = useState(false) + const appToaster = useAppToaster() + const activatedForApplicationQuery = useGetActivatedForApplicationQuery({ + variables: { regionId: regionId }, + }) + + const [updateActivatedForApplication, { loading }] = useUpdateActivatedForApplicationMutation({ + onError: error => { + const { title } = getMessageFromApolloError(error) + appToaster?.show({ intent: 'danger', message: title }) + }, + onCompleted: () => { + appToaster?.show({ intent: 'success', message: 'Einstellungen wurden erfolgreich geändert.' }) + }, + }) + useEffect(() => { + const activatedForApplicationQueryResult = getQueryResult(activatedForApplicationQuery) + if (activatedForApplicationQueryResult.successful) { + const { activatedForApplication } = activatedForApplicationQueryResult.data.result + setActivatedForApplication(activatedForApplication) + } + }, [activatedForApplicationQuery]) + + const activatedForApplicationQueryResult = getQueryResult(activatedForApplicationQuery) + if (!activatedForApplicationQueryResult.successful) return activatedForApplicationQueryResult.component + + return ( + +

Aktivierung Beantragungsprozess

+

Hier können Sie festlegen, ob Ihre Region für den neuen Antragsprozess freigeschaltet ist.

+ setActivatedForApplication(e.currentTarget.checked)} + label='Region ist aktiviert' + /> + +