Yaswanth56 commited on
Commit
0eedc31
·
verified ·
1 Parent(s): b81fa5c

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +10 -7
static/script.js CHANGED
@@ -47,21 +47,18 @@ function handleResponse(userInput) {
47
  { text: 'Vegetarian', class: 'green' },
48
  { text: 'Non-Vegetarian', class: 'red' }
49
  ];
50
- }else if (lastMessage.includes('non-vegetarian')) {
51
  conversation.push({ role: 'user', message: 'Non-Vegetarian' });
52
  console.log("Food preference selected: Non-Vegetarian");
53
  botResponse = 'Great choice! 🍽️ Please select a non-vegetarian option:';
54
  fetchIngredients('non-vegetarian');
55
  return;
56
-
57
- }
58
- else if (lastMessage.includes('vegetarian')) {
59
  conversation.push({ role: 'user', message: 'Vegetarian' });
60
  console.log("Food preference selected: Vegetarian");
61
  botResponse = 'Great choice! 🍽️ Here are some vegetarian ingredients:';
62
  fetchIngredients('vegetarian');
63
  return;
64
-
65
  } else if (lastMessage.includes('yes') && selectedMenuItem) {
66
  botResponse = 'Here are some ingredients to customize your dish:';
67
  fetchIngredients('non-vegetarian'); // Fetch non-veg ingredients for customization
@@ -261,8 +258,14 @@ function submitIngredients() {
261
  .then(response => response.json())
262
  .then(data => {
263
  if (data.success) {
264
- addMessage('bot', 'Great choice! Would you like to add any special instructions for your dish?');
265
- displayCustomizationInput();
 
 
 
 
 
 
266
  } else {
267
  addMessage('bot', 'There was an issue submitting your ingredients. Please try again.');
268
  }
 
47
  { text: 'Vegetarian', class: 'green' },
48
  { text: 'Non-Vegetarian', class: 'red' }
49
  ];
50
+ } else if (lastMessage.includes('non-vegetarian')) {
51
  conversation.push({ role: 'user', message: 'Non-Vegetarian' });
52
  console.log("Food preference selected: Non-Vegetarian");
53
  botResponse = 'Great choice! 🍽️ Please select a non-vegetarian option:';
54
  fetchIngredients('non-vegetarian');
55
  return;
56
+ } else if (lastMessage.includes('vegetarian')) {
 
 
57
  conversation.push({ role: 'user', message: 'Vegetarian' });
58
  console.log("Food preference selected: Vegetarian");
59
  botResponse = 'Great choice! 🍽️ Here are some vegetarian ingredients:';
60
  fetchIngredients('vegetarian');
61
  return;
 
62
  } else if (lastMessage.includes('yes') && selectedMenuItem) {
63
  botResponse = 'Here are some ingredients to customize your dish:';
64
  fetchIngredients('non-vegetarian'); // Fetch non-veg ingredients for customization
 
258
  .then(response => response.json())
259
  .then(data => {
260
  if (data.success) {
261
+ // Determine category based on selected ingredients
262
+ let category = 'non-vegetarian'; // Default for now
263
+ if (selectedIngredients.some(ing => ing.name.toLowerCase() === 'chicken')) {
264
+ category = 'chicken';
265
+ } else if (selectedIngredients.some(ing => ing.name.toLowerCase() === 'mutton')) {
266
+ category = 'mutton';
267
+ }
268
+ fetchMenuItems(category); // Fetch menu items based on category
269
  } else {
270
  addMessage('bot', 'There was an issue submitting your ingredients. Please try again.');
271
  }