Leospencer1 commited on
Commit
ffcb5dd
·
verified ·
1 Parent(s): 5dc1864

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -1436,6 +1436,20 @@ with gr.Blocks(title="Bitesized AI Meal Planner") as demo:
1436
  outputs=[title_radio, info_output, save_status, regenerate_btn, keep_checkboxes, refresh_unwanted_btn, ingredient_info, confirm_all_btn]
1437
  )
1438
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1439
  # ==================== END UNIFIED PLANNER ====================
1440
 
1441
  gr.Markdown("---")
@@ -2208,18 +2222,7 @@ with gr.Blocks(title="Bitesized AI Meal Planner") as demo:
2208
  supermarket_meals_per_week.change(update_weekly_total, inputs=[supermarket_cost_per_meal, supermarket_meals_per_week, supermarket_people], outputs=[supermarket_weekly_total], queue=False)
2209
  supermarket_people.change(update_weekly_total, inputs=[supermarket_cost_per_meal, supermarket_meals_per_week, supermarket_people], outputs=[supermarket_weekly_total], queue=False)
2210
 
2211
- generate_btn.click(generate_recipe_titles, inputs=[cost_per_meal, meals_per_week, postcode, preferences, people_count, meal_type, budget_preference], outputs=[title_radio, info_text, save_status, regenerate_btn, keep_checkboxes, refresh_unwanted_btn, ingredient_info, confirm_all_btn])
2212
- regenerate_btn.click(generate_recipe_titles, inputs=[cost_per_meal, meals_per_week, postcode, preferences, people_count, meal_type, budget_preference], outputs=[title_radio, info_text, save_status, regenerate_btn, keep_checkboxes, refresh_unwanted_btn, ingredient_info, confirm_all_btn])
2213
-
2214
- # Confirm all meals button - saves all recipes and adds all ingredients
2215
- confirm_all_btn.click(
2216
- confirm_all_meals_and_add_to_shopping,
2217
- inputs=[cost_per_meal, meals_per_week, postcode, preferences, people_count, meal_type, budget_preference],
2218
- outputs=[save_status, saved_recipes_radio, saved_count, shopping_checkboxes, shopping_list_table]
2219
- )
2220
-
2221
- refresh_unwanted_btn.click(refresh_unwanted_recipes, inputs=[cost_per_meal, meals_per_week, postcode, preferences, people_count, meal_type, keep_checkboxes, budget_preference], outputs=[title_radio, info_text, save_status, keep_checkboxes, refresh_unwanted_btn, ingredient_info, confirm_all_btn])
2222
- title_radio.change(display_recipe, inputs=[title_radio, cost_per_meal, meals_per_week, postcode, preferences, people_count, meal_type, budget_preference], outputs=[recipe_markdown])
2223
  add_item_btn.click(add_item_to_list, inputs=[new_item, new_quantity, new_category], outputs=[add_status, shopping_checkboxes, shopping_list_table], queue=False)
2224
  shopping_checkboxes.change(update_shopping_status, inputs=[shopping_checkboxes], outputs=[list_status, shopping_checkboxes, shopping_list_table])
2225
  refresh_list_btn.click(refresh_shopping_list, inputs=[], outputs=[shopping_checkboxes, shopping_list_table], queue=False)
 
1436
  outputs=[title_radio, info_output, save_status, regenerate_btn, keep_checkboxes, refresh_unwanted_btn, ingredient_info, confirm_all_btn]
1437
  )
1438
 
1439
+ # When user clicks a recipe title, display it
1440
+ def display_recipe_wrapper(title):
1441
+ """Wrapper to display recipe with the calculated cost"""
1442
+ if title is None:
1443
+ return gr.update(value="<p>👈 <strong>Select a recipe from the list</strong> to view full details.</p>")
1444
+ # Get the stored values - we'll use defaults for now since recipes are already generated
1445
+ return display_recipe(title, "3.50", 7, "", "", 4, "Dinner", "Spend Full Budget")
1446
+
1447
+ title_radio.change(
1448
+ fn=display_recipe_wrapper,
1449
+ inputs=[title_radio],
1450
+ outputs=[recipe_markdown]
1451
+ )
1452
+
1453
  # ==================== END UNIFIED PLANNER ====================
1454
 
1455
  gr.Markdown("---")
 
2222
  supermarket_meals_per_week.change(update_weekly_total, inputs=[supermarket_cost_per_meal, supermarket_meals_per_week, supermarket_people], outputs=[supermarket_weekly_total], queue=False)
2223
  supermarket_people.change(update_weekly_total, inputs=[supermarket_cost_per_meal, supermarket_meals_per_week, supermarket_people], outputs=[supermarket_weekly_total], queue=False)
2224
 
2225
+ # Shopping list handlers
 
 
 
 
 
 
 
 
 
 
 
2226
  add_item_btn.click(add_item_to_list, inputs=[new_item, new_quantity, new_category], outputs=[add_status, shopping_checkboxes, shopping_list_table], queue=False)
2227
  shopping_checkboxes.change(update_shopping_status, inputs=[shopping_checkboxes], outputs=[list_status, shopping_checkboxes, shopping_list_table])
2228
  refresh_list_btn.click(refresh_shopping_list, inputs=[], outputs=[shopping_checkboxes, shopping_list_table], queue=False)