2022-07-03 17:29:23 +00:00
|
|
|
import { Dialog, DialogProps } from '@/components/elements/dialog';
|
2022-07-02 22:53:03 +00:00
|
|
|
import { Button } from '@/components/elements/button/index';
|
|
|
|
import CopyOnClick from '@/components/elements/CopyOnClick';
|
|
|
|
import { Alert } from '@/components/elements/alert';
|
|
|
|
|
|
|
|
interface RecoveryTokenDialogProps extends DialogProps {
|
|
|
|
tokens: string[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ({ tokens, open, onClose }: RecoveryTokenDialogProps) => {
|
|
|
|
const grouped = [] as [string, string][];
|
|
|
|
tokens.forEach((token, index) => {
|
|
|
|
if (index % 2 === 0) {
|
|
|
|
grouped.push([token, tokens[index + 1] || '']);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Dialog
|
|
|
|
open={open}
|
|
|
|
onClose={onClose}
|
|
|
|
title={'Two-Step Authentication Enabled'}
|
|
|
|
description={
|
|
|
|
'Store the codes below somewhere safe. If you lose access to your phone you can use these backup codes to sign in.'
|
|
|
|
}
|
|
|
|
hideCloseIcon
|
|
|
|
preventExternalClose
|
|
|
|
>
|
|
|
|
<Dialog.Icon position={'container'} type={'success'} />
|
|
|
|
<CopyOnClick text={tokens.join('\n')} showInNotification={false}>
|
2022-12-16 02:06:14 +00:00
|
|
|
<pre className={'bg-slate-800 rounded p-2 mt-6'}>
|
2022-11-25 20:25:03 +00:00
|
|
|
{grouped.map(value => (
|
2022-07-02 22:53:03 +00:00
|
|
|
<span key={value.join('_')} className={'block'}>
|
|
|
|
{value[0]}
|
2022-12-16 02:06:14 +00:00
|
|
|
<span className={'mx-2 selection:bg-slate-800'}> </span>
|
2022-07-02 22:53:03 +00:00
|
|
|
{value[1]}
|
2022-12-16 02:06:14 +00:00
|
|
|
<span className={'selection:bg-slate-800'}> </span>
|
2022-07-02 22:53:03 +00:00
|
|
|
</span>
|
|
|
|
))}
|
|
|
|
</pre>
|
|
|
|
</CopyOnClick>
|
|
|
|
<Alert type={'danger'} className={'mt-3'}>
|
|
|
|
These codes will not be shown again.
|
|
|
|
</Alert>
|
|
|
|
<Dialog.Footer>
|
|
|
|
<Button.Text onClick={onClose}>Done</Button.Text>
|
|
|
|
</Dialog.Footer>
|
|
|
|
</Dialog>
|
|
|
|
);
|
|
|
|
};
|