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();
20 const { createNotification } = useNotifications();
22 const [revoking, withRevoking] = useLoading();
24 const handleVoidClick = async () => {
25 await api(deleteRecoverySecrets());
28 createNotification({ type: 'info', text: c('Info').t`Recovery files have been voided` });
35 title={c('Action').t`Void all recovery files?`}
37 <Button color="danger" loading={revoking} onClick={() => withRevoking(handleVoidClick())}>
40 <Button onClick={onClose}>{c('Action').t`Cancel`}</Button>,
44 {deviceRecoveryEnabled
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.`}
53 export default VoidRecoveryFilesModal;