2021-04-05 07:41:31 +00:00
|
|
|
import React, { useEffect, useState } from 'react';
|
2021-04-05 12:00:17 +00:00
|
|
|
import { Spinner } from 'react-bootstrap';
|
2021-04-05 07:41:31 +00:00
|
|
|
import { downloadAsFile } from 'utils/common';
|
|
|
|
import { getRecoveryKey } from 'utils/crypto';
|
|
|
|
import constants from 'utils/strings/constants';
|
2021-04-05 12:00:17 +00:00
|
|
|
import { MessageDialog } from './MessageDailog';
|
2021-04-05 07:41:31 +00:00
|
|
|
|
2021-04-05 12:00:17 +00:00
|
|
|
interface Props {
|
2021-04-05 07:41:31 +00:00
|
|
|
show: boolean;
|
|
|
|
onHide: () => void;
|
|
|
|
}
|
|
|
|
function RecoveryKeyModal(props: Props) {
|
|
|
|
const [recoveryKey, setRecoveryKey] = useState(null);
|
|
|
|
useEffect(() => {
|
2021-04-05 09:11:06 +00:00
|
|
|
if (!props.show) {
|
|
|
|
return;
|
|
|
|
}
|
2021-04-05 07:41:31 +00:00
|
|
|
const main = async () => {
|
2021-04-05 12:00:17 +00:00
|
|
|
const recoveryKey = null; //await getRecoveryKey();
|
2021-04-05 07:41:31 +00:00
|
|
|
|
|
|
|
setRecoveryKey(recoveryKey);
|
|
|
|
};
|
|
|
|
main();
|
|
|
|
}, [props.show]);
|
|
|
|
|
|
|
|
return (
|
2021-04-05 12:00:17 +00:00
|
|
|
<MessageDialog
|
|
|
|
{...props}
|
|
|
|
attributes={{
|
|
|
|
title: constants.DOWNLOAD_RECOVERY_KEY,
|
2021-04-05 12:17:33 +00:00
|
|
|
cancel: { text: constants.SAVE_LATER },
|
2021-04-05 12:00:17 +00:00
|
|
|
proceed: {
|
|
|
|
text: constants.SAVE,
|
|
|
|
action: () => {
|
2021-04-05 08:28:22 +00:00
|
|
|
downloadAsFile(
|
|
|
|
constants.RECOVERY_KEY_FILENAME,
|
|
|
|
recoveryKey
|
2021-04-05 10:39:58 +00:00
|
|
|
);
|
|
|
|
props.onHide();
|
2021-04-05 12:00:17 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{constants.PASSPHRASE_DISCLAIMER()}
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center',
|
|
|
|
background: '#1a1919',
|
|
|
|
height: '150px',
|
|
|
|
padding: '40px',
|
|
|
|
color: 'white',
|
|
|
|
margin: '20px 0',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{recoveryKey ? (
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
wordWrap: 'break-word',
|
|
|
|
overflowWrap: 'break-word',
|
|
|
|
minWidth: '40%',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{recoveryKey}
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<Spinner animation="border" />
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
{constants.KEY_NOT_STORED_DISCLAIMER()}
|
|
|
|
</MessageDialog>
|
2021-04-05 07:41:31 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
export default RecoveryKeyModal;
|