From a2341dfa38d9328d97df7b5e07da0e9e9f8bdb83 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Tue, 7 Apr 2026 11:36:08 -0400 Subject: [PATCH] fix: show resume prompt on landing page, keep step 1 check as fallback Restore "Resume where you left off" on the landing page. When clicked, restores localStorage data and does an email lookup to show the welcome-back modal. Fresh starts still get the email check on step 1 as a fallback for existing applications. Co-Authored-By: Claude Opus 4.6 --- apply.html | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/apply.html b/apply.html index 3c42601..cac3240 100644 --- a/apply.html +++ b/apply.html @@ -580,6 +580,11 @@
This application takes approximately 15–20 minutes to complete.
+ + @@ -1081,16 +1086,35 @@ document.getElementById('landing-reg-price').innerHTML = `€${tierPricing.perWeek} – €${REGISTRATION_PRICING.lastMin.perWeek}/wk`; + // Show resume notice if there's saved progress + (function checkSavedProgress() { + const saved = localStorage.getItem(STORAGE_KEY); + if (saved) { + document.getElementById('resume-notice').style.display = 'block'; + } + })(); + function startForm() { document.getElementById('landing-screen').style.display = 'none'; document.getElementById('application-form').style.display = 'block'; document.getElementById('progress-container').style.display = 'block'; + currentStep = 1; + showStep(1); + } - // Silently restore any locally saved progress + async function startFormAndResume() { + document.getElementById('landing-screen').style.display = 'none'; + document.getElementById('application-form').style.display = 'block'; + document.getElementById('progress-container').style.display = 'block'; + + // Restore locally saved progress const saved = localStorage.getItem(STORAGE_KEY); + let email = null; if (saved) { try { - restoreFormData(JSON.parse(saved)); + const data = JSON.parse(saved); + restoreFormData(data); + email = data.email; } catch (e) { console.error('Failed to restore saved data:', e); } @@ -1098,6 +1122,27 @@ currentStep = 1; showStep(1); + + // If we have an email, check server for existing application + if (email) { + try { + const resp = await fetch('/api/application/lookup?email=' + encodeURIComponent(email)); + if (resp.ok) { + const result = await resp.json(); + if (result.found) { + if (result.application.payment_status === 'paid') { + alert('This email already has a completed (paid) application. Contact us at contact@valleyofthecommons.com if you need to make changes.'); + return; + } + window._pendingLookupData = result.application; + document.getElementById('welcome-back-heading').textContent = `Welcome back, ${result.application.first_name}!`; + document.getElementById('welcome-back-modal').classList.add('visible'); + } + } + } catch (e) { + console.error('Email lookup failed:', e); + } + } } // ===== Autosave =====