| 133 | } |
| 134 | |
| 135 | function RecoveryCodesBlock({ codes }: { codes: string[] }) { |
| 136 | return ( |
| 137 | <div className="col gap-2"> |
| 138 | <div className="grid grid-cols-2 gap-2 rounded-md border border-border bg-def-100 p-3 font-mono text-sm"> |
| 139 | {codes.map((c) => ( |
| 140 | <span key={c}>{c}</span> |
| 141 | ))} |
| 142 | </div> |
| 143 | <div className="row gap-2"> |
| 144 | <Button |
| 145 | className="self-start" |
| 146 | icon={DownloadIcon} |
| 147 | onClick={() => { |
| 148 | const blob = new Blob([codes.join('\n')], { type: 'text/plain' }); |
| 149 | const url = URL.createObjectURL(blob); |
| 150 | const a = document.createElement('a'); |
| 151 | a.href = url; |
| 152 | a.download = 'recovery-codes.txt'; |
| 153 | a.click(); |
| 154 | URL.revokeObjectURL(url); |
| 155 | }} |
| 156 | size="sm" |
| 157 | variant="outline" |
| 158 | > |
| 159 | Download |
| 160 | </Button> |
| 161 | <Button |
| 162 | className="self-start" |
| 163 | onClick={() => { |
| 164 | navigator.clipboard.writeText(codes.join('\n')); |
| 165 | toast.success('Copied to clipboard'); |
| 166 | }} |
| 167 | size="sm" |
| 168 | variant="outline" |
| 169 | > |
| 170 | Copy all |
| 171 | </Button> |
| 172 | </div> |
| 173 | </div> |
| 174 | ); |
| 175 | } |