nagasurendra commited on
Commit
5fe6f92
·
verified ·
1 Parent(s): 04c45e0

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +2 -17
static/script.js CHANGED
@@ -355,28 +355,13 @@ function displayOptions(options) {
355
  options.forEach(opt => {
356
  const button = document.createElement('button');
357
  button.textContent = opt.text;
358
- button.className = `option-button ${opt.class}`;
359
  button.onclick = () => {
360
  addMessage('user', opt.text);
361
  conversation.push({ role: 'user', message: opt.text });
362
  chatMessages.innerHTML = '';
363
  conversation.forEach(msg => addMessage(msg.role, msg.message));
364
-
365
- if (opt.text === 'Yes') {
366
- // When 'Yes' is clicked, fetch both vegetarian and non-vegetarian ingredients
367
- fetchIngredients('both');
368
- } else if (opt.text === 'No') {
369
- // When 'No' is clicked, proceed as before (e.g., add item to cart)
370
- addToCart(selectedMenuItem);
371
- addMessage('bot', 'Item added to cart! Would you like to order more?');
372
- const options = [
373
- { text: 'Yes', class: 'green' },
374
- { text: 'No', class: 'red' }
375
- ];
376
- displayOptions(options);
377
- selectedMenuItem = null;
378
- selectedIngredients = [];
379
- }
380
  };
381
  chatMessages.appendChild(button);
382
  });
 
355
  options.forEach(opt => {
356
  const button = document.createElement('button');
357
  button.textContent = opt.text;
358
+ button.className = option-button ${opt.class};
359
  button.onclick = () => {
360
  addMessage('user', opt.text);
361
  conversation.push({ role: 'user', message: opt.text });
362
  chatMessages.innerHTML = '';
363
  conversation.forEach(msg => addMessage(msg.role, msg.message));
364
+ setTimeout(() => handleResponse(opt.text), 500);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  };
366
  chatMessages.appendChild(button);
367
  });