diff --git a/src/components/common/CreatorProfileHeader.tsx b/src/components/common/CreatorProfileHeader.tsx index 21d9325..045a036 100644 --- a/src/components/common/CreatorProfileHeader.tsx +++ b/src/components/common/CreatorProfileHeader.tsx @@ -23,18 +23,37 @@ const CreatorProfileHeader: React.FC = ({ }) => { const [copied, setCopied] = useState(false); - const handleCopy = async () => { + const handleShare = async () => { + const url = window.location.href; + + if (navigator.share) { + try { + await navigator.share({ + title: `${name} (@${handle}) on Access Layer`, + url, + }); + } catch (err) { + // User cancelled the share dialog — not an error worth surfacing + if (err instanceof Error && err.name !== 'AbortError') { + showToast.error('Failed to share profile'); + } + } + return; + } + + // Fallback: copy to clipboard try { - await navigator.clipboard.writeText(window.location.href); + await navigator.clipboard.writeText(url); setCopied(true); showToast.success('Profile link copied to clipboard!'); setTimeout(() => setCopied(false), 2000); - } catch (err) { - console.error('Failed to copy profile link:', err); + } catch { showToast.error('Failed to copy link'); } }; + const canNativeShare = typeof navigator !== 'undefined' && !!navigator.share; + return (
= ({
-