File size: 839 Bytes
ce6a5d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d381a2d
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
from utils.state_management import state

def preferences_page():
    def save_preferences(preferences, allergies):
        if not state.get("user"):
            return "Please log in first!"

        state["user"]["Preferences"] = preferences
        state["user"]["Allergies"] = allergies
        return "Preferences saved successfully!"

    with gr.Group():
        gr.Markdown("### Set Your Preferences and Allergies")
        preferences = gr.Dropdown(["Vegetarian", "Vegan", "Halal", "Full Menu"], label="Preferences")
        allergies = gr.Textbox(label="Allergies (comma-separated)")
        status_label = gr.Label(label="Status")  # Use a Label for output
        save_button = gr.Button("Save Preferences")
        save_button.click(save_preferences, inputs=[preferences, allergies], outputs=status_label)