lokesh341 commited on
Commit
380eabf
·
verified ·
1 Parent(s): 1ceb849

Update templates/chef-bot.html

Browse files
Files changed (1) hide show
  1. templates/chef-bot.html +50 -15
templates/chef-bot.html CHANGED
@@ -241,6 +241,7 @@
241
  font-size: 13px;
242
  margin: 5px 0;
243
  width: 100%;
 
244
  }
245
 
246
  .selected-item-image {
@@ -251,13 +252,14 @@
251
  margin-right: 8px;
252
  }
253
 
254
- .ingredient-select {
255
  padding: 8px;
256
  border: 1px solid #b3d7ff;
257
  border-radius: 6px;
258
  font-size: 13px;
259
  width: 150px;
260
  outline: none;
 
261
  }
262
 
263
  .submit-button {
@@ -290,7 +292,7 @@
290
  background-color: #c82333;
291
  }
292
 
293
- .name-input {
294
  padding: 8px;
295
  border: 1px solid #b3d7ff;
296
  border-radius: 6px;
@@ -398,7 +400,7 @@
398
  height: 25px;
399
  }
400
 
401
- .name-input, .order-name-input {
402
  width: 120px;
403
  font-size: 13px;
404
  padding: 6px;
@@ -420,7 +422,7 @@
420
  padding: 4px 8px;
421
  }
422
 
423
- .ingredient-select {
424
  width: 120px;
425
  font-size: 12px;
426
  }
@@ -645,6 +647,17 @@
645
  });
646
  contentDiv.appendChild(ingredientSelect);
647
 
 
 
 
 
 
 
 
 
 
 
 
648
  itemContainer.appendChild(contentDiv);
649
 
650
  const removeButton = document.createElement('button');
@@ -679,10 +692,21 @@
679
  orderNameInput.className = 'order-name-input';
680
  selectionBox.appendChild(orderNameInput);
681
 
 
 
 
 
 
 
 
682
  const submitButton = document.createElement('button');
683
  submitButton.textContent = 'Submit';
684
  submitButton.className = 'submit-button';
685
- submitButton.onclick = () => promptAndSubmit(quantityInput.value, orderNameInput.value);
 
 
 
 
686
  selectionBox.appendChild(submitButton);
687
  }
688
 
@@ -690,7 +714,11 @@
690
  }
691
 
692
  chatMessages.scrollTop = chatMessages.scrollHeight;
693
- console.log('Updated selection box:', selectedItems.map(item => ({ name: item.name, additionalIngredients: item.additionalIngredients })));
 
 
 
 
694
  }
695
 
696
  function fetchMenuItems(dietaryPreference = '', searchTerm = '') {
@@ -724,13 +752,14 @@
724
  fetch('/get_sector_ingredients', {
725
  method: 'POST',
726
  headers: { 'Content-Type': 'application/json' },
727
- body: JSON.stringify({ dietary_preference: dietaryPreference })
728
  })
729
  .then(response => response.json())
730
  .then(data => {
731
  if (!data.error) {
732
  sectorIngredients = data.ingredients;
733
  console.log('Fetched Sector_Detail__c ingredients:', sectorIngredients);
 
734
  }
735
  })
736
  .catch(error => console.error('Error fetching Sector_Detail__c ingredients:', error));
@@ -810,9 +839,10 @@
810
  description: item.description || 'No description available',
811
  source: item.source,
812
  quantity: 1,
813
- additionalIngredients: []
 
814
  };
815
- if (selectedItems.some(existing => existing.name === selectedItem.name && !existing.additionalIngredients)) {
816
  addMessage('bot', `"${selectedItem.name}" already selected!`);
817
  } else {
818
  selectedItems.push(selectedItem);
@@ -830,15 +860,15 @@
830
  chatMessages.scrollTop = chatMessages.scrollHeight;
831
  }
832
 
833
- function promptAndSubmit(quantity, orderName) {
834
  if (confirm(`Submit ${selectedItems.length} items (Qty: ${quantity}) as "${orderName || 'Order'}"?`)) {
835
- submitToSalesforce(orderName, quantity);
836
  } else {
837
  addMessage('bot', 'Cancelled. Add more items?');
838
  }
839
  }
840
 
841
- function submitToSalesforce(customOrderName, quantity) {
842
  if (selectedItems.length === 0) {
843
  addMessage('bot', 'No items selected! Add some dishes! 😊');
844
  return;
@@ -852,13 +882,18 @@
852
  description: item.description || 'No description available',
853
  image_url: item.image_url || '',
854
  quantity: parseInt(quantity) || 1,
855
- additionalIngredients: item.additionalIngredients || []
 
856
  }));
857
 
858
  fetch('/submit_items', {
859
  method: 'POST',
860
  headers: { 'Content-Type': 'application/json' },
861
- body: JSON.stringify({ items: itemsToSubmit, custom_order_name: customOrderName })
 
 
 
 
862
  })
863
  .then(response => response.json())
864
  .then(data => {
@@ -872,7 +907,7 @@
872
  })
873
  .catch(error => {
874
  addMessage('bot', `Submission error: ${error.message}. Retrying...`);
875
- setTimeout(() => submitToSalesforce(customOrderName, quantity), 2000);
876
  });
877
  }
878
 
 
241
  font-size: 13px;
242
  margin: 5px 0;
243
  width: 100%;
244
+ flex-wrap: wrap;
245
  }
246
 
247
  .selected-item-image {
 
252
  margin-right: 8px;
253
  }
254
 
255
+ .ingredient-select, .ingredient-info-input {
256
  padding: 8px;
257
  border: 1px solid #b3d7ff;
258
  border-radius: 6px;
259
  font-size: 13px;
260
  width: 150px;
261
  outline: none;
262
+ margin: 5px;
263
  }
264
 
265
  .submit-button {
 
292
  background-color: #c82333;
293
  }
294
 
295
+ .name-input, .ingredients-info-input {
296
  padding: 8px;
297
  border: 1px solid #b3d7ff;
298
  border-radius: 6px;
 
400
  height: 25px;
401
  }
402
 
403
+ .name-input, .order-name-input, .ingredients-info-input {
404
  width: 120px;
405
  font-size: 13px;
406
  padding: 6px;
 
422
  padding: 4px 8px;
423
  }
424
 
425
+ .ingredient-select, .ingredient-info-input {
426
  width: 120px;
427
  font-size: 12px;
428
  }
 
647
  });
648
  contentDiv.appendChild(ingredientSelect);
649
 
650
+ // Ingredientsinfo Input
651
+ const ingredientInfoInput = document.createElement('input');
652
+ ingredientInfoInput.type = 'text';
653
+ ingredientInfoInput.placeholder = 'Add ingredient details...';
654
+ ingredientInfoInput.className = 'ingredient-info-input';
655
+ ingredientInfoInput.value = item.ingredientsInfo || '';
656
+ ingredientInfoInput.addEventListener('input', (e) => {
657
+ selectedItems[index].ingredientsInfo = e.target.value;
658
+ });
659
+ contentDiv.appendChild(ingredientInfoInput);
660
+
661
  itemContainer.appendChild(contentDiv);
662
 
663
  const removeButton = document.createElement('button');
 
692
  orderNameInput.className = 'order-name-input';
693
  selectionBox.appendChild(orderNameInput);
694
 
695
+ const ingredientsInfoInput = document.createElement('input');
696
+ ingredientsInfoInput.type = 'text';
697
+ ingredientsInfoInput.placeholder = 'Order Ingredients Info...';
698
+ ingredientsInfoInput.className = 'ingredients-info-input';
699
+ ingredientsInfoInput.id = 'orderIngredientsInfo';
700
+ selectionBox.appendChild(ingredientsInfoInput);
701
+
702
  const submitButton = document.createElement('button');
703
  submitButton.textContent = 'Submit';
704
  submitButton.className = 'submit-button';
705
+ submitButton.onclick = () => promptAndSubmit(
706
+ quantityInput.value,
707
+ orderNameInput.value,
708
+ ingredientsInfoInput.value
709
+ );
710
  selectionBox.appendChild(submitButton);
711
  }
712
 
 
714
  }
715
 
716
  chatMessages.scrollTop = chatMessages.scrollHeight;
717
+ console.log('Updated selection box:', selectedItems.map(item => ({
718
+ name: item.name,
719
+ additionalIngredients: item.additionalIngredients,
720
+ ingredientsInfo: item.ingredientsInfo
721
+ })));
722
  }
723
 
724
  function fetchMenuItems(dietaryPreference = '', searchTerm = '') {
 
752
  fetch('/get_sector_ingredients', {
753
  method: 'POST',
754
  headers: { 'Content-Type': 'application/json' },
755
+ body: JSON.stringify({ dietary_preference: 'both' })
756
  })
757
  .then(response => response.json())
758
  .then(data => {
759
  if (!data.error) {
760
  sectorIngredients = data.ingredients;
761
  console.log('Fetched Sector_Detail__c ingredients:', sectorIngredients);
762
+ updateSelectionBox();
763
  }
764
  })
765
  .catch(error => console.error('Error fetching Sector_Detail__c ingredients:', error));
 
839
  description: item.description || 'No description available',
840
  source: item.source,
841
  quantity: 1,
842
+ additionalIngredients: [],
843
+ ingredientsInfo: ''
844
  };
845
+ if (selectedItems.some(existing => existing.name === selectedItem.name && !existing.additionalIngredients && !existing.ingredientsInfo)) {
846
  addMessage('bot', `"${selectedItem.name}" already selected!`);
847
  } else {
848
  selectedItems.push(selectedItem);
 
860
  chatMessages.scrollTop = chatMessages.scrollHeight;
861
  }
862
 
863
+ function promptAndSubmit(quantity, orderName, ingredientsInfo) {
864
  if (confirm(`Submit ${selectedItems.length} items (Qty: ${quantity}) as "${orderName || 'Order'}"?`)) {
865
+ submitToSalesforce(orderName, quantity, ingredientsInfo);
866
  } else {
867
  addMessage('bot', 'Cancelled. Add more items?');
868
  }
869
  }
870
 
871
+ function submitToSalesforce(customOrderName, quantity, ingredientsInfo) {
872
  if (selectedItems.length === 0) {
873
  addMessage('bot', 'No items selected! Add some dishes! 😊');
874
  return;
 
882
  description: item.description || 'No description available',
883
  image_url: item.image_url || '',
884
  quantity: parseInt(quantity) || 1,
885
+ additionalIngredients: item.additionalIngredients || [],
886
+ ingredientsInfo: item.ingredientsInfo || ''
887
  }));
888
 
889
  fetch('/submit_items', {
890
  method: 'POST',
891
  headers: { 'Content-Type': 'application/json' },
892
+ body: JSON.stringify({
893
+ items: itemsToSubmit,
894
+ custom_order_name: customOrderName,
895
+ ingredients_info: ingredientsInfo
896
+ })
897
  })
898
  .then(response => response.json())
899
  .then(data => {
 
907
  })
908
  .catch(error => {
909
  addMessage('bot', `Submission error: ${error.message}. Retrying...`);
910
+ setTimeout(() => submitToSalesforce(customOrderName, quantity, ingredientsInfo), 2000);
911
  });
912
  }
913