()
| 1 | import { useToast } from "@chakra-ui/react"; |
| 2 | |
| 3 | export const useCopyToClipboard = () => { |
| 4 | const toast = useToast(); |
| 5 | |
| 6 | const copyToClipboard = async (text?: string) => { |
| 7 | try { |
| 8 | await navigator.clipboard.writeText(text as string); |
| 9 | toast({ |
| 10 | title: "Copied to clipboard", |
| 11 | status: "success", |
| 12 | duration: 2000, |
| 13 | }); |
| 14 | } catch (err) { |
| 15 | toast({ |
| 16 | title: "Failed to copy to clipboard", |
| 17 | status: "error", |
| 18 | duration: 2000, |
| 19 | }); |
| 20 | } |
| 21 | }; |
| 22 | |
| 23 | return copyToClipboard; |
| 24 | }; |
no outgoing calls
no test coverage detected