1 import { c } from 'ttag';
3 import { Button } from '@proton/atoms';
4 import Prompt from '@proton/components/components/prompt/Prompt';
5 import useApi from '@proton/components/hooks/useApi';
6 import useEventManager from '@proton/components/hooks/useEventManager';
7 import useLoading from '@proton/hooks/useLoading';
8 import metrics, { observeApiError } from '@proton/metrics';
9 import { updateSessionAccountRecovery } from '@proton/shared/lib/api/sessionRecovery';
10 import noop from '@proton/utils/noop';
17 const ConfirmDisableSessionRecoveryModal = ({ open, onClose }: Props) => {
19 const { call } = useEventManager();
21 const [submitting, withSubmitting] = useLoading();
23 const handleDisableSessionRecoveryToggle = async () => {
25 await api(updateSessionAccountRecovery({ SessionAccountRecovery: 0 }));
28 metrics.core_session_recovery_settings_update_total.increment({
32 observeApiError(error, (status) =>
33 metrics.core_session_recovery_settings_update_total.increment({
40 const handleClose = submitting ? noop : onClose;
46 title={c('session_recovery:disable:title').t`Disable password reset?`}
52 void withSubmitting(handleDisableSessionRecoveryToggle());
55 {c('session_recovery:disable:action').t`Disable password reset`}
57 <Button onClick={onClose} disabled={submitting}>{c('Action').t`Cancel`}</Button>,
61 {c('session_recovery:disable:info')
62 .t`You will no longer be able to request a password reset from your account settings.`}
64 <p>{c('session_recovery:disable:info').t`Make sure you have access to a recovery method.`}</p>
69 export default ConfirmDisableSessionRecoveryModal;