Spaces:
Sleeping
Sleeping
Update static/script.js
Browse files- static/script.js +23 -32
static/script.js
CHANGED
|
@@ -564,43 +564,34 @@ function promptAndSubmit(quantity) {
|
|
| 564 |
}
|
| 565 |
}
|
| 566 |
|
| 567 |
-
function
|
| 568 |
-
|
| 569 |
-
addMessage('bot', 'No items selected! Add some dishes! 😊');
|
| 570 |
-
showToast('No items selected');
|
| 571 |
-
return;
|
| 572 |
-
}
|
| 573 |
-
|
| 574 |
-
const itemsToSubmit = selectedItems.map(item => ({
|
| 575 |
-
name: item.name,
|
| 576 |
-
category: item.category || 'Not specified',
|
| 577 |
-
description: item.description || 'No description available',
|
| 578 |
-
image_url: item.image_url || '',
|
| 579 |
-
quantity: item.quantity || parseInt(quantity) || 1
|
| 580 |
-
}));
|
| 581 |
-
|
| 582 |
-
fetchWithRetry('/submit_items', {
|
| 583 |
method: 'POST',
|
| 584 |
headers: { 'Content-Type': 'application/json' },
|
| 585 |
-
body: JSON.stringify({
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
addMessage('bot', `Submission failed: ${data.error}. Try again?`);
|
| 590 |
-
showToast(`Submission failed: ${data.error}`);
|
| 591 |
-
} else {
|
| 592 |
-
addMessage('bot', `Order "${customOrderName || 'Order'}" with ${itemsToSubmit.length} items submitted! What's next?`);
|
| 593 |
-
selectedItems = [];
|
| 594 |
-
updateSelectionBox();
|
| 595 |
-
showToast('Order submitted successfully!');
|
| 596 |
-
}
|
| 597 |
})
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 602 |
}
|
| 603 |
|
|
|
|
| 604 |
function resetConversation() {
|
| 605 |
const userName = conversation.length > 1 ? conversation[1].message : 'Friend';
|
| 606 |
conversation = [
|
|
|
|
| 564 |
}
|
| 565 |
}
|
| 566 |
|
| 567 |
+
function submitCustomizedItem(menuItem, ingredients, instructions) {
|
| 568 |
+
fetch('/cart/add_custom', {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 569 |
method: 'POST',
|
| 570 |
headers: { 'Content-Type': 'application/json' },
|
| 571 |
+
body: JSON.stringify({
|
| 572 |
+
menu_item: menuItem,
|
| 573 |
+
ingredients: ingredients,
|
| 574 |
+
instructions: instructions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 575 |
})
|
| 576 |
+
})
|
| 577 |
+
.then(response => response.json())
|
| 578 |
+
.then(data => {
|
| 579 |
+
if (data.success) {
|
| 580 |
+
addMessage('bot', data.message);
|
| 581 |
+
showToast(data.message);
|
| 582 |
+
} else {
|
| 583 |
+
addMessage('bot', `Failed: ${data.error}`);
|
| 584 |
+
showToast(`Error: ${data.error}`);
|
| 585 |
+
}
|
| 586 |
+
})
|
| 587 |
+
.catch(err => {
|
| 588 |
+
console.error(err);
|
| 589 |
+
addMessage('bot', `Submission failed: ${err.message}`);
|
| 590 |
+
showToast('Submission failed');
|
| 591 |
+
});
|
| 592 |
}
|
| 593 |
|
| 594 |
+
|
| 595 |
function resetConversation() {
|
| 596 |
const userName = conversation.length > 1 ? conversation[1].message : 'Friend';
|
| 597 |
conversation = [
|