/* * Wire * Copyright (C) 2023 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 React, {useState} from 'react'; import {StatusCodes as HTTP_STATUS} from 'http-status-codes'; import {Button, COLOR, Container, ErrorMessage, Form, H2, Input, Link, Modal, Text} from '@wireapp/react-ui-kit'; import {t} from 'Util/LocalizerUtil'; import {Config} from '../../Config'; export interface JoinGuestLinkPasswordModalProps { onSubmitPassword: (password: string) => void; isLoading?: boolean; conversationName?: string; error: (Error & {label?: string; code?: number; message?: string}) | null; onClose: () => void; } const JoinGuestLinkPasswordModal: React.FC = ({ error, onClose, isLoading, conversationName, onSubmitPassword, }) => { const [passwordValue, setPasswordValue] = useState(''); const onSubmit = (event: React.FormEvent) => { event.preventDefault(); onSubmitPassword(passwordValue); }; const Error = () => { if (error?.code === HTTP_STATUS.FORBIDDEN || error?.code === HTTP_STATUS.BAD_REQUEST) { return {t('guestLinkPasswordModal.passwordIncorrect')}; } return null; }; return (

{conversationName ? t('guestLinkPasswordModal.headline', {conversationName}) : t('guestLinkPasswordModal.headlineDefault')}

{t('guestLinkPasswordModal.description')}
) => onSubmit(event)} autoComplete="off" > } data-uie-name="guest-link-join-password-input" name="guest-join-password" required placeholder={t('guestLinkPasswordModal.passwordInputLabel')} label={t('guestLinkPasswordModal.passwordInputLabel')} id="guest_link_join_password" className="modal__input" type="password" autoComplete="off" value={passwordValue} onChange={event => setPasswordValue(event.currentTarget.value)} />
{t('guestLinkPasswordModal.learnMoreLink')}
); }; export {JoinGuestLinkPasswordModal};