Remove payments API routing initialization
[ProtonMail-WebClient.git] / packages / components / containers / recovery / VoidRecoveryFilesModal.tsx
blobd45a49a26d54e0a35430c0aa826f806b11dc1b95
1 import { c } from 'ttag';
3 import { Button } from '@proton/atoms';
4 import type { ModalProps } from '@proton/components/components/modalTwo/Modal';
5 import Prompt from '@proton/components/components/prompt/Prompt';
6 import useApi from '@proton/components/hooks/useApi';
7 import useEventManager from '@proton/components/hooks/useEventManager';
8 import useNotifications from '@proton/components/hooks/useNotifications';
9 import { useLoading } from '@proton/hooks';
10 import { deleteRecoverySecrets } from '@proton/shared/lib/api/settingsRecovery';
12 interface Props extends Omit<ModalProps, 'children' | 'size'> {
13     deviceRecoveryEnabled: boolean | undefined;
14     onVoid: () => Promise<void>;
17 const VoidRecoveryFilesModal = ({ deviceRecoveryEnabled, onVoid, onClose, ...rest }: Props) => {
18     const { call } = useEventManager();
19     const api = useApi();
20     const { createNotification } = useNotifications();
22     const [revoking, withRevoking] = useLoading();
24     const handleVoidClick = async () => {
25         await api(deleteRecoverySecrets());
26         await call();
27         await onVoid();
28         createNotification({ type: 'info', text: c('Info').t`Recovery files have been voided` });
29         onClose?.();
30     };
32     return (
33         <Prompt
34             {...rest}
35             title={c('Action').t`Void all recovery files?`}
36             buttons={[
37                 <Button color="danger" loading={revoking} onClick={() => withRevoking(handleVoidClick())}>
38                     {c('Action').t`Void`}
39                 </Button>,
40                 <Button onClick={onClose}>{c('Action').t`Cancel`}</Button>,
41             ]}
42         >
43             <p className="m-0">
44                 {deviceRecoveryEnabled
45                     ? c('Info')
46                           .t`You won’t be able to recover locked data using your downloaded recovery files. This will also disable device-based recovery.`
47                     : c('Info').t`You won’t be able to recover locked data using your downloaded recovery files.`}
48             </p>
49         </Prompt>
50     );
53 export default VoidRecoveryFilesModal;