File size: 1,569 Bytes
6a94706
358b6a5
cd941f3
491df19
b537c3b
7980609
358b6a5
cd941f3
358b6a5
 
 
cd941f3
 
358b6a5
 
cd941f3
358b6a5
 
ad4e58e
4b7cf86
cd941f3
 
 
6a94706
358b6a5
cd941f3
ad4e58e
cd941f3
358b6a5
cd941f3
491df19
cd941f3
 
013b172
491df19
 
 
 
 
 
 
 
 
358b6a5
7980609
 
358b6a5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import gradio as gr
from components.menu import generate_menu
from components.popup import show_popup
from components.cart import add_to_cart, cart_data
import pandas as pd

# Load menu data
menu_data = pd.read_excel("data/menu.xlsx")

def main():
    with gr.Blocks(css="static/styles.css") as app:
        gr.Markdown("# Dynamic Menu with Popups and Ordering System")

        # Preference Selection
        preference = gr.Radio(
            label="Choose a Preference",
            choices=["All", "Vegetarian", "Non-Vegetarian", "Guilt-Free"],
            value="All"
        )

        # Menu Display
        menu_display = gr.Row()
        preference.change(generate_menu, inputs=[preference], outputs=menu_display)

        # Popup Display
        popup_display = gr.Column(visible=False)  # Placeholder for popup

        # Cart Section
        gr.Markdown("## Your Cart")
        cart_display = gr.Dataframe(
            value=pd.DataFrame(cart_data(), columns=["Dish", "Spice Level", "Extras", "Instructions", "Quantity", "Price"]),
            headers=["Dish", "Spice Level", "Extras", "Instructions", "Quantity", "Price"]
        )

        # Keep updating the cart display
        def update_cart_display():
            return pd.DataFrame(cart_data(), columns=["Dish", "Spice Level", "Extras", "Instructions", "Quantity", "Price"])

        # Update cart when new item is added
        gr.Button("Update Cart").click(
            update_cart_display, inputs=[], outputs=cart_display
        )

        app.launch()

if __name__ == "__main__":
    main()