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 =====