From d912e0820cf089063f9c952e85fbced480780408 Mon Sep 17 00:00:00 2001 From: Sterling Archer Date: Thu, 18 Jun 2026 20:05:31 -0700 Subject: [PATCH] Add Copy Link button to invite modal --- index.html | 55 +- stepmates.html | 2564 ------------------------------------------------ 2 files changed, 47 insertions(+), 2572 deletions(-) delete mode 100644 stepmates.html diff --git a/index.html b/index.html index 320376d..9573663 100644 --- a/index.html +++ b/index.html @@ -1372,9 +1372,10 @@

Invite a Friend

Share this message with a friend. When they tap the link they'll be taken straight to StepMates.

- @@ -1521,6 +1522,11 @@ const _initialParams = new URLSearchParams(window.location.search); const _savedInviteToken = _initialParams.get('invite'); const _savedFromUid = _initialParams.get('from'); +if (_savedInviteToken && _savedFromUid) { + localStorage.setItem('pendingInviteToken', _savedInviteToken); + localStorage.setItem('pendingInviteFrom', _savedFromUid); +} + // ───────────────────────────────────────────── // INIT // ───────────────────────────────────────────── @@ -1559,8 +1565,15 @@ window.sendMagicLink = async function() { btn.disabled = true; btn.innerHTML = ' Sending…'; try { - const currentUrl = window.location.href.split('?')[0] + window.location.search; - const res = await fetch(`${window.STEPMATES_CONFIG.sendMagicLinkUrl}?email=${encodeURIComponent(email)}&continueUrl=${encodeURIComponent(currentUrl)}`); + const currentPageParams = new URLSearchParams(window.location.search); + const inviteToken = currentPageParams.get('invite') || localStorage.getItem('pendingInviteToken'); + const inviteFrom = currentPageParams.get('from') || localStorage.getItem('pendingInviteFrom'); + if (inviteToken && inviteFrom) { + localStorage.setItem('pendingInviteToken', inviteToken); + localStorage.setItem('pendingInviteFrom', inviteFrom); + localStorage.setItem('pendingInviteEmail', email); + } + const res = await fetch(`${window.STEPMATES_CONFIG.sendMagicLinkUrl}?email=${encodeURIComponent(email)}`); const data = await res.json(); if (!res.ok) throw new Error(data.error || 'Failed to send'); localStorage.setItem('emailForSignIn', email); @@ -2255,6 +2268,20 @@ window.closeInviteModalOutside = function(e) { if (e.target === document.getElementById('invite-modal')) closeInviteModal(); } +window.copyInviteLink = function() { + const url = document.getElementById('invite-modal').dataset.url; + navigator.clipboard.writeText(url); + const btn = document.getElementById('copy-invite-btn'); + btn.textContent = '✓ Copied!'; + btn.style.color = 'var(--success)'; + btn.style.borderColor = 'var(--success)'; + setTimeout(() => { + btn.textContent = 'Copy Link'; + btn.style.color = ''; + btn.style.borderColor = ''; + }, 2000); +} + window.shareInvite = function() { const msg = document.getElementById('invite-modal').dataset.msg; if (navigator.share) { @@ -2418,9 +2445,21 @@ window.saveProfile = async function() { // INVITE LINK HANDLER // ───────────────────────────────────────────── async function handleInviteLink() { - const inviteToken = _savedInviteToken; - const fromUid = _savedFromUid; - if (!inviteToken || !fromUid || fromUid === currentUser.uid) return; + const inviteToken = _savedInviteToken || localStorage.getItem('pendingInviteToken'); + const fromUid = _savedFromUid || localStorage.getItem('pendingInviteFrom'); + const inviteEmail = localStorage.getItem('pendingInviteEmail'); + if (!inviteToken || !fromUid || fromUid === currentUser.uid) { + localStorage.removeItem('pendingInviteToken'); + localStorage.removeItem('pendingInviteFrom'); + localStorage.removeItem('pendingInviteEmail'); + return; + } + if (inviteEmail && inviteEmail.toLowerCase() !== currentUser.email.toLowerCase()) { + return; + } + localStorage.removeItem('pendingInviteToken'); + localStorage.removeItem('pendingInviteFrom'); + localStorage.removeItem('pendingInviteEmail'); try { const inviteRef = doc(db, 'invites', inviteToken); const inviteSnap = await getDoc(inviteRef); diff --git a/stepmates.html b/stepmates.html deleted file mode 100644 index b538c4d..0000000 --- a/stepmates.html +++ /dev/null @@ -1,2564 +0,0 @@ - - - - - - - - -StepMates — Walk Together - - - - - - -
- - -
-
-
- Loading… -
-
- - -
-
- -

Walk more. Compete with friends.

-
-

Welcome

-

Enter your email to sign in or create an account — no password needed.

- - - - -
- -
-
- - -
-
-
-
✉️
-

Confirm your email

-

You opened this link on a different device. Enter your email to complete sign-in.

- - - - -
-
-
- - -
-
-
⏳
-

Waiting for approval

-

Your account request has been sent to the administrator. You'll be able to sign in once it's approved.

- -
-
- - -
-
-
-
-
-
-
- - -
-

What should friends call you?

-

Choose a display name. This is what your friends will see.

- - - - -
- - -
-

Sync your steps automatically

-

Download the free bridge app for your phone. It reads your steps from Apple Health or Android Health and sends them here.

- -
- 💡 Once installed, the app will ask for a Webhook URL — you'll get yours on the next screen. -
- -

- -
- - -
-

Your personal sync URL

-

Copy this URL and paste it into the bridge app. Your steps will sync automatically from that point on.

-
-
Your Webhook URL
-
-
Generating…
- -
-
- -
-

Where to paste it:

-
- iPhone (Health Auto Export):
- Automations → New Automation → Webhook → paste URL → select Steps → set schedule Daily

- Android (HC Webhook):
- Add Webhook → paste URL → enable Steps → set sync interval -
-
- -
-
-
- - -
- - - - - -
- - -
- - - - - -
- - -
-
My Steps — Today
-
—
-
Loading…
-
-
-
-
- 0 - Goal: 5,000 -
-
- - - - - - - - -
-
- - -
- - - - - -
-
My Friends
- -
- -
- - -
- -
- - - -
- -
- - - - - - -
- - -
-
-
Sync Setup
-
- -
- Paste your Webhook URL into the bridge app on your phone. Steps will sync automatically. -
- -
Your Webhook URL
-
-
-
Loading…
- -
-
- -
- iPhone — Health Auto Export:
- Automations → New Automation → Webhook → paste URL
- Select Steps → set to run Daily

- Android — HC Webhook:
- Download from GitHub → Add Webhook → paste URL
- Enable Steps → set sync interval -
- -
-
Bridge App Downloads
-
- - -
-
Account
-
-
-
-
- ? -
-
-
—
-
-
- -
-
- -
- -
- -
- - - - - -
- -
-
-
-
- — - ✏️ -
- -
- -
-
- Joined StepMates - — -
-
- Avg. steps per day - — -
-
- - -
-
- - - - - - - - - -
- -
↓ Refreshing…
- -
- - - - - - -