nagasurendra commited on
Commit
4298625
·
verified ·
1 Parent(s): 6b37621

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +5 -1
static/script.js CHANGED
@@ -550,6 +550,7 @@ function promptAndSubmit(quantity) {
550
  const orderNameInput = document.querySelector('.order-name-input');
551
  const customOrderName = orderNameInput ? orderNameInput.value.trim() : '';
552
  const qty = parseInt(quantity);
 
553
  if (isNaN(qty) || qty <= 0) {
554
  addMessage('bot', 'Please enter a valid quantity (1 or more)!');
555
  showToast('Invalid quantity!');
@@ -565,7 +566,7 @@ function promptAndSubmit(quantity) {
565
  const item = selectedItems[0];
566
 
567
  if (confirm(`Submit "${item.name}" with quantity ${qty}?`)) {
568
- const instructions = prompt('Any special instructions?', '') || '';
569
  item.quantity = qty;
570
 
571
  submitCustomizedItem(item, item.ingredients || [], instructions);
@@ -577,6 +578,7 @@ function promptAndSubmit(quantity) {
577
  }
578
 
579
 
 
580
  function submitCustomizedItem(menuItem, ingredients, instructions) {
581
  fetch('/cart/add_custom', {
582
  method: 'POST',
@@ -592,6 +594,8 @@ function submitCustomizedItem(menuItem, ingredients, instructions) {
592
  if (data.success) {
593
  addMessage('bot', data.message);
594
  showToast(data.message);
 
 
595
  } else {
596
  addMessage('bot', `Failed: ${data.error}`);
597
  showToast(`Error: ${data.error}`);
 
550
  const orderNameInput = document.querySelector('.order-name-input');
551
  const customOrderName = orderNameInput ? orderNameInput.value.trim() : '';
552
  const qty = parseInt(quantity);
553
+
554
  if (isNaN(qty) || qty <= 0) {
555
  addMessage('bot', 'Please enter a valid quantity (1 or more)!');
556
  showToast('Invalid quantity!');
 
566
  const item = selectedItems[0];
567
 
568
  if (confirm(`Submit "${item.name}" with quantity ${qty}?`)) {
569
+ const instructions = item.instructions || prompt('Any special instructions?', '') || '';
570
  item.quantity = qty;
571
 
572
  submitCustomizedItem(item, item.ingredients || [], instructions);
 
578
  }
579
 
580
 
581
+
582
  function submitCustomizedItem(menuItem, ingredients, instructions) {
583
  fetch('/cart/add_custom', {
584
  method: 'POST',
 
594
  if (data.success) {
595
  addMessage('bot', data.message);
596
  showToast(data.message);
597
+ selectedItems = [];
598
+ updateSelectionBox();
599
  } else {
600
  addMessage('bot', `Failed: ${data.error}`);
601
  showToast(`Error: ${data.error}`);