Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -136,10 +136,8 @@ def modal_js():
|
|
136 |
const instructions = document.getElementById('special-instructions').value;
|
137 |
const extrasCost = 0; // For simplicity, no extras are added here
|
138 |
const totalCost = price * quantity + extrasCost;
|
139 |
-
|
140 |
cart.push({ name, quantity, instructions, totalCost });
|
141 |
totalCartCost += totalCost;
|
142 |
-
|
143 |
updateCartButton();
|
144 |
closeModal();
|
145 |
}
|
@@ -154,7 +152,6 @@ def modal_js():
|
|
154 |
alert("Cart is empty. Please add items!");
|
155 |
return;
|
156 |
}
|
157 |
-
|
158 |
let summary = "<h3>Order Summary</h3><ul>";
|
159 |
cart.forEach(item => {
|
160 |
summary += `<li>${item.name} (x${item.quantity}) - $${item.totalCost.toFixed(2)}</li>`;
|
@@ -171,6 +168,7 @@ with gr.Blocks() as app:
|
|
171 |
with gr.Row():
|
172 |
gr.HTML("<h1 style='text-align: center;'>Welcome to Biryani Hub</h1>")
|
173 |
|
|
|
174 |
with gr.Row(visible=True) as login_page:
|
175 |
with gr.Column():
|
176 |
login_email = gr.Textbox(label="Email")
|
@@ -179,6 +177,7 @@ with gr.Blocks() as app:
|
|
179 |
signup_redirect = gr.Button("Go to Signup")
|
180 |
login_output = gr.Textbox(label="Status")
|
181 |
|
|
|
182 |
with gr.Row(visible=False) as signup_page:
|
183 |
with gr.Column():
|
184 |
signup_name = gr.Textbox(label="Name")
|
@@ -189,48 +188,45 @@ with gr.Blocks() as app:
|
|
189 |
login_redirect = gr.Button("Go to Login")
|
190 |
signup_output = gr.Textbox(label="Status")
|
191 |
|
|
|
192 |
with gr.Row(visible=False) as menu_page:
|
193 |
with gr.Column():
|
194 |
preference = gr.Radio(["All", "Veg", "Non-Veg"], label="Filter Preference", value="All")
|
195 |
menu_output = gr.HTML()
|
196 |
-
submit_cart_button = gr.Button("Submit Cart"
|
197 |
-
cart_summary = gr.HTML(
|
198 |
|
199 |
-
#
|
200 |
login_button.click(
|
201 |
lambda email, password: (gr.update(visible=False), gr.update(visible=True), filter_menu("All"), "Login successful!")
|
202 |
-
if login(email, password)[0] == "Login successful!"
|
|
|
203 |
[login_email, login_password],
|
204 |
[login_page, menu_page, menu_output, login_output]
|
205 |
)
|
206 |
|
207 |
-
# Signup Button Click
|
208 |
submit_signup.click(
|
209 |
lambda name, email, phone, password: (signup(name, email, phone, password), gr.update(visible=False), gr.update(visible=True)),
|
210 |
[signup_name, signup_email, signup_phone, signup_password],
|
211 |
[signup_output, signup_page, login_page]
|
212 |
)
|
213 |
|
214 |
-
# Signup Redirect
|
215 |
signup_redirect.click(
|
216 |
lambda: (gr.update(visible=False), gr.update(visible=True)),
|
217 |
[],
|
218 |
[login_page, signup_page]
|
219 |
)
|
220 |
|
221 |
-
# Login Redirect
|
222 |
login_redirect.click(
|
223 |
lambda: (gr.update(visible=True), gr.update(visible=False)),
|
224 |
[],
|
225 |
[login_page, signup_page]
|
226 |
)
|
227 |
|
228 |
-
# Submit Cart Button
|
229 |
submit_cart_button.click(
|
230 |
-
|
231 |
[],
|
232 |
-
[cart_summary]
|
233 |
-
_js="submitCart()"
|
234 |
)
|
235 |
|
236 |
app.launch()
|
|
|
136 |
const instructions = document.getElementById('special-instructions').value;
|
137 |
const extrasCost = 0; // For simplicity, no extras are added here
|
138 |
const totalCost = price * quantity + extrasCost;
|
|
|
139 |
cart.push({ name, quantity, instructions, totalCost });
|
140 |
totalCartCost += totalCost;
|
|
|
141 |
updateCartButton();
|
142 |
closeModal();
|
143 |
}
|
|
|
152 |
alert("Cart is empty. Please add items!");
|
153 |
return;
|
154 |
}
|
|
|
155 |
let summary = "<h3>Order Summary</h3><ul>";
|
156 |
cart.forEach(item => {
|
157 |
summary += `<li>${item.name} (x${item.quantity}) - $${item.totalCost.toFixed(2)}</li>`;
|
|
|
168 |
with gr.Row():
|
169 |
gr.HTML("<h1 style='text-align: center;'>Welcome to Biryani Hub</h1>")
|
170 |
|
171 |
+
# Login Page
|
172 |
with gr.Row(visible=True) as login_page:
|
173 |
with gr.Column():
|
174 |
login_email = gr.Textbox(label="Email")
|
|
|
177 |
signup_redirect = gr.Button("Go to Signup")
|
178 |
login_output = gr.Textbox(label="Status")
|
179 |
|
180 |
+
# Signup Page
|
181 |
with gr.Row(visible=False) as signup_page:
|
182 |
with gr.Column():
|
183 |
signup_name = gr.Textbox(label="Name")
|
|
|
188 |
login_redirect = gr.Button("Go to Login")
|
189 |
signup_output = gr.Textbox(label="Status")
|
190 |
|
191 |
+
# Menu Page
|
192 |
with gr.Row(visible=False) as menu_page:
|
193 |
with gr.Column():
|
194 |
preference = gr.Radio(["All", "Veg", "Non-Veg"], label="Filter Preference", value="All")
|
195 |
menu_output = gr.HTML()
|
196 |
+
submit_cart_button = gr.Button("Submit Cart")
|
197 |
+
cart_summary = gr.HTML(label="Cart Summary")
|
198 |
|
199 |
+
# Navigation and Functionality
|
200 |
login_button.click(
|
201 |
lambda email, password: (gr.update(visible=False), gr.update(visible=True), filter_menu("All"), "Login successful!")
|
202 |
+
if login(email, password)[0] == "Login successful!"
|
203 |
+
else (gr.update(), gr.update(), "Invalid email or password."),
|
204 |
[login_email, login_password],
|
205 |
[login_page, menu_page, menu_output, login_output]
|
206 |
)
|
207 |
|
|
|
208 |
submit_signup.click(
|
209 |
lambda name, email, phone, password: (signup(name, email, phone, password), gr.update(visible=False), gr.update(visible=True)),
|
210 |
[signup_name, signup_email, signup_phone, signup_password],
|
211 |
[signup_output, signup_page, login_page]
|
212 |
)
|
213 |
|
|
|
214 |
signup_redirect.click(
|
215 |
lambda: (gr.update(visible=False), gr.update(visible=True)),
|
216 |
[],
|
217 |
[login_page, signup_page]
|
218 |
)
|
219 |
|
|
|
220 |
login_redirect.click(
|
221 |
lambda: (gr.update(visible=True), gr.update(visible=False)),
|
222 |
[],
|
223 |
[login_page, signup_page]
|
224 |
)
|
225 |
|
|
|
226 |
submit_cart_button.click(
|
227 |
+
lambda: "Order submitted successfully!",
|
228 |
[],
|
229 |
+
[cart_summary]
|
|
|
230 |
)
|
231 |
|
232 |
app.launch()
|