DSatishchandra commited on
Commit
73736ef
·
verified ·
1 Parent(s): 08b9b8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -53
app.py CHANGED
@@ -75,60 +75,58 @@ def app():
75
  # Modal window
76
  modal_window = gr.HTML("""
77
  <div id="modal" style="
78
- display: none;
79
- position: fixed;
80
- top: 50%;
81
- left: 50%;
82
- transform: translate(-50%, -50%);
83
- width: 90%;
84
- max-width: 600px;
85
- max-height: 90%;
86
- background: white;
87
- border-radius: 8px;
88
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
89
- padding: 20px;
90
- z-index: 1000;
91
  overflow-y: auto;
 
92
  ">
93
  <div style="text-align: right;">
94
- <button onclick="closeModal()" style="background: none; border: none; font-size: 18px; cursor: pointer;">&times;</button>
 
 
 
 
 
 
95
  </div>
96
- <img id="modal-image" style="width: 100%; height: auto; border-radius: 8px; margin-bottom: 20px;" />
97
- <h2 id="modal-name" style="margin-bottom: 10px;"></h2>
98
- <p id="modal-description" style="margin-bottom: 10px;"></p>
99
- <p id="modal-price" style="margin-bottom: 20px;"></p>
100
-
101
- <!-- Spice Levels -->
102
- <label for="spice-level" style="font-weight: bold;">Choose a Spice Level (Required):</label>
103
- <div id="spice-level-options" style="display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0;">
104
- <label><input type="radio" name="spice-level" value="American Mild" required /> American Mild</label>
105
- <label><input type="radio" name="spice-level" value="American Medium" required /> American Medium</label>
106
- <label><input type="radio" name="spice-level" value="American Spicy" required /> American Spicy</label>
107
- <label><input type="radio" name="spice-level" value="Indian Mild" required /> Indian Mild</label>
108
- <label><input type="radio" name="spice-level" value="Indian Medium" required /> Indian Medium</label>
109
- <label><input type="radio" name="spice-level" value="Indian Very Spicy" required /> Indian Very Spicy</label>
 
 
 
 
 
 
 
 
 
 
 
 
110
  </div>
111
-
112
- <!-- Biryani Extras -->
113
- <label for="biryani-extras" style="font-weight: bold;">Biryani Extras (Optional - Choose as many as you like):</label>
114
- <div id="biryani-extras-options" style="display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0;">
115
- <label><input type="checkbox" name="biryani-extra" value="Extra Raitha 4oz" /> Extra Raitha 4oz + $1.00</label>
116
- <label><input type="checkbox" name="biryani-extra" value="Extra Raitha 8oz" /> Extra Raitha 8oz + $2.00</label>
117
- <label><input type="checkbox" name="biryani-extra" value="Extra Salan 4oz" /> Extra Salan 4oz + $1.00</label>
118
- <label><input type="checkbox" name="biryani-extra" value="Extra Salan 8oz" /> Extra Salan 8oz + $2.00</label>
119
- <label><input type="checkbox" name="biryani-extra" value="Extra Onion" /> Extra Onion + $1.00</label>
120
- <label><input type="checkbox" name="biryani-extra" value="Extra Onion & Lemon" /> Extra Onion & Lemon + $2.00</label>
121
- <label><input type="checkbox" name="biryani-extra" value="Extra Fried Onion" /> Extra Fried Onion 4oz + $2.00</label>
122
- </div>
123
-
124
- <!-- Quantity and Special Instructions -->
125
- <label for="quantity" style="font-weight: bold;">Quantity:</label>
126
- <input type="number" id="quantity" value="1" min="1" style="width: 50px; margin-bottom: 10px;" />
127
- <br>
128
- <textarea id="special-instructions" placeholder="Add special instructions here..." style="width: 100%; height: 60px; margin-bottom: 20px;"></textarea>
129
-
130
- <!-- Add to Cart Button -->
131
- <button style="background-color: #28a745; color: white; border: none; padding: 10px 20px; font-size: 14px; border-radius: 5px; cursor: pointer;" onclick="addToCart()">Add to Cart</button>
132
  </div>
133
 
134
  <script>
@@ -150,11 +148,8 @@ def app():
150
  function addToCart() {
151
  const name = document.getElementById('modal-name').innerText;
152
  const price = document.getElementById('modal-price').innerText;
153
- const spiceLevel = document.querySelector('input[name="spice-level"]:checked')?.value || "Not Selected";
154
  const quantity = parseInt(document.getElementById('quantity').value) || 1;
155
- const instructions = document.getElementById('special-instructions').value;
156
- const extras = Array.from(document.querySelectorAll('input[name="biryani-extra"]:checked')).map(extra => extra.value);
157
- const cartItem = { name, price, spiceLevel, quantity, instructions, extras };
158
  cart.push(cartItem);
159
  fetch("/update_cart", {
160
  method: "POST",
 
75
  # Modal window
76
  modal_window = gr.HTML("""
77
  <div id="modal" style="
78
+ display: none;
79
+ position: fixed;
80
+ top: 50%;
81
+ left: 50%;
82
+ transform: translate(-50%, -50%);
83
+ width: 90%;
84
+ max-width: 500px;
85
+ max-height: 90%;
86
+ background: white;
87
+ border-radius: 15px;
88
+ box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
89
+ padding: 20px;
90
+ z-index: 1000;
91
  overflow-y: auto;
92
+ font-family: Arial, sans-serif;
93
  ">
94
  <div style="text-align: right;">
95
+ <button onclick="closeModal()" style="
96
+ background: none;
97
+ border: none;
98
+ font-size: 24px;
99
+ cursor: pointer;
100
+ color: #333;
101
+ ">&times;</button>
102
  </div>
103
+ <img id="modal-image" style="
104
+ width: 100%;
105
+ height: auto;
106
+ border-radius: 12px;
107
+ margin-bottom: 15px;
108
+ " />
109
+ <h2 id="modal-name" style="margin-bottom: 10px; font-size: 22px; color: #333;"></h2>
110
+ <p id="modal-description" style="margin-bottom: 10px; color: #555; font-size: 16px;"></p>
111
+ <p id="modal-price" style="margin-bottom: 20px; font-size: 18px; font-weight: bold; color: #222;"></p>
112
+ <div style="display: flex; justify-content: space-between; align-items: center;">
113
+ <label for="quantity" style="font-weight: bold;">Quantity:</label>
114
+ <input type="number" id="quantity" value="1" min="1" style="
115
+ width: 60px;
116
+ padding: 5px;
117
+ border: 1px solid #ccc;
118
+ border-radius: 5px;
119
+ " />
120
+ <button style="
121
+ background-color: #28a745;
122
+ color: white;
123
+ border: none;
124
+ padding: 10px 20px;
125
+ font-size: 16px;
126
+ border-radius: 8px;
127
+ cursor: pointer;
128
+ " onclick="addToCart()">Add</button>
129
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  </div>
131
 
132
  <script>
 
148
  function addToCart() {
149
  const name = document.getElementById('modal-name').innerText;
150
  const price = document.getElementById('modal-price').innerText;
 
151
  const quantity = parseInt(document.getElementById('quantity').value) || 1;
152
+ const cartItem = { name, price, quantity };
 
 
153
  cart.push(cartItem);
154
  fetch("/update_cart", {
155
  method: "POST",