Biryani-Hub-Menu-System / components /cart_management.py
nagasurendra's picture
Create cart_management.py
dccd44d verified
raw
history blame contribute delete
629 Bytes
import gradio as gr
from utils.state_management import state
def cart_page():
def view_cart():
cart = state.get("cart", [])
return cart
def remove_item(item_name):
cart = state.get("cart", [])
cart = [item for item in cart if item["Item"] != item_name]
state["cart"] = cart
return "Item removed!"
with gr.Group():
gr.Markdown("### Cart")
cart_items = view_cart()
for item in cart_items:
gr.Text(f"{item['Item']} - {item['Spice Level']}")
gr.Button("Remove").click(remove_item, inputs=[item["Item"]], outputs="Status")