Rammohan0504 commited on
Commit
48c87bf
·
verified ·
1 Parent(s): 0507cc4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -5
app.py CHANGED
@@ -83,8 +83,18 @@ menu_data = [
83
  # The rest of the code remains unchanged
84
 
85
 
 
86
  spice_levels = ["American Mild", "American Medium", "American Spicy",
87
  "Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"]
 
 
 
 
 
 
 
 
 
88
 
89
  # Filter dishes by category
90
  def filter_dishes(category):
@@ -132,7 +142,7 @@ with gr.Blocks() as demo:
132
  dish_display = gr.HTML(value=display_dishes("ALL"))
133
 
134
  # JavaScript for managing the pop-up
135
- gr.HTML("""
136
  <div id="popup" style="display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
137
  background-color: white; padding: 20px; border-radius: 10px;
138
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;">
@@ -142,9 +152,14 @@ with gr.Blocks() as demo:
142
  <p id="popup-price" style="margin-top: 10px; font-size: 16px; color: #444;"></p>
143
 
144
  <h4 style="text-align: left; margin-top: 20px;">Choose a spice level</h4>
145
- <form id="spice-levels">
146
- """ + "".join([f'<label style="margin-right: 10px;"><input type="radio" name="spice" value="{spice}" style="margin-right: 5px;">{spice}</label>' for spice in spice_levels]) + """
147
- </form>
 
 
 
 
 
148
 
149
  <button onclick="addToCart(document.getElementById('popup-title').textContent, document.querySelector('input[name=spice]:checked').value)"
150
  style="margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none;
@@ -166,7 +181,8 @@ with gr.Blocks() as demo:
166
  document.getElementById('popup').style.display = 'none';
167
  }
168
  function addToCart(dishName, spiceLevel) {
169
- alert(dishName + " with " + spiceLevel + " spice level has been added to the cart!");
 
170
  }
171
  </script>
172
  """)
 
83
  # The rest of the code remains unchanged
84
 
85
 
86
+ # Spice levels and extras
87
  spice_levels = ["American Mild", "American Medium", "American Spicy",
88
  "Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"]
89
+ extras = [
90
+ {"name": "Extra Raitha 4oz", "price": "$1.00"},
91
+ {"name": "Extra Raitha 8oz", "price": "$2.00"},
92
+ {"name": "Extra Salan 4oz", "price": "$1.00"},
93
+ {"name": "Extra Salan 8oz", "price": "$2.00"},
94
+ {"name": "Extra Onion", "price": "$1.00"},
95
+ {"name": "Extra Onion & Lemon", "price": "$2.00"},
96
+ {"name": "Extra Fried Onion 4oz", "price": "$2.00"},
97
+ ]
98
 
99
  # Filter dishes by category
100
  def filter_dishes(category):
 
142
  dish_display = gr.HTML(value=display_dishes("ALL"))
143
 
144
  # JavaScript for managing the pop-up
145
+ gr.HTML(f"""
146
  <div id="popup" style="display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
147
  background-color: white; padding: 20px; border-radius: 10px;
148
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;">
 
152
  <p id="popup-price" style="margin-top: 10px; font-size: 16px; color: #444;"></p>
153
 
154
  <h4 style="text-align: left; margin-top: 20px;">Choose a spice level</h4>
155
+ <div style="display: flex; flex-wrap: wrap; justify-content: space-between; border: 1px solid #ddd; padding: 10px; border-radius: 5px;">
156
+ """ + "".join([f'<label style="margin-right: 10px; display: block;"><input type="radio" name="spice" value="{spice}" style="margin-right: 5px;">{spice}</label>' for spice in spice_levels]) + """
157
+ </div>
158
+
159
+ <h4 style="text-align: left; margin-top: 20px;">Choose Extras</h4>
160
+ <div style="display: flex; flex-wrap: wrap; justify-content: space-between; border: 1px solid #ddd; padding: 10px; border-radius: 5px;">
161
+ """ + "".join([f'<label style="margin-right: 10px; display: block;"><input type="checkbox" name="extras" value="{extra["name"]}" style="margin-right: 5px;">{extra["name"]} + {extra["price"]}</label>' for extra in extras]) + """
162
+ </div>
163
 
164
  <button onclick="addToCart(document.getElementById('popup-title').textContent, document.querySelector('input[name=spice]:checked').value)"
165
  style="margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none;
 
181
  document.getElementById('popup').style.display = 'none';
182
  }
183
  function addToCart(dishName, spiceLevel) {
184
+ const selectedExtras = Array.from(document.querySelectorAll('input[name=extras]:checked')).map(cb => cb.value).join(", ");
185
+ alert(dishName + " with " + spiceLevel + " spice level and extras: " + selectedExtras + " has been added to the cart!");
186
  }
187
  </script>
188
  """)