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