Path: blob/develop/resources/scripts/components/dashboard/forms/RecoveryTokensDialog.tsx
7454 views
import { Dialog, DialogProps } from '@/components/elements/dialog';1import { Button } from '@/components/elements/button/index';2import CopyOnClick from '@/components/elements/CopyOnClick';3import { Alert } from '@/components/elements/alert';45interface RecoveryTokenDialogProps extends DialogProps {6tokens: string[];7}89export default ({ tokens, open, onClose }: RecoveryTokenDialogProps) => {10const grouped = [] as [string, string][];11tokens.forEach((token, index) => {12if (index % 2 === 0) {13grouped.push([token, tokens[index + 1] || '']);14}15});1617return (18<Dialog19open={open}20onClose={onClose}21title={'Two-Step Authentication Enabled'}22description={23'Store the codes below somewhere safe. If you lose access to your phone you can use these backup codes to sign in.'24}25hideCloseIcon26preventExternalClose27>28<Dialog.Icon position={'container'} type={'success'} />29<CopyOnClick text={tokens.join('\n')} showInNotification={false}>30<pre className={'mt-6 rounded bg-slate-800 p-2'}>31{grouped.map(value => (32<span key={value.join('_')} className={'block'}>33{value[0]}34<span className={'mx-2 selection:bg-slate-800'}> </span>35{value[1]}36<span className={'selection:bg-slate-800'}> </span>37</span>38))}39</pre>40</CopyOnClick>41<Alert type={'danger'} className={'mt-3'}>42These codes will not be shown again.43</Alert>44<Dialog.Footer>45<Button.Text onClick={onClose}>Done</Button.Text>46</Dialog.Footer>47</Dialog>48);49};505152