/opt/canhelp/apps/web/src/components
Edit: /opt/canhelp/apps/web/src/components/ShareButton.tsx (1041B)
'use client'
import { useState } from 'react'
interface Props {
label: string
copiedLabel: string
}
export function ShareButton({ label, copiedLabel }: Props) {
const [copied, setCopied] = useState(false)
const handle = async () => {
const url = window.location.origin
if (navigator.share) {
try {
await navigator.share({ url, title: 'CanHelp' })
return
} catch {}
}
await navigator.clipboard.writeText(url)
setCopied(true)
setTimeout(() => setCopied(false), 2500)
}
return (
)
}