| 1 | "use client"; |
| 2 | |
| 3 | import { useState } from |
| 4 | import { toast } |
| 5 | |
| 6 | /** Copies `text` to the clipboard, flagging `copied` for two seconds, or toasts `failure`. */ |
| 7 | export function useCopy(text |
| 8 | const [copied, |
| 9 | |
| 10 | async function copy |
| 11 | try { |
| 12 | await navigator.clipboard |
| 13 | setCopied(true); |
| 14 | setTimeout(() => |
| 15 | } catch { |
| 16 | toast.error(failure |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | return { copied, |
| 21 | } |