| 1 | "use client"; |
| 2 | |
| 3 | import { Check, Copy |
| 4 | import type { ReactNode |
| 5 | |
| 6 | import { Alert, AlertDescription |
| 7 | import { Button } |
| 8 | import { useCopy } |
| 9 | |
| 10 | /** A secret Ghost shows once, with a copy button. */ |
| 11 | export function SecretAlert({ |
| 12 | title, |
| 13 | description, |
| 14 | secret, |
| 15 | }: { |
| 16 | title: string |
| 17 | description: ReactNode |
| 18 | secret: string |
| 19 | }) { |
| 20 | const { copied, |
| 21 | |
| 22 | return ( |
| 23 | <Alert> |
| 24 | <AlertTitle>{title} |
| 25 | <AlertDescription className=" |
| 26 | <p>{description}</ |
| 27 | <div className="flex w-full items-center gap-2 |
| 28 | <code className="min-w-0 flex-1 truncate rounded-md border bg-muted px-2 py-1.5 font-mono text-xs |
| 29 | {secret} |
| 30 | </code> |
| 31 | <Button |
| 32 | type="button" |
| 33 | size="sm" |
| 34 | variant="outline" |
| 35 | onClick={copy} |
| 36 | aria-label="Copy secret" |
| 37 | > |
| 38 | {copied ? <Check |
| 39 | {copied ? "Copied |
| 40 | </Button> |
| 41 | </div> |
| 42 | </AlertDescription> |
| 43 | </Alert> |
| 44 | ); |
| 45 | } |