# DO NOT COPY OR SHARE - A3Tech / NCTI course material for enrolled students only.
# BUG HUNT - this app doesn't crash, but it's losing stock!
# Open it, then change the number box a few times WITHOUT pressing Sell.
# Watch "Beef Patty left". Why does it go down? Fix it so it only sells on Sell.
import streamlit as st
import shop_db

shop_db.setup()
st.title("Quick Sell")

qty = st.number_input("How many Beef Patty?", min_value=1, value=1, step=1)
sell = st.button("Sell")
message = shop_db.record_sale("Beef Patty", qty)
if sell:
    st.success(message)

st.write("Beef Patty left:", shop_db.find_product("Beef Patty")["stock"])
