import React, { useEffect, useState } from 'react'; import { downloadAsFile } from 'utils/file'; import { getRecoveryKey } from 'utils/crypto'; import constants from 'utils/strings/constants'; import MessageDialog from './MessageDialog'; import EnteSpinner from './EnteSpinner'; import styled from 'styled-components'; export const CodeBlock = styled.div<{ height: number }>` display: flex; align-items: center; justify-content: center; background: #1a1919; height: ${(props) => props.height}px; padding-left: 30px; padding-right: 20px; color: white; margin: 20px 0; width: 100%; `; export const FreeFlowText = styled.div` word-wrap: break-word; overflow-wrap: break-word; min-width: 30%; `; interface Props { show: boolean; onHide: () => void; somethingWentWrong: any; } function RecoveryKeyModal({ somethingWentWrong, ...props }: Props) { const [recoveryKey, setRecoveryKey] = useState(null); useEffect(() => { if (!props.show) { return; } const main = async () => { const recoveryKey = await getRecoveryKey(); if (!recoveryKey) { somethingWentWrong(); props.onHide(); } setRecoveryKey(recoveryKey); }; main(); }, [props.show]); function onSaveClick() { downloadAsFile(constants.RECOVERY_KEY_FILENAME, recoveryKey); onClose(); } function onClose() { props.onHide(); } return (

{constants.RECOVERY_KEY_DESCRIPTION}

{recoveryKey ? ( {recoveryKey} ) : ( )}

{constants.KEY_NOT_STORED_DISCLAIMER}

); } export default RecoveryKeyModal;