nagasurendra commited on
Commit
cdc2844
·
verified ·
1 Parent(s): 17119fe

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +36 -26
templates/index.html CHANGED
@@ -846,33 +846,43 @@
846
  // Log to verify the dishes being fetched
847
  console.log('Fetched menu items:', menuItems);
848
 
849
- menuItems.forEach(item => {
850
- const menuItem = document.createElement('div');
851
- menuItem.className = 'menu-item';
852
- const img = document.createElement('img');
853
- img.src = item.image_url || 'https://via.placeholder.com/120';
854
- img.alt = item.name;
855
- const name = document.createElement('div');
856
- name.textContent = item.name;
857
- const button = document.createElement('button');
858
- button.textContent = 'Add to Cart';
859
- button.onclick = () => {
860
- selectedMenuItem = item;
861
- addMessage('bot', `World-class selection! Would you like to customize your dish further?`);
862
- const options = [
863
- { text: 'Yes', class: 'green' },
864
- { text: 'No', class: 'red' }
865
- ];
866
- currentStep = 'customization';
867
- displayOptions(options);
868
- };
869
- menuItem.appendChild(img);
870
- menuItem.appendChild(name);
871
- menuItem.appendChild(button);
872
- menuItemsList.appendChild(menuItem);
873
- });
 
 
 
 
 
 
 
 
 
 
874
 
875
- // If there's no issue with the fetch, we expect the dishes to be displayed correctly here.
876
  console.log('Menu items displayed');
877
  }
878
 
 
846
  // Log to verify the dishes being fetched
847
  console.log('Fetched menu items:', menuItems);
848
 
849
+ // If menuItems is an empty array, add a message indicating no items found
850
+ if (menuItems.length === 0) {
851
+ const noItemsMessage = document.createElement('div');
852
+ noItemsMessage.textContent = 'No dishes available at the moment.';
853
+ menuItemsList.appendChild(noItemsMessage);
854
+ } else {
855
+ menuItems.forEach(item => {
856
+ const menuItem = document.createElement('div');
857
+ menuItem.className = 'menu-item';
858
+ const img = document.createElement('img');
859
+ img.src = item.image_url || 'https://via.placeholder.com/120';
860
+ img.alt = item.name;
861
+ const name = document.createElement('div');
862
+ name.textContent = item.name;
863
+ const button = document.createElement('button');
864
+ button.textContent = 'Add to Cart';
865
+ button.onclick = () => {
866
+ selectedMenuItem = item;
867
+ addMessage('bot', `World-class selection! Would you like to customize your dish further?`);
868
+ const options = [
869
+ { text: 'Yes', class: 'green' },
870
+ { text: 'No', class: 'red' }
871
+ ];
872
+ currentStep = 'customization';
873
+ displayOptions(options);
874
+ };
875
+ menuItem.appendChild(img);
876
+ menuItem.appendChild(name);
877
+ menuItem.appendChild(button);
878
+ menuItemsList.appendChild(menuItem);
879
+ });
880
+ }
881
+
882
+ // Ensure the display is scrolled to the latest message
883
+ chatMessages.scrollTop = chatMessages.scrollHeight;
884
 
885
+ // Log that menu items were displayed
886
  console.log('Menu items displayed');
887
  }
888