From fb402e98980ad231a07d2cbbc9ce104c551530d7 Mon Sep 17 00:00:00 2001 From: Mannu Date: Sat, 23 May 2026 19:40:51 +0530 Subject: [PATCH] feat(settings/profile): move share to per-product, profile share on card header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Each product row now has an ↗ share button (product URL shared, not profile) WhatsApp message: "Found this for our baby — [title]: [url]" - Only one product share sheet open at a time; closes on backdrop tap - Profile page share (↗) moved to the profile card header row where it contextually belongs — shares the /m/slug link, not a product - Removed the share button that was on the Products section header Co-Authored-By: Claude Sonnet 4.6 --- src/app/settings/profile/page.tsx | 196 +++++++++++++++++------------- 1 file changed, 114 insertions(+), 82 deletions(-) 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 && ( + + )} +
+ + )} +
+ +
))}