Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
27 lines
807 B
TypeScript
27 lines
807 B
TypeScript
import { addToast } from '@/lib/toast'
|
|
|
|
/**
|
|
* Copies `text` to the clipboard and shows a success/failure toast.
|
|
* Was hand-copied (identical try/writeText/toast/catch shape) in
|
|
* BookingActionsModal.tsx#handleCopyCode and HostedEventActionsModal.tsx#handleShare —
|
|
* this is the shared home for any future "copy X" feature.
|
|
*/
|
|
const useCopyToClipboard = () => {
|
|
const copyToClipboard = async (text: string, messages: { successMessage: string; failureMessage: string }) => {
|
|
try {
|
|
await navigator.clipboard.writeText(text)
|
|
addToast({ title: messages.successMessage, color: 'success' })
|
|
|
|
return true
|
|
} catch {
|
|
addToast({ title: messages.failureMessage, color: 'danger' })
|
|
|
|
return false
|
|
}
|
|
}
|
|
|
|
return { copyToClipboard }
|
|
}
|
|
|
|
export default useCopyToClipboard
|