Spaces:
Sleeping
Sleeping
Update templates/chef-bot.html
Browse files- templates/chef-bot.html +207 -412
templates/chef-bot.html
CHANGED
@@ -225,7 +225,7 @@
|
|
225 |
.option-button.gray { background-color: #616161; }
|
226 |
.option-button:active { opacity: 0.9; }
|
227 |
|
228 |
-
.selection-box {
|
229 |
background-color: #e1f5fe;
|
230 |
padding: 8px;
|
231 |
border: 1px solid #0288d1;
|
@@ -238,7 +238,7 @@
|
|
238 |
gap: 5px;
|
239 |
}
|
240 |
|
241 |
-
.selection-box span {
|
242 |
background-color: #bbdefb;
|
243 |
padding: 3px 8px;
|
244 |
border-radius: 5px;
|
@@ -262,7 +262,7 @@
|
|
262 |
margin-right: 5px;
|
263 |
}
|
264 |
|
265 |
-
.submit-button {
|
266 |
padding: 6px 10px;
|
267 |
background-color: #0288d1;
|
268 |
color: white;
|
@@ -273,7 +273,7 @@
|
|
273 |
min-width: 60px;
|
274 |
}
|
275 |
|
276 |
-
.submit-button:active {
|
277 |
background-color: #0277bd;
|
278 |
}
|
279 |
|
@@ -292,7 +292,7 @@
|
|
292 |
background-color: #b71c1c;
|
293 |
}
|
294 |
|
295 |
-
.manual-input {
|
296 |
padding: 4px;
|
297 |
border: 1px solid #0288d1;
|
298 |
border-radius: 5px;
|
@@ -300,15 +300,6 @@
|
|
300 |
width: 100px;
|
301 |
}
|
302 |
|
303 |
-
.ingredient-input {
|
304 |
-
padding: 4px;
|
305 |
-
border: 1px solid #0288d1;
|
306 |
-
border-radius: 5px;
|
307 |
-
font-size: 12px;
|
308 |
-
width: 100px;
|
309 |
-
margin-left: 5px;
|
310 |
-
}
|
311 |
-
|
312 |
.quantity-input {
|
313 |
padding: 4px;
|
314 |
border: 1px solid #0288d1;
|
@@ -326,173 +317,50 @@
|
|
326 |
}
|
327 |
|
328 |
@media (max-width: 480px) {
|
329 |
-
.chat-header {
|
330 |
-
|
331 |
-
|
332 |
-
}
|
333 |
-
.chat-
|
334 |
-
|
335 |
-
}
|
336 |
-
.
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
}
|
341 |
-
.
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
}
|
346 |
-
.
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
min-width: 50px;
|
351 |
-
}
|
352 |
-
.items-grid {
|
353 |
-
flex-direction: column;
|
354 |
-
overflow-x: hidden;
|
355 |
-
gap: 6px;
|
356 |
-
padding: 6px;
|
357 |
-
}
|
358 |
-
.item-card {
|
359 |
-
width: 100%;
|
360 |
-
flex: 0 0 auto;
|
361 |
-
max-width: 120px;
|
362 |
-
}
|
363 |
-
.item-image {
|
364 |
-
height: 80px;
|
365 |
-
}
|
366 |
-
.item-name {
|
367 |
-
font-size: 10px;
|
368 |
-
}
|
369 |
-
.item-field, .item-description {
|
370 |
-
font-size: 9px;
|
371 |
-
}
|
372 |
-
.show-button, .add-button {
|
373 |
-
font-size: 9px;
|
374 |
-
padding: 3px;
|
375 |
-
min-width: 35px;
|
376 |
-
}
|
377 |
-
.options-container {
|
378 |
-
gap: 3px;
|
379 |
-
}
|
380 |
-
.option-button {
|
381 |
-
font-size: 11px;
|
382 |
-
padding: 5px 8px;
|
383 |
-
min-width: 50px;
|
384 |
-
}
|
385 |
-
.selection-box {
|
386 |
-
padding: 6px;
|
387 |
-
gap: 3px;
|
388 |
-
}
|
389 |
-
.selection-box span {
|
390 |
-
font-size: 11px;
|
391 |
-
padding: 2px 6px;
|
392 |
-
}
|
393 |
-
.selected-item {
|
394 |
-
font-size: 10px;
|
395 |
-
padding: 2px 6px;
|
396 |
-
}
|
397 |
-
.selected-item-image {
|
398 |
-
width: 20px;
|
399 |
-
height: 20px;
|
400 |
-
}
|
401 |
-
.submit-button {
|
402 |
-
font-size: 11px;
|
403 |
-
padding: 5px 8px;
|
404 |
-
min-width: 50px;
|
405 |
-
}
|
406 |
-
.remove-button {
|
407 |
-
font-size: 9px;
|
408 |
-
padding: 2px 5px;
|
409 |
-
}
|
410 |
-
.manual-input, .order-name-input, .ingredient-input {
|
411 |
-
width: 80px;
|
412 |
-
font-size: 11px;
|
413 |
-
padding: 3px;
|
414 |
-
}
|
415 |
-
.quantity-input {
|
416 |
-
width: 40px;
|
417 |
-
font-size: 11px;
|
418 |
-
padding: 3px;
|
419 |
-
}
|
420 |
}
|
421 |
|
422 |
@media (min-width: 481px) and (max-width: 768px) {
|
423 |
-
.chat-header {
|
424 |
-
|
425 |
-
}
|
426 |
-
.chat-
|
427 |
-
|
428 |
-
}
|
429 |
-
.
|
430 |
-
|
431 |
-
|
432 |
-
}
|
433 |
-
.
|
434 |
-
|
435 |
-
|
436 |
-
}
|
437 |
-
.
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
}
|
442 |
-
.
|
443 |
-
gap: 8px;
|
444 |
-
}
|
445 |
-
.item-card {
|
446 |
-
flex: 0 0 140px;
|
447 |
-
}
|
448 |
-
.item-image {
|
449 |
-
height: 90px;
|
450 |
-
}
|
451 |
-
.item-name {
|
452 |
-
font-size: 11px;
|
453 |
-
}
|
454 |
-
.item-field, .item-description {
|
455 |
-
font-size: 10px;
|
456 |
-
}
|
457 |
-
.show-button, .add-button {
|
458 |
-
font-size: 10px;
|
459 |
-
padding: 4px;
|
460 |
-
min-width: 40px;
|
461 |
-
}
|
462 |
-
.option-button {
|
463 |
-
font-size: 12px;
|
464 |
-
padding: 6px 10px;
|
465 |
-
}
|
466 |
-
.selection-box {
|
467 |
-
padding: 8px;
|
468 |
-
gap: 5px;
|
469 |
-
}
|
470 |
-
.selection-box span {
|
471 |
-
font-size: 12px;
|
472 |
-
}
|
473 |
-
.selected-item {
|
474 |
-
font-size: 11px;
|
475 |
-
}
|
476 |
-
.selected-item-image {
|
477 |
-
width: 25px;
|
478 |
-
height: 25px;
|
479 |
-
}
|
480 |
-
.submit-button {
|
481 |
-
font-size: 12px;
|
482 |
-
padding: 6px 10px;
|
483 |
-
}
|
484 |
-
.remove-button {
|
485 |
-
font-size: 10px;
|
486 |
-
padding: 3px 6px;
|
487 |
-
}
|
488 |
-
.manual-input, .order-name-input, .ingredient-input {
|
489 |
-
width: 100px;
|
490 |
-
font-size: 12px;
|
491 |
-
}
|
492 |
-
.quantity-input {
|
493 |
-
width: 50px;
|
494 |
-
font-size: 12px;
|
495 |
-
}
|
496 |
}
|
497 |
</style>
|
498 |
</head>
|
@@ -513,8 +381,8 @@
|
|
513 |
{ role: 'bot', message: 'Hello! I’m Chef Bot, your culinary assistant! What’s your name?' }
|
514 |
];
|
515 |
let selectedItems = [];
|
|
|
516 |
let selectionBoxVisible = false;
|
517 |
-
let currentDietaryPreference = '';
|
518 |
|
519 |
function addMessage(role, message) {
|
520 |
const chatMessages = document.getElementById('chatMessages');
|
@@ -547,6 +415,7 @@
|
|
547 |
}
|
548 |
userInput.value = '';
|
549 |
updateSelectionBox();
|
|
|
550 |
}
|
551 |
|
552 |
function handleResponse(userInput) {
|
@@ -554,7 +423,7 @@
|
|
554 |
let botResponse = '';
|
555 |
|
556 |
if (conversation.length === 2) {
|
557 |
-
botResponse = `Hi ${userInput}! 🍳
|
558 |
displayOptions([
|
559 |
{ text: 'Vegetarian', class: 'green' },
|
560 |
{ text: 'Non-Vegetarian', class: 'red' },
|
@@ -562,14 +431,13 @@
|
|
562 |
]);
|
563 |
addMessage('bot', botResponse);
|
564 |
} else if (lowerInput === 'vegetarian' || lowerInput === 'non-vegetarian' || lowerInput === 'both') {
|
565 |
-
|
566 |
-
botResponse = `Fetching ${lowerInput} dishes...`;
|
567 |
addMessage('bot', botResponse);
|
568 |
fetchMenuItems(lowerInput);
|
569 |
} else {
|
570 |
-
botResponse = `Looking for "${userInput}"...`;
|
571 |
addMessage('bot', botResponse);
|
572 |
-
fetchMenuItems(
|
573 |
}
|
574 |
}
|
575 |
|
@@ -585,151 +453,7 @@
|
|
585 |
const selectionBox = document.createElement('div');
|
586 |
selectionBox.className = 'selection-box';
|
587 |
|
588 |
-
|
589 |
-
vegButton.textContent = 'Veg';
|
590 |
-
vegButton.className = 'dietary-button green';
|
591 |
-
vegButton.onclick = () => {
|
592 |
-
addMessage('user', 'Vegetarian');
|
593 |
-
conversation.push({ role: 'user', message: 'Vegetarian' });
|
594 |
-
handleResponse('vegetarian');
|
595 |
-
};
|
596 |
-
selectionBox.appendChild(vegButton);
|
597 |
-
|
598 |
-
const nonVegButton = document.createElement('button');
|
599 |
-
nonVegButton.textContent = 'Non-Veg';
|
600 |
-
nonVegButton.className = 'dietary-button red';
|
601 |
-
nonVegButton.onclick = () => {
|
602 |
-
addMessage('user', 'Non-Vegetarian');
|
603 |
-
conversation.push({ role: 'user', message: 'Non-Vegetarian' });
|
604 |
-
handleResponse('non-vegetarian');
|
605 |
-
};
|
606 |
-
selectionBox.appendChild(nonVegButton);
|
607 |
-
|
608 |
-
const bothButton = document.createElement('button');
|
609 |
-
bothButton.textContent = 'Both';
|
610 |
-
bothButton.className = 'dietary-button gray';
|
611 |
-
bothButton.onclick = () => {
|
612 |
-
addMessage('user', 'Both');
|
613 |
-
conversation.push({ role: 'user', message: 'Both' });
|
614 |
-
handleResponse('both');
|
615 |
-
};
|
616 |
-
selectionBox.appendChild(bothButton);
|
617 |
-
|
618 |
-
const label = document.createElement('span');
|
619 |
-
label.textContent = 'Selected:';
|
620 |
-
selectionBox.appendChild(label);
|
621 |
-
|
622 |
-
selectedItems.forEach((item, index) => {
|
623 |
-
const itemContainer = document.createElement('div');
|
624 |
-
itemContainer.className = 'selected-item';
|
625 |
-
itemContainer.dataset.hidden = item.source === 'Sector_Detail__c' ? 'true' : 'false';
|
626 |
-
|
627 |
-
const img = document.createElement('img');
|
628 |
-
img.src = item.image_url || 'https://via.placeholder.com/30';
|
629 |
-
img.alt = item.name;
|
630 |
-
img.className = 'selected-item-image';
|
631 |
-
itemContainer.appendChild(img);
|
632 |
-
|
633 |
-
const contentDiv = document.createElement('div');
|
634 |
-
contentDiv.className = 'selected-item-content';
|
635 |
-
|
636 |
-
const itemName = item.additionalIngredients && item.additionalIngredients.length > 0
|
637 |
-
? `${item.name} with ${item.additionalIngredients.join(', ')}`
|
638 |
-
: item.name;
|
639 |
-
const itemSpan = document.createElement('span');
|
640 |
-
itemSpan.textContent = `${itemName} (Qty: ${item.quantity || 1})`;
|
641 |
-
contentDiv.appendChild(itemSpan);
|
642 |
-
|
643 |
-
if (item.source === 'Sector_Detail__c') {
|
644 |
-
const showButton = document.createElement('button');
|
645 |
-
showButton.textContent = 'Show';
|
646 |
-
showButton.className = 'show-button';
|
647 |
-
showButton.onclick = () => toggleDescription(itemContainer, item.description, itemName);
|
648 |
-
contentDiv.appendChild(showButton);
|
649 |
-
}
|
650 |
-
|
651 |
-
const ingredientInput = document.createElement('input');
|
652 |
-
ingredientInput.type = 'text';
|
653 |
-
ingredientInput.placeholder = 'Add ingredient...';
|
654 |
-
ingredientInput.className = 'ingredient-input';
|
655 |
-
ingredientInput.addEventListener('keypress', (e) => {
|
656 |
-
if (e.key === 'Enter' && ingredientInput.value.trim()) {
|
657 |
-
const ingredientName = ingredientInput.value.trim();
|
658 |
-
fetchSectorItemDetails(ingredientName, index);
|
659 |
-
ingredientInput.value = '';
|
660 |
-
}
|
661 |
-
});
|
662 |
-
contentDiv.appendChild(ingredientInput);
|
663 |
-
|
664 |
-
itemContainer.appendChild(contentDiv);
|
665 |
-
|
666 |
-
const removeButton = document.createElement('button');
|
667 |
-
removeButton.textContent = 'X';
|
668 |
-
removeButton.className = 'remove-button';
|
669 |
-
removeButton.onclick = () => {
|
670 |
-
selectedItems.splice(index, 1);
|
671 |
-
addMessage('bot', `Removed "${itemName}".`);
|
672 |
-
updateSelectionBox();
|
673 |
-
};
|
674 |
-
itemContainer.appendChild(removeButton);
|
675 |
-
|
676 |
-
selectionBox.appendChild(itemContainer);
|
677 |
-
|
678 |
-
if (item.additionalIngredients && item.additionalIngredients.length > 0) {
|
679 |
-
const originalContainer = document.createElement('div');
|
680 |
-
originalContainer.className = 'selected-item';
|
681 |
-
originalContainer.dataset.hidden = item.source === 'Sector_Detail__c' ? 'true' : 'false';
|
682 |
-
|
683 |
-
const originalImg = document.createElement('img');
|
684 |
-
originalImg.src = item.image_url || 'https://via.placeholder.com/30';
|
685 |
-
originalImg.alt = item.name;
|
686 |
-
originalImg.className = 'selected-item-image';
|
687 |
-
originalContainer.appendChild(originalImg);
|
688 |
-
|
689 |
-
const originalContentDiv = document.createElement('div');
|
690 |
-
originalContentDiv.className = 'selected-item-content';
|
691 |
-
|
692 |
-
const originalSpan = document.createElement('span');
|
693 |
-
originalSpan.textContent = `${item.name} (Qty: ${item.quantity || 1})`;
|
694 |
-
originalContentDiv.appendChild(originalSpan);
|
695 |
-
|
696 |
-
if (item.source === 'Sector_Detail__c') {
|
697 |
-
const originalShowButton = document.createElement('button');
|
698 |
-
originalShowButton.textContent = 'Show';
|
699 |
-
originalShowButton.className = 'show-button';
|
700 |
-
originalShowButton.onclick = () => toggleDescription(originalContainer, item.description, item.name);
|
701 |
-
originalContentDiv.appendChild(originalShowButton);
|
702 |
-
}
|
703 |
-
|
704 |
-
const originalIngredientInput = document.createElement('input');
|
705 |
-
originalIngredientInput.type = 'text';
|
706 |
-
originalIngredientInput.placeholder = 'Add ingredient...';
|
707 |
-
originalIngredientInput.className = 'ingredient-input';
|
708 |
-
originalIngredientInput.addEventListener('keypress', (e) => {
|
709 |
-
if (e.key === 'Enter' && originalIngredientInput.value.trim()) {
|
710 |
-
const ingredientName = originalIngredientInput.value.trim();
|
711 |
-
fetchSectorItemDetails(ingredientName, index);
|
712 |
-
originalIngredientInput.value = '';
|
713 |
-
}
|
714 |
-
});
|
715 |
-
originalContentDiv.appendChild(originalIngredientInput);
|
716 |
-
|
717 |
-
originalContainer.appendChild(originalContentDiv);
|
718 |
-
|
719 |
-
const originalRemoveButton = document.createElement('button');
|
720 |
-
originalRemoveButton.textContent = 'X';
|
721 |
-
originalRemoveButton.className = 'remove-button';
|
722 |
-
originalRemoveButton.onclick = () => {
|
723 |
-
selectedItems.splice(index, 1);
|
724 |
-
addMessage('bot', `Removed "${item.name}".`);
|
725 |
-
updateSelectionBox();
|
726 |
-
};
|
727 |
-
originalContainer.appendChild(originalRemoveButton);
|
728 |
-
|
729 |
-
selectionBox.appendChild(originalContainer);
|
730 |
-
}
|
731 |
-
});
|
732 |
-
|
733 |
const textInput = document.createElement('input');
|
734 |
textInput.type = 'text';
|
735 |
textInput.placeholder = 'Add item...';
|
@@ -739,13 +463,78 @@
|
|
739 |
const itemName = textInput.value.trim();
|
740 |
addMessage('user', itemName);
|
741 |
conversation.push({ role: 'user', message: itemName });
|
742 |
-
|
743 |
textInput.value = '';
|
744 |
}
|
745 |
});
|
746 |
selectionBox.appendChild(textInput);
|
747 |
|
|
|
748 |
if (selectedItems.length > 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
749 |
const quantityInput = document.createElement('input');
|
750 |
quantityInput.type = 'number';
|
751 |
quantityInput.min = '1';
|
@@ -754,12 +543,6 @@
|
|
754 |
quantityInput.className = 'quantity-input';
|
755 |
selectionBox.appendChild(quantityInput);
|
756 |
|
757 |
-
const submitButton = document.createElement('button');
|
758 |
-
submitButton.textContent = 'Submit';
|
759 |
-
submitButton.className = 'submit-button';
|
760 |
-
submitButton.onclick = () => promptAndSubmit(quantityInput.value);
|
761 |
-
selectionBox.appendChild(submitButton);
|
762 |
-
|
763 |
const orderNameInput = document.createElement('input');
|
764 |
orderNameInput.type = 'text';
|
765 |
orderNameInput.placeholder = 'Order Name';
|
@@ -772,11 +555,61 @@
|
|
772 |
console.log('Updated selection box:', selectedItems.map(item => ({ name: item.name, additionalIngredients: item.additionalIngredients })));
|
773 |
}
|
774 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
775 |
function fetchMenuItems(dietaryPreference = '', searchTerm = '') {
|
776 |
const payload = {};
|
777 |
if (dietaryPreference) payload.dietary_preference = dietaryPreference;
|
778 |
if (searchTerm) payload.search_term = searchTerm;
|
779 |
-
fetch('/get_menu_items', {
|
780 |
method: 'POST',
|
781 |
headers: { 'Content-Type': 'application/json' },
|
782 |
body: JSON.stringify(payload)
|
@@ -799,6 +632,30 @@
|
|
799 |
});
|
800 |
}
|
801 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
802 |
function fetchSectorItemDetails(itemName, itemIndex = null) {
|
803 |
fetch('/get_sector_item_details', {
|
804 |
method: 'POST',
|
@@ -811,15 +668,6 @@
|
|
811 |
addMessage('bot', `No "${itemName}" found in Sector_Detail__c. Try another!`);
|
812 |
} else {
|
813 |
const details = data.item_details;
|
814 |
-
// Validate dietary preference
|
815 |
-
if (currentDietaryPreference === 'vegetarian' && details.category !== 'Veg') {
|
816 |
-
addMessage('bot', `"${details.name}" is not vegetarian. Please choose a vegetarian item.`);
|
817 |
-
return;
|
818 |
-
}
|
819 |
-
if (currentDietaryPreference === 'non-vegetarian' && details.category !== 'Non-Veg') {
|
820 |
-
addMessage('bot', `"${details.name}" is not non-vegetarian. Please choose a non-vegetarian item.`);
|
821 |
-
return;
|
822 |
-
}
|
823 |
if (itemIndex !== null) {
|
824 |
if (!selectedItems[itemIndex].additionalIngredients) {
|
825 |
selectedItems[itemIndex].additionalIngredients = [];
|
@@ -848,22 +696,6 @@
|
|
848 |
});
|
849 |
}
|
850 |
|
851 |
-
function toggleDescription(itemContainer, description, itemName) {
|
852 |
-
let descElement = itemContainer.querySelector('.item-description');
|
853 |
-
if (!descElement) {
|
854 |
-
descElement = document.createElement('p');
|
855 |
-
descElement.className = 'item-description';
|
856 |
-
descElement.textContent = description;
|
857 |
-
itemContainer.querySelector('.selected-item-content').appendChild(descElement);
|
858 |
-
itemContainer.dataset.hidden = 'false';
|
859 |
-
console.log(`Showed description for ${itemName}`);
|
860 |
-
} else {
|
861 |
-
descElement.remove();
|
862 |
-
itemContainer.dataset.hidden = 'true';
|
863 |
-
console.log(`Hid description for ${itemName}`);
|
864 |
-
}
|
865 |
-
}
|
866 |
-
|
867 |
function displayItemsList(items) {
|
868 |
const chatMessages = document.getElementById('chatMessages');
|
869 |
if (!chatMessages) {
|
@@ -872,25 +704,10 @@
|
|
872 |
return;
|
873 |
}
|
874 |
|
875 |
-
// Filter items based on dietary preference
|
876 |
-
const filteredItems = items.filter(item => {
|
877 |
-
if (currentDietaryPreference === 'vegetarian') {
|
878 |
-
return item.veg_nonveg === 'Vegetarian' || item.category === 'Veg';
|
879 |
-
} else if (currentDietaryPreference === 'non-vegetarian') {
|
880 |
-
return item.veg_nonveg === 'Non-Vegetarian' || item.category === 'Non-Veg';
|
881 |
-
}
|
882 |
-
return true;
|
883 |
-
});
|
884 |
-
|
885 |
-
if (filteredItems.length === 0) {
|
886 |
-
addMessage('bot', `No ${currentDietaryPreference} items found. Try another search!`);
|
887 |
-
return;
|
888 |
-
}
|
889 |
-
|
890 |
const itemsGrid = document.createElement('div');
|
891 |
itemsGrid.className = 'items-grid';
|
892 |
|
893 |
-
|
894 |
const itemDiv = document.createElement('div');
|
895 |
itemDiv.className = 'item-card';
|
896 |
|
@@ -993,18 +810,20 @@
|
|
993 |
optionsDiv.appendChild(button);
|
994 |
});
|
995 |
|
996 |
-
const backButton = document.createElement('button');
|
997 |
-
backButton.textContent = 'Back';
|
998 |
-
backButton.className = 'option-button';
|
999 |
-
backButton.onclick = () => resetConversation();
|
1000 |
-
optionsDiv.appendChild(backButton);
|
1001 |
-
|
1002 |
chatMessages.appendChild(optionsDiv);
|
1003 |
}
|
1004 |
|
1005 |
-
function promptAndSubmit(
|
1006 |
const orderNameInput = document.querySelector('.order-name-input');
|
|
|
1007 |
const customOrderName = orderNameInput ? orderNameInput.value.trim() : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1008 |
if (confirm(`Submit ${selectedItems.length} items (Qty: ${quantity})?`)) {
|
1009 |
submitToSalesforce(customOrderName, quantity);
|
1010 |
} else {
|
@@ -1013,11 +832,6 @@
|
|
1013 |
}
|
1014 |
|
1015 |
function submitToSalesforce(customOrderName, quantity) {
|
1016 |
-
if (selectedItems.length === 0) {
|
1017 |
-
addMessage('bot', 'No items selected! Add some dishes! 😊');
|
1018 |
-
return;
|
1019 |
-
}
|
1020 |
-
|
1021 |
const itemsToSubmit = selectedItems.map(item => ({
|
1022 |
name: item.additionalIngredients && item.additionalIngredients.length > 0
|
1023 |
? `${item.name} with ${item.additionalIngredients.join(', ')}`
|
@@ -1025,7 +839,7 @@
|
|
1025 |
category: item.category || 'Not specified',
|
1026 |
description: item.description || 'No description available',
|
1027 |
image_url: item.image_url || '',
|
1028 |
-
quantity:
|
1029 |
additionalIngredients: item.additionalIngredients || []
|
1030 |
}));
|
1031 |
|
@@ -1040,8 +854,10 @@
|
|
1040 |
addMessage('bot', `Submission failed: ${data.error}. Try again?`);
|
1041 |
} else {
|
1042 |
addMessage('bot', `Submitted ${data.ingredient_name}! What's next?`);
|
|
|
1043 |
selectedItems = [];
|
1044 |
updateSelectionBox();
|
|
|
1045 |
}
|
1046 |
})
|
1047 |
.catch(error => {
|
@@ -1050,27 +866,6 @@
|
|
1050 |
});
|
1051 |
}
|
1052 |
|
1053 |
-
function resetConversation() {
|
1054 |
-
const userName = conversation.length > 1 ? conversation[1].message : 'Friend';
|
1055 |
-
conversation = [
|
1056 |
-
{ role: 'bot', message: `Hello! I’m Chef Bot, your culinary assistant! What’s your name?` },
|
1057 |
-
{ role: 'user', message: userName },
|
1058 |
-
{ role: 'bot', message: `Hi ${userName}! 🍳 Please choose a dietary preference: Vegetarian, Non-Vegetarian, or Both.` }
|
1059 |
-
];
|
1060 |
-
selectedItems = [];
|
1061 |
-
currentDietaryPreference = '';
|
1062 |
-
selectionBoxVisible = true;
|
1063 |
-
const chatMessages = document.getElementById('chatMessages');
|
1064 |
-
chatMessages.innerHTML = '';
|
1065 |
-
conversation.forEach(msg => addMessage(msg.role, msg.message));
|
1066 |
-
displayOptions([
|
1067 |
-
{ text: 'Vegetarian', class: 'green' },
|
1068 |
-
{ text: 'Non-Vegetarian', class: 'red' },
|
1069 |
-
{ text: 'Both', class: 'gray' }
|
1070 |
-
]);
|
1071 |
-
updateSelectionBox();
|
1072 |
-
}
|
1073 |
-
|
1074 |
document.getElementById('userInput').addEventListener('keypress', (e) => {
|
1075 |
if (e.key === 'Enter') sendMessage();
|
1076 |
});
|
|
|
225 |
.option-button.gray { background-color: #616161; }
|
226 |
.option-button:active { opacity: 0.9; }
|
227 |
|
228 |
+
.selection-box, .submission-box {
|
229 |
background-color: #e1f5fe;
|
230 |
padding: 8px;
|
231 |
border: 1px solid #0288d1;
|
|
|
238 |
gap: 5px;
|
239 |
}
|
240 |
|
241 |
+
.selection-box span, .submission-box span {
|
242 |
background-color: #bbdefb;
|
243 |
padding: 3px 8px;
|
244 |
border-radius: 5px;
|
|
|
262 |
margin-right: 5px;
|
263 |
}
|
264 |
|
265 |
+
.submit-button, .both-button {
|
266 |
padding: 6px 10px;
|
267 |
background-color: #0288d1;
|
268 |
color: white;
|
|
|
273 |
min-width: 60px;
|
274 |
}
|
275 |
|
276 |
+
.submit-button:active, .both-button:active {
|
277 |
background-color: #0277bd;
|
278 |
}
|
279 |
|
|
|
292 |
background-color: #b71c1c;
|
293 |
}
|
294 |
|
295 |
+
.manual-input, .ingredient-input {
|
296 |
padding: 4px;
|
297 |
border: 1px solid #0288d1;
|
298 |
border-radius: 5px;
|
|
|
300 |
width: 100px;
|
301 |
}
|
302 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
.quantity-input {
|
304 |
padding: 4px;
|
305 |
border: 1px solid #0288d1;
|
|
|
317 |
}
|
318 |
|
319 |
@media (max-width: 480px) {
|
320 |
+
.chat-header { font-size: 14px; padding: 6px; }
|
321 |
+
.chat-messages { padding: 3px; }
|
322 |
+
.bot-message, .user-message { font-size: 11px; padding: 6px; margin: 3px 0; }
|
323 |
+
.chat-input input { font-size: 11px; min-height: 30px; padding: 5px; }
|
324 |
+
.chat-input button { font-size: 11px; min-height: 30px; padding: 5px 8px; min-width: 50px; }
|
325 |
+
.items-grid { flex-direction: column; overflow-x: hidden; gap: 6px; padding: 6px; }
|
326 |
+
.item-card { width: 100%; flex: 0 0 auto; max-width: 120px; }
|
327 |
+
.item-image { height: 80px; }
|
328 |
+
.item-name { font-size: 10px; }
|
329 |
+
.item-field, .item-description { font-size: 9px; }
|
330 |
+
.show-button, .add-button { font-size: 9px; padding: 3px; min-width: 35px; }
|
331 |
+
.options-container { gap: 3px; }
|
332 |
+
.option-button { font-size: 11px; padding: 5px 8px; min-width: 50px; }
|
333 |
+
.selection-box, .submission-box { padding: 6px; gap: 3px; }
|
334 |
+
.selection-box span, .submission-box span { font-size: 11px; padding: 2px 6px; }
|
335 |
+
.selected-item { font-size: 10px; padding: 2px 6px; }
|
336 |
+
.selected-item-image { width: 20px; height: 20px; }
|
337 |
+
.submit-button, .both-button { font-size: 11px; padding: 5px 8px; min-width: 50px; }
|
338 |
+
.remove-button { font-size: 9px; padding: 2px 5px; }
|
339 |
+
.manual-input, .order-name-input, .ingredient-input { width: 80px; font-size: 11px; padding: 3px; }
|
340 |
+
.quantity-input { width: 40px; font-size: 11px; padding: 3px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
341 |
}
|
342 |
|
343 |
@media (min-width: 481px) and (max-width: 768px) {
|
344 |
+
.chat-header { font-size: 15px; }
|
345 |
+
.chat-messages { padding: 4px; }
|
346 |
+
.bot-message, .user-message { font-size: 12px; padding: 7px; }
|
347 |
+
.chat-input input { font-size: 12px; min-height: 35px; }
|
348 |
+
.chat-input button { font-size: 12px; min-height: 35px; padding: 6px 10px; }
|
349 |
+
.items-grid { gap: 8px; }
|
350 |
+
.item-card { flex: 0 0 140px; }
|
351 |
+
.item-image { height: 90px; }
|
352 |
+
.item-name { font-size: 11px; }
|
353 |
+
.item-field, .item-description { font-size: 10px; }
|
354 |
+
.show-button, .add-button { font-size: 10px; padding: 4px; min-width: 40px; }
|
355 |
+
.option-button { font-size: 12px; padding: 6px 10px; }
|
356 |
+
.selection-box, .submission-box { padding: 8px; gap: 5px; }
|
357 |
+
.selection-box span, .submission-box span { font-size: 12px; }
|
358 |
+
.selected-item { font-size: 11px; }
|
359 |
+
.selected-item-image { width: 25px; height: 25px; }
|
360 |
+
.submit-button, .both-button { font-size: 12px; padding: 6px 10px; }
|
361 |
+
.remove-button { font-size: 10px; padding: 3px 6px; }
|
362 |
+
.manual-input, .order-name-input, .ingredient-input { width: 100px; font-size: 12px; }
|
363 |
+
.quantity-input { width: 50px; font-size: 12px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
}
|
365 |
</style>
|
366 |
</head>
|
|
|
381 |
{ role: 'bot', message: 'Hello! I’m Chef Bot, your culinary assistant! What’s your name?' }
|
382 |
];
|
383 |
let selectedItems = [];
|
384 |
+
let submittedItems = [];
|
385 |
let selectionBoxVisible = false;
|
|
|
386 |
|
387 |
function addMessage(role, message) {
|
388 |
const chatMessages = document.getElementById('chatMessages');
|
|
|
415 |
}
|
416 |
userInput.value = '';
|
417 |
updateSelectionBox();
|
418 |
+
updateSubmissionBox();
|
419 |
}
|
420 |
|
421 |
function handleResponse(userInput) {
|
|
|
423 |
let botResponse = '';
|
424 |
|
425 |
if (conversation.length === 2) {
|
426 |
+
botResponse = `Hi ${userInput}! 🍳 Search for a dish or choose a preference below!`;
|
427 |
displayOptions([
|
428 |
{ text: 'Vegetarian', class: 'green' },
|
429 |
{ text: 'Non-Vegetarian', class: 'red' },
|
|
|
431 |
]);
|
432 |
addMessage('bot', botResponse);
|
433 |
} else if (lowerInput === 'vegetarian' || lowerInput === 'non-vegetarian' || lowerInput === 'both') {
|
434 |
+
botResponse = `Fetching ${lowerInput} items from Sector_Detail__c...`;
|
|
|
435 |
addMessage('bot', botResponse);
|
436 |
fetchMenuItems(lowerInput);
|
437 |
} else {
|
438 |
+
botResponse = `Looking for "${userInput}" in Menu_Item__c...`;
|
439 |
addMessage('bot', botResponse);
|
440 |
+
fetchMenuItems(null, userInput);
|
441 |
}
|
442 |
}
|
443 |
|
|
|
453 |
const selectionBox = document.createElement('div');
|
454 |
selectionBox.className = 'selection-box';
|
455 |
|
456 |
+
// First Box: Input for adding items
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
457 |
const textInput = document.createElement('input');
|
458 |
textInput.type = 'text';
|
459 |
textInput.placeholder = 'Add item...';
|
|
|
463 |
const itemName = textInput.value.trim();
|
464 |
addMessage('user', itemName);
|
465 |
conversation.push({ role: 'user', message: itemName });
|
466 |
+
handleResponse(itemName);
|
467 |
textInput.value = '';
|
468 |
}
|
469 |
});
|
470 |
selectionBox.appendChild(textInput);
|
471 |
|
472 |
+
// Second Box: Selected items and customization
|
473 |
if (selectedItems.length > 0) {
|
474 |
+
const label = document.createElement('span');
|
475 |
+
label.textContent = 'Selected:';
|
476 |
+
selectionBox.appendChild(label);
|
477 |
+
|
478 |
+
selectedItems.forEach((item, index) => {
|
479 |
+
const itemContainer = document.createElement('div');
|
480 |
+
itemContainer.className = 'selected-item';
|
481 |
+
|
482 |
+
const img = document.createElement('img');
|
483 |
+
img.src = item.image_url || 'https://via.placeholder.com/30';
|
484 |
+
img.alt = item.name;
|
485 |
+
img.className = 'selected-item-image';
|
486 |
+
itemContainer.appendChild(img);
|
487 |
+
|
488 |
+
const contentDiv = document.createElement('div');
|
489 |
+
contentDiv.className = 'selected-item-content';
|
490 |
+
|
491 |
+
const itemName = item.additionalIngredients && item.additionalIngredients.length > 0
|
492 |
+
? `${item.name} with ${item.additionalIngredients.join(', ')}`
|
493 |
+
: item.name;
|
494 |
+
const itemSpan = document.createElement('span');
|
495 |
+
itemSpan.textContent = `${itemName} (Qty: ${item.quantity || 1})`;
|
496 |
+
contentDiv.appendChild(itemSpan);
|
497 |
+
|
498 |
+
const ingredientInput = document.createElement('input');
|
499 |
+
ingredientInput.type = 'text';
|
500 |
+
ingredientInput.placeholder = 'Add ingredient...';
|
501 |
+
ingredientInput.className = 'ingredient-input';
|
502 |
+
ingredientInput.addEventListener('keypress', (e) => {
|
503 |
+
if (e.key === 'Enter' && ingredientInput.value.trim()) {
|
504 |
+
const ingredientName = ingredientInput.value.trim();
|
505 |
+
fetchSectorItemDetails(ingredientName, index);
|
506 |
+
ingredientInput.value = '';
|
507 |
+
}
|
508 |
+
});
|
509 |
+
contentDiv.appendChild(ingredientInput);
|
510 |
+
|
511 |
+
itemContainer.appendChild(contentDiv);
|
512 |
+
|
513 |
+
const removeButton = document.createElement('button');
|
514 |
+
removeButton.textContent = 'X';
|
515 |
+
removeButton.className = 'remove-button';
|
516 |
+
removeButton.onclick = () => {
|
517 |
+
selectedItems.splice(index, 1);
|
518 |
+
addMessage('bot', `Removed "${itemName}".`);
|
519 |
+
updateSelectionBox();
|
520 |
+
};
|
521 |
+
itemContainer.appendChild(removeButton);
|
522 |
+
|
523 |
+
selectionBox.appendChild(itemContainer);
|
524 |
+
});
|
525 |
+
|
526 |
+
const bothButton = document.createElement('button');
|
527 |
+
bothButton.textContent = 'Both';
|
528 |
+
bothButton.className = 'both-button';
|
529 |
+
bothButton.onclick = () => fetchBothItems();
|
530 |
+
selectionBox.appendChild(bothButton);
|
531 |
+
|
532 |
+
const submitButton = document.createElement('button');
|
533 |
+
submitButton.textContent = 'Submit';
|
534 |
+
submitButton.className = 'submit-button';
|
535 |
+
submitButton.onclick = () => promptAndSubmit();
|
536 |
+
selectionBox.appendChild(submitButton);
|
537 |
+
|
538 |
const quantityInput = document.createElement('input');
|
539 |
quantityInput.type = 'number';
|
540 |
quantityInput.min = '1';
|
|
|
543 |
quantityInput.className = 'quantity-input';
|
544 |
selectionBox.appendChild(quantityInput);
|
545 |
|
|
|
|
|
|
|
|
|
|
|
|
|
546 |
const orderNameInput = document.createElement('input');
|
547 |
orderNameInput.type = 'text';
|
548 |
orderNameInput.placeholder = 'Order Name';
|
|
|
555 |
console.log('Updated selection box:', selectedItems.map(item => ({ name: item.name, additionalIngredients: item.additionalIngredients })));
|
556 |
}
|
557 |
|
558 |
+
function updateSubmissionBox() {
|
559 |
+
const chatMessages = document.getElementById('chatMessages');
|
560 |
+
if (!chatMessages) return;
|
561 |
+
|
562 |
+
const existingBox = document.querySelector('.submission-box');
|
563 |
+
if (existingBox) existingBox.remove();
|
564 |
+
|
565 |
+
if (submittedItems.length === 0) return;
|
566 |
+
|
567 |
+
const submissionBox = document.createElement('div');
|
568 |
+
submissionBox.className = 'submission-box';
|
569 |
+
|
570 |
+
const label = document.createElement('span');
|
571 |
+
label.textContent = 'Submitted Items:';
|
572 |
+
submissionBox.appendChild(label);
|
573 |
+
|
574 |
+
submittedItems.forEach(item => {
|
575 |
+
const itemContainer = document.createElement('div');
|
576 |
+
itemContainer.className = 'selected-item';
|
577 |
+
|
578 |
+
const img = document.createElement('img');
|
579 |
+
img.src = item.image_url || 'https://via.placeholder.com/30';
|
580 |
+
img.alt = item.name;
|
581 |
+
img.className = 'selected-item-image';
|
582 |
+
itemContainer.appendChild(img);
|
583 |
+
|
584 |
+
const contentDiv = document.createElement('div');
|
585 |
+
contentDiv.className = 'selected-item-content';
|
586 |
+
|
587 |
+
const itemName = item.additionalIngredients && item.additionalIngredients.length > 0
|
588 |
+
? `${item.name} with ${item.additionalIngredients.join(', ')}`
|
589 |
+
: item.name;
|
590 |
+
const itemSpan = document.createElement('span');
|
591 |
+
itemSpan.textContent = `${itemName} (Qty: ${item.quantity || 1})`;
|
592 |
+
contentDiv.appendChild(itemSpan);
|
593 |
+
|
594 |
+
const descElement = document.createElement('p');
|
595 |
+
descElement.className = 'item-description';
|
596 |
+
descElement.textContent = item.description || 'No description available';
|
597 |
+
contentDiv.appendChild(descElement);
|
598 |
+
|
599 |
+
itemContainer.appendChild(contentDiv);
|
600 |
+
submissionBox.appendChild(itemContainer);
|
601 |
+
});
|
602 |
+
|
603 |
+
chatMessages.appendChild(submissionBox);
|
604 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
605 |
+
console.log('Updated submission box:', submittedItems.map(item => ({ name: item.name, additionalIngredients: item.additionalIngredients })));
|
606 |
+
}
|
607 |
+
|
608 |
function fetchMenuItems(dietaryPreference = '', searchTerm = '') {
|
609 |
const payload = {};
|
610 |
if (dietaryPreference) payload.dietary_preference = dietaryPreference;
|
611 |
if (searchTerm) payload.search_term = searchTerm;
|
612 |
+
fetch(dietaryPreference ? '/get_menu_items' : '/search_menu_items', {
|
613 |
method: 'POST',
|
614 |
headers: { 'Content-Type': 'application/json' },
|
615 |
body: JSON.stringify(payload)
|
|
|
632 |
});
|
633 |
}
|
634 |
|
635 |
+
function fetchBothItems() {
|
636 |
+
fetch('/get_both_items', {
|
637 |
+
method: 'POST',
|
638 |
+
headers: { 'Content-Type': 'application/json' },
|
639 |
+
body: JSON.stringify({})
|
640 |
+
})
|
641 |
+
.then(response => response.json())
|
642 |
+
.then(data => {
|
643 |
+
if (data.error) {
|
644 |
+
addMessage('bot', `Error: ${data.error}. Try again!`);
|
645 |
+
} else if (data.menu_items.length > 0) {
|
646 |
+
addMessage('bot', `--- Found ${data.menu_items.length} 'Both' items from Sector_Detail__c ---`);
|
647 |
+
displayItemsList(data.menu_items);
|
648 |
+
} else {
|
649 |
+
addMessage('bot', `No 'Both' items found in Sector_Detail__c.`);
|
650 |
+
}
|
651 |
+
console.log('Fetched Both items:', data.menu_items);
|
652 |
+
})
|
653 |
+
.catch(error => {
|
654 |
+
addMessage('bot', `Connection issue: ${error.message}. Retrying...`);
|
655 |
+
setTimeout(fetchBothItems, 2000);
|
656 |
+
});
|
657 |
+
}
|
658 |
+
|
659 |
function fetchSectorItemDetails(itemName, itemIndex = null) {
|
660 |
fetch('/get_sector_item_details', {
|
661 |
method: 'POST',
|
|
|
668 |
addMessage('bot', `No "${itemName}" found in Sector_Detail__c. Try another!`);
|
669 |
} else {
|
670 |
const details = data.item_details;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
671 |
if (itemIndex !== null) {
|
672 |
if (!selectedItems[itemIndex].additionalIngredients) {
|
673 |
selectedItems[itemIndex].additionalIngredients = [];
|
|
|
696 |
});
|
697 |
}
|
698 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
699 |
function displayItemsList(items) {
|
700 |
const chatMessages = document.getElementById('chatMessages');
|
701 |
if (!chatMessages) {
|
|
|
704 |
return;
|
705 |
}
|
706 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
707 |
const itemsGrid = document.createElement('div');
|
708 |
itemsGrid.className = 'items-grid';
|
709 |
|
710 |
+
items.forEach(item => {
|
711 |
const itemDiv = document.createElement('div');
|
712 |
itemDiv.className = 'item-card';
|
713 |
|
|
|
810 |
optionsDiv.appendChild(button);
|
811 |
});
|
812 |
|
|
|
|
|
|
|
|
|
|
|
|
|
813 |
chatMessages.appendChild(optionsDiv);
|
814 |
}
|
815 |
|
816 |
+
function promptAndSubmit() {
|
817 |
const orderNameInput = document.querySelector('.order-name-input');
|
818 |
+
const quantityInput = document.querySelector('.quantity-input');
|
819 |
const customOrderName = orderNameInput ? orderNameInput.value.trim() : '';
|
820 |
+
const quantity = quantityInput ? parseInt(quantityInput.value) || 1 : 1;
|
821 |
+
|
822 |
+
if (selectedItems.length === 0) {
|
823 |
+
addMessage('bot', 'No items selected! Add some dishes! 😊');
|
824 |
+
return;
|
825 |
+
}
|
826 |
+
|
827 |
if (confirm(`Submit ${selectedItems.length} items (Qty: ${quantity})?`)) {
|
828 |
submitToSalesforce(customOrderName, quantity);
|
829 |
} else {
|
|
|
832 |
}
|
833 |
|
834 |
function submitToSalesforce(customOrderName, quantity) {
|
|
|
|
|
|
|
|
|
|
|
835 |
const itemsToSubmit = selectedItems.map(item => ({
|
836 |
name: item.additionalIngredients && item.additionalIngredients.length > 0
|
837 |
? `${item.name} with ${item.additionalIngredients.join(', ')}`
|
|
|
839 |
category: item.category || 'Not specified',
|
840 |
description: item.description || 'No description available',
|
841 |
image_url: item.image_url || '',
|
842 |
+
quantity: quantity,
|
843 |
additionalIngredients: item.additionalIngredients || []
|
844 |
}));
|
845 |
|
|
|
854 |
addMessage('bot', `Submission failed: ${data.error}. Try again?`);
|
855 |
} else {
|
856 |
addMessage('bot', `Submitted ${data.ingredient_name}! What's next?`);
|
857 |
+
submittedItems = [...itemsToSubmit];
|
858 |
selectedItems = [];
|
859 |
updateSelectionBox();
|
860 |
+
updateSubmissionBox();
|
861 |
}
|
862 |
})
|
863 |
.catch(error => {
|
|
|
866 |
});
|
867 |
}
|
868 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
869 |
document.getElementById('userInput').addEventListener('keypress', (e) => {
|
870 |
if (e.key === 'Enter') sendMessage();
|
871 |
});
|