// Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React, { useRef, useState } from 'react'; import type { LocalizerType } from '../types/Util'; import { Button, ButtonVariant } from './Button'; import { Modal } from './Modal'; import { Spinner } from './Spinner'; type PropsType = { i18n: LocalizerType; isPending: boolean; onContinue: () => void; onSkip: () => void; }; export function CaptchaDialog(props: Readonly): JSX.Element { const { i18n, isPending, onSkip, onContinue } = props; const [isClosing, setIsClosing] = useState(false); const buttonRef = useRef(null); const onCancelClick = (event: React.MouseEvent) => { event.preventDefault(); setIsClosing(false); }; const onSkipClick = (event: React.MouseEvent) => { event.preventDefault(); onSkip(); }; if (isClosing && !isPending) { return ( setIsClosing(false)} >

{i18n('CaptchaDialog--can-close__body')}

); } const onContinueClick = (event: React.MouseEvent) => { event.preventDefault(); onContinue(); }; const updateButtonRef = (button: HTMLButtonElement): void => { buttonRef.current = button; if (button) { button.focus(); } }; return ( setIsClosing(true)} >

{i18n('CaptchaDialog__first-paragraph')}

{i18n('CaptchaDialog__second-paragraph')}

); }