| 1 | "use client"; |
| 2 | |
| 3 | import { Check, Copy |
| 4 | import { useState } |
| 5 | import { toast } |
| 6 | |
| 7 | import { Alert, AlertDescription |
| 8 | import { Button } |
| 9 | |
| 10 | export function SecretAlert({ |
| 11 | const [copied, |
| 12 | |
| 13 | async function copy |
| 14 | try { |
| 15 | await navigator.clipboard |
| 16 | setCopied(true); |
| 17 | setTimeout(() => |
| 18 | } catch { |
| 19 | toast.error("Could not copy the secret. |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | return ( |
| 24 | <Alert> |
| 25 | <AlertTitle>Copy the signing secret for {url |
| 26 | <AlertDescription className=" |
| 27 | <p> |
| 28 | Ghost will not show it again. Use it to check the{" "} |
| 29 | <code className="font-mono text-xs |
| 30 | header on each delivery. |
| 31 | </p> |
| 32 | <div className="flex w-full items-center gap-2 |
| 33 | <code className="min-w-0 flex-1 truncate rounded-md border bg-muted px-2 py-1.5 font-mono text-xs |
| 34 | {secret} |
| 35 | </code> |
| 36 | <Button |
| 37 | type="button" |
| 38 | size="sm" |
| 39 | variant="outline" |
| 40 | onClick={copy} |
| 41 | aria-label="Copy signing secret" |
| 42 | > |
| 43 | {copied ? <Check |
| 44 | {copied ? "Copied |
| 45 | </Button> |
| 46 | </div> |
| 47 | </AlertDescription> |
| 48 | </Alert> |
| 49 | ); |
| 50 | } |