coderuday21 commited on
Commit
236cdf9
·
1 Parent(s): 064e77c

UX: show detection-type menu after auth then auto-redirect based on URL

Browse files
Files changed (2) hide show
  1. static/js/app.js +17 -4
  2. templates/index.html +1 -1
static/js/app.js CHANGED
@@ -81,8 +81,7 @@ document.getElementById('form-login')?.addEventListener('submit', async (e) => {
81
  const data = await api('POST', '/api/auth/login', { body: JSON.stringify({ email, password }) });
82
  setToken(data.access_token);
83
  document.getElementById('user-email').textContent = data.user.email;
84
- showView('dashboard');
85
- loadHistory();
86
  } catch (err) { showError('login-error', err.message); }
87
  });
88
 
@@ -96,11 +95,25 @@ document.getElementById('form-register')?.addEventListener('submit', async (e) =
96
  const data = await api('POST', '/api/auth/register', { body: JSON.stringify({ email, password, full_name }) });
97
  setToken(data.access_token);
98
  document.getElementById('user-email').textContent = data.user.email;
99
- showView('dashboard');
100
- loadHistory();
101
  } catch (err) { showError('register-error', err.message); }
102
  });
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  // ---- Forgot password ----
105
  document.getElementById('form-forgot')?.addEventListener('submit', async (e) => {
106
  e.preventDefault();
 
81
  const data = await api('POST', '/api/auth/login', { body: JSON.stringify({ email, password }) });
82
  setToken(data.access_token);
83
  document.getElementById('user-email').textContent = data.user.email;
84
+ handlePostAuthNavigation();
 
85
  } catch (err) { showError('login-error', err.message); }
86
  });
87
 
 
95
  const data = await api('POST', '/api/auth/register', { body: JSON.stringify({ email, password, full_name }) });
96
  setToken(data.access_token);
97
  document.getElementById('user-email').textContent = data.user.email;
98
+ handlePostAuthNavigation();
 
99
  } catch (err) { showError('register-error', err.message); }
100
  });
101
 
102
+ function handlePostAuthNavigation() {
103
+ const preferred = getDetectionTypeFromPath();
104
+ if (preferred) applyDetectionTypeToUI(preferred);
105
+ showView('detection-type');
106
+
107
+ // If user already chose a URL (/detect/change or /detect/landslide),
108
+ // then auto-redirect after the menu is shown.
109
+ if (preferred) {
110
+ setTimeout(() => {
111
+ showView('dashboard');
112
+ loadHistory();
113
+ }, 150);
114
+ }
115
+ }
116
+
117
  // ---- Forgot password ----
118
  document.getElementById('form-forgot')?.addEventListener('submit', async (e) => {
119
  e.preventDefault();
templates/index.html CHANGED
@@ -392,6 +392,6 @@
392
  </div>
393
  </div>
394
 
395
- <script src="/static/js/app.js?v=27"></script>
396
  </body>
397
  </html>
 
392
  </div>
393
  </div>
394
 
395
+ <script src="/static/js/app.js?v=28"></script>
396
  </body>
397
  </html>