lokesh341 commited on
Commit
13a827e
·
verified ·
1 Parent(s): d1dea61

Update templates/search.html

Browse files
Files changed (1) hide show
  1. templates/search.html +237 -6
templates/search.html CHANGED
@@ -7,7 +7,6 @@
7
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
8
  <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
9
  <style>
10
- /* Reuse styles from menu.html */
11
  body {
12
  font-family: Arial, sans-serif;
13
  background-color: #fdf4e3;
@@ -93,7 +92,6 @@
93
  margin-top: 20px;
94
  }
95
  .menu-card {
96
- /* Copy relevant styles from menu.html */
97
  max-width: 350px;
98
  border-radius: 15px;
99
  overflow: hidden;
@@ -103,7 +101,78 @@
103
  flex-direction: column;
104
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
105
  }
106
- /* Add other necessary styles from menu.html */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  </style>
108
  </head>
109
  <body>
@@ -151,9 +220,44 @@
151
  </div>
152
  </div>
153
 
154
- <!-- Item Modal (copied from menu.html) -->
155
  <div class="modal fade" id="itemModal" tabindex="-1" aria-labelledby="itemModalLabel" aria-hidden="true">
156
- <!-- Same modal content as in menu.html -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  </div>
158
 
159
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
@@ -227,7 +331,134 @@
227
  }
228
  });
229
 
230
- // Add your showItemDetails function and other necessary JavaScript from menu.html
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  });
232
  </script>
233
  </body>
 
7
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
8
  <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
9
  <style>
 
10
  body {
11
  font-family: Arial, sans-serif;
12
  background-color: #fdf4e3;
 
92
  margin-top: 20px;
93
  }
94
  .menu-card {
 
95
  max-width: 350px;
96
  border-radius: 15px;
97
  overflow: hidden;
 
101
  flex-direction: column;
102
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
103
  }
104
+ .menu-video {
105
+ height: 200px;
106
+ width: 100%;
107
+ object-fit: cover;
108
+ border-radius: 15px 15px 0 0;
109
+ }
110
+ .card-body .card-title {
111
+ font-size: 1.2rem;
112
+ font-weight: 600;
113
+ margin: 10px 0;
114
+ color: #333333;
115
+ }
116
+ .card-body .card-text.price {
117
+ font-size: 1rem;
118
+ font-weight: 500;
119
+ color: #000000;
120
+ margin-bottom: 5px;
121
+ }
122
+ .btn-primary {
123
+ font-size: 12px;
124
+ font-weight: bold;
125
+ border-radius: 8px;
126
+ width: 70px;
127
+ height: 35px;
128
+ background-color: #0FAA39;
129
+ border-color: #0FAA39;
130
+ display: flex;
131
+ align-items: center;
132
+ justify-content: center;
133
+ padding: 0;
134
+ }
135
+ /* Full-page modal styling */
136
+ .modal-fullscreen {
137
+ width: 100vw;
138
+ max-width: none;
139
+ height: 100%;
140
+ margin: 0;
141
+ }
142
+ .modal-fullscreen .modal-content {
143
+ height: 100%;
144
+ border: none;
145
+ border-radius: 0;
146
+ }
147
+ .modal-body {
148
+ max-height: 70vh;
149
+ overflow-y: auto;
150
+ padding: 15px;
151
+ text-align: center;
152
+ }
153
+ .modal-footer {
154
+ display: flex;
155
+ align-items: center;
156
+ justify-content: space-between;
157
+ padding: 10px;
158
+ }
159
+ .modal-footer .btn-primary {
160
+ width: auto;
161
+ padding: 10px 20px;
162
+ height: 40px;
163
+ }
164
+ .addon-section {
165
+ background-color: #fff;
166
+ border: 2px solid #ffa500;
167
+ border-radius: 8px;
168
+ padding: 12px;
169
+ margin-bottom: 10px;
170
+ }
171
+ .addon-section h6 {
172
+ margin-bottom: 10px;
173
+ font-size: 1.1rem;
174
+ font-weight: bold;
175
+ }
176
  </style>
177
  </head>
178
  <body>
 
220
  </div>
221
  </div>
222
 
223
+ <!-- Item Modal (Full-page version from menu.html) -->
224
  <div class="modal fade" id="itemModal" tabindex="-1" aria-labelledby="itemModalLabel" aria-hidden="true">
225
+ <div class="modal-dialog modal-fullscreen">
226
+ <div class="modal-content">
227
+ <div class="modal-header">
228
+ <h5 class="modal-title" id="itemModalLabel">Item Details</h5>
229
+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
230
+ </div>
231
+ <div class="modal-body">
232
+ <img id="modal-img" class="img-fluid rounded mb-3 d-block mx-auto" alt="Item Image" style="max-height: 200px; object-fit: cover;">
233
+ <h5 id="modal-name" class="fw-bold text-center"></h5>
234
+ <p id="modal-price" class="text-muted text-center"></p>
235
+ <p id="modal-description" class="text-secondary"></p>
236
+ <div class="nutritional-info">
237
+ <strong>Ingredients:</strong> <span id="modal-ingredients"></span><br>
238
+ <strong>Nutrition:</strong> <span id="modal-nutrition"></span><br>
239
+ <strong>Allergens:</strong> <span id="modal-allergens"></span>
240
+ </div>
241
+ <div id="modal-addons" class="modal-addons mt-4">
242
+ <h6>Customization Options</h6>
243
+ <div id="addons-list" class="addons-container">Loading customization options...</div>
244
+ </div>
245
+ <div class="mt-4">
246
+ <h6>Custom Request</h6>
247
+ <textarea id="modal-instructions" class="form-control" placeholder="Enter any special instructions here..."></textarea>
248
+ </div>
249
+ <span id="modal-section" data-section="" data-category="" style="display: none;"></span>
250
+ </div>
251
+ <div class="modal-footer d-flex align-items-center justify-content-between">
252
+ <div class="d-flex align-items-center gap-2">
253
+ <button type="button" class="btn btn-outline-secondary" id="decreaseQuantity">-</button>
254
+ <input type="text" class="form-control text-center" id="quantityInput" value="1" readonly style="width: 50px;"/>
255
+ <button type="button" class="btn btn-outline-secondary" id="increaseQuantity">+</button>
256
+ </div>
257
+ <button type="button" class="btn btn-primary" onclick="addToCartFromModal()">Add to Cart</button>
258
+ </div>
259
+ </div>
260
+ </div>
261
  </div>
262
 
263
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
 
331
  }
332
  });
333
 
334
+ // Quantity controls
335
+ const decreaseBtn = document.getElementById('decreaseQuantity');
336
+ const increaseBtn = document.getElementById('increaseQuantity');
337
+ const quantityInput = document.getElementById('quantityInput');
338
+
339
+ decreaseBtn.addEventListener('click', function () {
340
+ let currentQuantity = parseInt(quantityInput.value);
341
+ if (currentQuantity > 1) {
342
+ currentQuantity--;
343
+ quantityInput.value = currentQuantity;
344
+ }
345
+ });
346
+
347
+ increaseBtn.addEventListener('click', function () {
348
+ let currentQuantity = parseInt(quantityInput.value);
349
+ currentQuantity++;
350
+ quantityInput.value = currentQuantity;
351
+ });
352
+
353
+ // Item details and cart functionality
354
+ window.showItemDetails = function(name, price, image, description, ingredients, nutrition, allergens, section, selectedCategory) {
355
+ document.getElementById('modal-name').innerText = name;
356
+ document.getElementById('modal-price').innerText = `$${price}`;
357
+ const modalImg = document.getElementById('modal-img');
358
+ modalImg.src = image || '/static/placeholder.jpg';
359
+ document.getElementById('modal-description').innerText = description || 'No description available.';
360
+ document.getElementById('modal-ingredients').innerText = ingredients || 'Not specified';
361
+ document.getElementById('modal-nutrition').innerText = nutrition || 'Not available';
362
+ document.getElementById('modal-allergens').innerText = allergens || 'None listed';
363
+ document.getElementById('addons-list').innerHTML = 'Loading customization options...';
364
+ document.getElementById('modal-instructions').value = '';
365
+ const modalSectionEl = document.getElementById('modal-section');
366
+ modalSectionEl.setAttribute('data-section', section);
367
+ modalSectionEl.setAttribute('data-category', selectedCategory);
368
+ document.getElementById('quantityInput').value = 1;
369
+
370
+ fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
371
+ .then(response => response.json())
372
+ .then(data => {
373
+ const addonsList = document.getElementById('addons-list');
374
+ addonsList.innerHTML = '';
375
+ if (!data.success || !data.addons || data.addons.length === 0) {
376
+ addonsList.innerHTML = '<p>No customization options available.</p>';
377
+ return;
378
+ }
379
+ data.addons.forEach(addon => {
380
+ const sectionDiv = document.createElement('div');
381
+ sectionDiv.classList.add('addon-section');
382
+ const title = document.createElement('h6');
383
+ title.innerText = addon.name;
384
+ sectionDiv.appendChild(title);
385
+ const optionsContainer = document.createElement('div');
386
+ addon.options.forEach((option, index) => {
387
+ const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
388
+ const listItem = document.createElement('div');
389
+ listItem.classList.add('form-check');
390
+ listItem.innerHTML = `
391
+ <input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}"
392
+ data-name="${option}" data-group="${addon.name}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
393
+ <label class="form-check-label" for="${optionId}">
394
+ ${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
395
+ </label>
396
+ `;
397
+ optionsContainer.appendChild(listItem);
398
+ });
399
+ sectionDiv.appendChild(optionsContainer);
400
+ addonsList.appendChild(sectionDiv);
401
+ });
402
+ })
403
+ .catch(err => {
404
+ console.error('Error fetching add-ons:', err);
405
+ document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
406
+ });
407
+ };
408
+
409
+ window.addToCartFromModal = function() {
410
+ const itemName = document.getElementById('modal-name').innerText;
411
+ const itemPrice = parseFloat(document.getElementById('modal-price').innerText.replace('$', ''));
412
+ const itemImage = document.getElementById('modal-img').src;
413
+ const instructions = document.getElementById('modal-instructions').value;
414
+ const quantity = parseInt(document.getElementById('quantityInput').value);
415
+ const modalSectionEl = document.getElementById('modal-section');
416
+ const section = modalSectionEl.getAttribute('data-section');
417
+ const selectedCategory = modalSectionEl.getAttribute('data-category');
418
+
419
+ const addons = [];
420
+ document.querySelectorAll('.addon-option:checked').forEach(checkbox => {
421
+ addons.push({
422
+ name: checkbox.getAttribute('data-name'),
423
+ price: parseFloat(checkbox.getAttribute('data-price')) || 0
424
+ });
425
+ });
426
+
427
+ const cartPayload = {
428
+ itemName: itemName,
429
+ itemPrice: itemPrice,
430
+ itemImage: itemImage,
431
+ section: section,
432
+ category: selectedCategory,
433
+ addons: addons,
434
+ instructions: instructions,
435
+ quantity: quantity
436
+ };
437
+
438
+ fetch('/cart/add', {
439
+ method: 'POST',
440
+ headers: {
441
+ 'Content-Type': 'application/json',
442
+ },
443
+ body: JSON.stringify(cartPayload)
444
+ })
445
+ .then(response => response.json())
446
+ .then(data => {
447
+ if (data.success) {
448
+ alert('Item added to cart successfully!');
449
+ const modal = bootstrap.Modal.getInstance(document.getElementById('itemModal'));
450
+ modal.hide();
451
+ // Optionally update cart UI here if you add a cart badge
452
+ } else {
453
+ console.error('Failed to add item to cart:', data.error);
454
+ alert(data.error || 'Failed to add item to cart.');
455
+ }
456
+ })
457
+ .catch(err => {
458
+ console.error('Error adding item to cart:', err);
459
+ alert('Error adding item to cart.');
460
+ });
461
+ };
462
  });
463
  </script>
464
  </body>