nagasurendra commited on
Commit
bee6024
·
verified ·
1 Parent(s): e23474e

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +44 -38
templates/index.html CHANGED
@@ -500,45 +500,51 @@
500
  displayCart();
501
  }
502
 
503
- function resetToPreviousStep() {
504
- console.log('Resetting to previous step. Current step:', currentStep);
505
-
506
- // Based on the currentStep, go back to the previous step
507
- if (currentStep === 'food_type') {
508
- currentStep = 'greeting';
509
- conversation.push({ role: 'bot', message: "Hi there! I'm Chef Bot! May I know your name?" });
510
- console.log('Step changed to greeting. Conversation updated.');
511
- } else if (currentStep === 'select_ingredients') {
512
- currentStep = 'food_type';
513
- conversation.push({ role: 'bot', message: 'What type of food would you prefer?' });
514
- console.log('Step changed to food_type. Conversation updated.');
515
- } else if (currentStep === 'customization') {
516
- currentStep = 'menu_display';
517
- console.log('Step changed to menu_display.');
518
- //fetchMenuItems({ ingredient_names: ingredientNames });
519
- } else if (currentStep === 'post_cart') {
520
- currentStep = 'food_type';
521
- conversation.push({ role: 'bot', message: 'What type of food would you prefer?' });
522
- console.log('Step changed to food_type after post_cart. Conversation updated.');
523
- } else {
524
- console.error('Unexpected currentStep value:', currentStep);
525
- }
526
-
527
- // After going back to 'select_ingredients', trigger the fetchIngredients again
528
- if (currentStep === 'select_ingredients') {
529
- const lastMessage = conversation[conversation.length - 1].message.toLowerCase();
530
- if (lastMessage.includes('vegetarian')) {
531
- console.log('Fetching vegetarian ingredients again after back.');
532
- fetchIngredients('vegetarian');
533
- } else if (lastMessage.includes('non-vegetarian')) {
534
- console.log('Fetching non-vegetarian ingredients again after back.');
535
- fetchIngredients('non-vegetarian');
536
- }
537
- }
538
-
539
- // Ensure the bot message is updated according to the previous step
540
- setTimeout(() => handleResponse(conversation[conversation.length - 1].message), 500);
 
541
  }
 
 
 
 
 
542
 
543
 
544
  function handleYesResponse() {
 
500
  displayCart();
501
  }
502
 
503
+ function resetToPreviousStep() {
504
+ console.log('Resetting to previous step. Current step:', currentStep);
505
+
506
+ // Clear selected ingredients and selected menu item, but not the cart
507
+ selectedIngredients = [];
508
+ selectedMenuItem = null;
509
+ cart = [];
510
+
511
+ // Based on the currentStep, go back to the previous step
512
+ if (currentStep === 'food_type') {
513
+ currentStep = 'greeting';
514
+ conversation.push({ role: 'bot', message: "Hi there! I'm Chef Bot! May I know your name?" });
515
+ console.log('Step changed to greeting. Conversation updated.');
516
+ } else if (currentStep === 'select_ingredients') {
517
+ currentStep = 'food_type';
518
+ conversation.push({ role: 'bot', message: 'What type of food would you prefer?' });
519
+ console.log('Step changed to food_type. Conversation updated.');
520
+ } else if (currentStep === 'customization') {
521
+ currentStep = 'menu_display';
522
+ console.log('Step changed to menu_display.');
523
+ // If needed, fetch the menu items again
524
+ //fetchMenuItems({ ingredient_names: ingredientNames });
525
+ } else if (currentStep === 'post_cart') {
526
+ currentStep = 'food_type';
527
+ conversation.push({ role: 'bot', message: 'What type of food would you prefer?' });
528
+ console.log('Step changed to food_type after post_cart. Conversation updated.');
529
+ } else {
530
+ console.error('Unexpected currentStep value:', currentStep);
531
+ }
532
+
533
+ // After going back to 'select_ingredients', trigger the fetchIngredients again
534
+ if (currentStep === 'select_ingredients') {
535
+ const lastMessage = conversation[conversation.length - 1].message.toLowerCase();
536
+ if (lastMessage.includes('vegetarian')) {
537
+ console.log('Fetching vegetarian ingredients again after back.');
538
+ fetchIngredients('vegetarian');
539
+ } else if (lastMessage.includes('non-vegetarian')) {
540
+ console.log('Fetching non-vegetarian ingredients again after back.');
541
+ fetchIngredients('non-vegetarian');
542
  }
543
+ }
544
+
545
+ // Ensure the bot message is updated according to the previous step
546
+ setTimeout(() => handleResponse(conversation[conversation.length - 1].message), 500);
547
+ }
548
 
549
 
550
  function handleYesResponse() {