forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecoveryTokensDialog.tsx
More file actions
51 lines (48 loc) · 1.92 KB
/
RecoveryTokensDialog.tsx
File metadata and controls
51 lines (48 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React from 'react';
import { Dialog, DialogProps } from '@/components/elements/dialog';
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}>
<pre className={'bg-gray-800 rounded p-2 mt-6'}>
{grouped.map((value) => (
<span key={value.join('_')} className={'block'}>
{value[0]}
<span className={'mx-2 selection:bg-gray-800'}> </span>
{value[1]}
<span className={'selection:bg-gray-800'}> </span>
</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>
);
};