import { Box, ModalFooterAnnotation, ModalIcon } from '@rocket.chat/fuselage';
import { ExternalLink, GenericModal } from '@rocket.chat/ui-client';
import { useToastMessageDispatch } from '@rocket.chat/ui-contexts';
import { Trans, useTranslation } from 'react-i18next';
import { links } from '../../../../lib/links';
import { useE2EEResetRoomKey } from '../../hooks/useE2EEResetRoomKey';
const E2EE_RESET_KEY_LINK = links.go.e2eeGuide;
export type ResetKeysE2EEModalProps = {
roomType: string;
roomId: string;
onCancel: () => void;
};
const ResetKeysE2EEModal = ({ roomType, roomId, onCancel }: ResetKeysE2EEModalProps) => {
const { t } = useTranslation();
const resetRoomKeyMutation = useE2EEResetRoomKey();
const dispatchToastMessage = useToastMessageDispatch();
const handleResetRoomKey = () => {
resetRoomKeyMutation.mutate(
{ roomId },
{
onSuccess: () => {
dispatchToastMessage({ type: 'success', message: t('E2E_reset_encryption_keys_success') });
},
onError: () => {
dispatchToastMessage({ type: 'error', message: t('E2E_reset_encryption_keys_error') });
},
onSettled: () => {
onCancel();
},
},
);
};
return (
}
title={t('E2E_reset_encryption_keys')}
variant='danger'
confirmText={t('E2E_reset_encryption_keys')}
dontAskAgain={{t('This_action_cannot_be_undone')}}
onCancel={onCancel}
onConfirm={handleResetRoomKey}
onDismiss={() => undefined}
>
Resetting E2EE keys is only recommend if no {roomType} member has a valid key to regain access to the previously encrypted
content. All members may lose access to previously encrypted content.
Learn more about resetting encryption keys. Proceed with caution.
);
};
export default ResetKeysE2EEModal;