diff --git a/src/app/settings/profile/page.tsx b/src/app/settings/profile/page.tsx index 82b0918..893322e 100644 --- a/src/app/settings/profile/page.tsx +++ b/src/app/settings/profile/page.tsx @@ -33,6 +33,9 @@ export default function ProfileSettingsPage() { const [loading, setLoading] = useState(true); const [saving, setSaving] = useState(false); const [saveMsg, setSaveMsg] = useState(""); + const [profileExpanded, setProfileExpanded] = useState(true); + const [showShareSheet, setShowShareSheet] = useState(false); + const [copied, setCopied] = useState(false); const [slug, setSlug] = useState(""); const [displayName, setDisplayName] = useState(""); @@ -58,12 +61,15 @@ export default function ProfileSettingsPage() { setDisplayName(pd.profile.display_name); setBio(pd.profile.bio ?? ""); setIsPublic(pd.profile.is_public); + setProfileExpanded(false); // already set up β start collapsed } setProducts(prods.items || []); setLoading(false); }).catch(() => setLoading(false)); }, []); + const profileUrl = typeof window !== "undefined" && slug ? `${window.location.origin}/m/${slug}` : ""; + async function saveProfile() { setSaving(true); setSaveMsg(""); @@ -75,13 +81,32 @@ export default function ProfileSettingsPage() { const d = await r.json(); if (r.ok) { setProfile(d.profile); - setSaveMsg(`Saved! View at /m/${d.profile.slug}`); + setSaveMsg("Saved!"); + setProfileExpanded(false); // collapse after save } else { setSaveMsg(d.error || "Save failed"); } setSaving(false); } + async function copyLink() { + if (!profileUrl) return; + await navigator.clipboard.writeText(profileUrl); + 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"); + } + + async function shareNative() { + if (navigator.share) { + await navigator.share({ title: `${displayName}'s baby picks`, url: profileUrl }); + } + } + function resetProductForm() { setPTitle(""); setPUrl(""); setPDesc(""); setPImageUrl(""); setPCategory("general"); setShowAddProduct(false); setEditingProduct(null); @@ -162,65 +187,93 @@ export default function ProfileSettingsPage() {
3β40 chars, lowercase letters, numbers, hyphens only
- )} - - -