diff --git a/src/app/settings/profile/page.tsx b/src/app/settings/profile/page.tsx index 893322e..dc314b6 100644 --- a/src/app/settings/profile/page.tsx +++ b/src/app/settings/profile/page.tsx @@ -34,7 +34,8 @@ export default function ProfileSettingsPage() { const [saving, setSaving] = useState(false); const [saveMsg, setSaveMsg] = useState(""); const [profileExpanded, setProfileExpanded] = useState(true); - const [showShareSheet, setShowShareSheet] = useState(false); + const [shareProductId, setShareProductId] = useState(null); + const [profileShareOpen, setProfileShareOpen] = useState(false); const [copied, setCopied] = useState(false); const [slug, setSlug] = useState(""); @@ -89,21 +90,20 @@ export default function ProfileSettingsPage() { setSaving(false); } - async function copyLink() { - if (!profileUrl) return; - await navigator.clipboard.writeText(profileUrl); + async function copyLink(url: string) { + await navigator.clipboard.writeText(url); setCopied(true); setTimeout(() => setCopied(false), 2000); } - function shareViaWhatsApp() { - const text = encodeURIComponent(`Check out my baby product recommendations! ${profileUrl}`); - window.open(`https://wa.me/?text=${text}`, "_blank"); + function shareViaWhatsApp(url: string, text: string) { + const msg = encodeURIComponent(`${text} ${url}`); + window.open(`https://wa.me/?text=${msg}`, "_blank"); } - async function shareNative() { + async function shareNative(title: string, url: string) { if (navigator.share) { - await navigator.share({ title: `${displayName}'s baby picks`, url: profileUrl }); + await navigator.share({ title, url }); } } @@ -190,13 +190,13 @@ export default function ProfileSettingsPage() { {/* Profile section โ€” collapsible */}
{/* Always-visible header row */} - +
+ {/* Profile page share โ€” only when slug is set */} + {slug && slugValid && ( +
+ + {profileShareOpen && ( + <> +
setProfileShareOpen(false)} /> +
+

Share your profile page

+ + + {typeof navigator !== "undefined" && "share" in navigator && ( + + )} +
+ + )} +
+ )} +
- โ–ผ - +
{/* Expanded form */} {profileExpanded && ( @@ -281,58 +322,12 @@ export default function ProfileSettingsPage() {

Product Recommendations

-
- {/* Share button โ€” only visible when profile has a slug */} - {slug && slugValid && ( -
- - - {showShareSheet && ( - <> -
setShowShareSheet(false)} /> -
-

Share your page

- - - {typeof navigator !== "undefined" && "share" in navigator && ( - - )} -
- - )} -
- )} - -
+
{/* Add/Edit form */} @@ -373,19 +368,56 @@ export default function ProfileSettingsPage() {
{products.map((p, i) => ( -
-
{CATEGORY_EMOJI[p.category] || "๐Ÿ›๏ธ"}
-
-

{p.title}

-

{p.category} ยท {p.click_count} clicks

-
-
- - - - +
+
+
{CATEGORY_EMOJI[p.category] || "๐Ÿ›๏ธ"}
+
+

{p.title}

+

{p.category} ยท {p.click_count} clicks

+
+
+ + + + {/* Per-product share */} +
+ + {shareProductId === p.id && ( + <> +
setShareProductId(null)} /> +
+

{p.title}

+ + + {typeof navigator !== "undefined" && "share" in navigator && ( + + )} +
+ + )} +
+ +
))}