/* * Wire * Copyright (C) 2024 Wire Swiss GmbH * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * */ import {useState} from 'react'; import {StatusCodes} from 'http-status-codes'; import {container} from 'tsyringe'; import {Button, ButtonVariant, Checkbox, Link} from '@wireapp/react-ui-kit'; import {PrimaryModal} from 'Components/Modals/PrimaryModal'; import {Config} from 'src/script/Config'; import {TeamService} from 'src/script/team/TeamService'; import {t} from 'Util/LocalizerUtil'; import {StepProps} from './StepProps'; import { listCss, modalButtonsCss, termsCheckboxLabelCss, termsOfUseLinkCss, termsCheckboxWrapperCss, } from './TeamCreationSteps.styles'; import {buttonCss} from '../TeamCreation.styles'; const confirmationList = [ t('teamCreationConfirmListItem1'), t('teamCreationConfirmListItem2'), t('teamCreationConfirmListItem3'), ]; export const Confirmation = ({onPreviousStep, onNextStep, teamName, goToFirstStep, onSuccess}: StepProps) => { const [isMigrationAccepted, setIsMigrationAccepted] = useState(false); const [isTermOfUseAccepted, setIsTermOfUseAccepted] = useState(false); const [loading, setLoading] = useState(false); const teamService = container.resolve(TeamService); const onSubmit = async () => { try { setLoading(true); await teamService.upgradePersonalToTeamUser({ name: teamName, }); onNextStep(); } catch (error: any) { if (error.code === StatusCodes.FORBIDDEN) { PrimaryModal.show(PrimaryModal.type.ACKNOWLEDGE, { primaryAction: { action: onSuccess, text: t('teamCreationAlreadyInTeamErrorActionText'), }, close: onSuccess, text: { message: t('teamCreationAlreadyInTeamErrorMessage'), title: t('teamCreationAlreadyInTeamErrorTitle'), }, }); } else { PrimaryModal.show(PrimaryModal.type.ACKNOWLEDGE, { primaryAction: { action: goToFirstStep, text: t('teamCreationGeneralErrorActionText'), }, close: goToFirstStep, text: { message: t('teamCreationGeneralErrorMessage'), title: t('teamCreationGeneralErrorTitle'), }, }); } } finally { setLoading(false); } }; return ( <>

{t('teamCreationConfirmTitle')}

) => { setIsMigrationAccepted(event.target.checked); }} id="do-accept-migration" data-uie-name="do-accept-migration" wrapperCSS={termsCheckboxWrapperCss} > {t('teamCreationConfirmMigrationTermsText')} ) => { setIsTermOfUseAccepted(event.target.checked); }} id="do-accept-terms" data-uie-name="do-accept-terms" wrapperCSS={termsCheckboxWrapperCss} > {t('teamCreationConfirmTermsOfUseText')}{' '} {t('teamCreationConfirmTermsOfUseLink')} .
); };