lokesh341 commited on
Commit
b0e8f81
·
verified ·
1 Parent(s): 905bdda

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +17 -14
templates/index.html CHANGED
@@ -121,8 +121,10 @@
121
  let response = event.results[0][0].transcript.trim().toLowerCase();
122
  recognition.stop();
123
  if (response.includes("new")) {
 
124
  captureEmail();
125
  } else if (response.includes("existing")) {
 
126
  captureEmail();
127
  } else {
128
  speak("I didn't understand. Please say 'new' for registration or 'existing' for login.", askLoginOrRegister);
@@ -152,20 +154,16 @@
152
  }
153
 
154
  function checkEmailExists(email) {
155
- fetch(`/check_email?email=${encodeURIComponent(email)}`)
156
- .then(response => response.json())
157
- .then(data => {
158
- if (data.exists) {
159
- speak("Welcome back! You are logged in.");
160
- document.getElementById('loginForm').style.display = 'block';
161
- document.getElementById('registrationForm').style.display = 'none';
162
- } else {
163
- speak("You are a new customer. Please proceed with registration.", showRegistrationForm);
164
- }
165
- })
166
- .catch(() => {
167
- speak("Error checking email. Please try again.");
168
- });
169
  }
170
 
171
  function showRegistrationForm() {
@@ -173,6 +171,11 @@
173
  document.getElementById('loginForm').style.display = 'none';
174
  }
175
 
 
 
 
 
 
176
  function captureMobile() {
177
  speak("Please say your 12-digit mobile number.", function () {
178
  recognition.start();
 
121
  let response = event.results[0][0].transcript.trim().toLowerCase();
122
  recognition.stop();
123
  if (response.includes("new")) {
124
+ showRegistrationForm();
125
  captureEmail();
126
  } else if (response.includes("existing")) {
127
+ showLoginForm();
128
  captureEmail();
129
  } else {
130
  speak("I didn't understand. Please say 'new' for registration or 'existing' for login.", askLoginOrRegister);
 
154
  }
155
 
156
  function checkEmailExists(email) {
157
+ // Simulate checking if email exists in Salesforce (you can replace this with an actual API call)
158
+ const existingEmails = ["existing@domain.com"];
159
+ if (existingEmails.includes(email)) {
160
+ speak("Welcome back! You are logged in.");
161
+ document.getElementById('loginForm').style.display = 'block';
162
+ document.getElementById('registrationForm').style.display = 'none';
163
+ } else {
164
+ speak("You are a new customer. Please proceed with registration.");
165
+ showRegistrationForm();
166
+ }
 
 
 
 
167
  }
168
 
169
  function showRegistrationForm() {
 
171
  document.getElementById('loginForm').style.display = 'none';
172
  }
173
 
174
+ function showLoginForm() {
175
+ document.getElementById('loginForm').style.display = 'block';
176
+ document.getElementById('registrationForm').style.display = 'none';
177
+ }
178
+
179
  function captureMobile() {
180
  speak("Please say your 12-digit mobile number.", function () {
181
  recognition.start();