lokesh341 commited on
Commit
c129ae7
·
verified ·
1 Parent(s): a0f415d

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +66 -74
templates/menu.html CHANGED
@@ -75,29 +75,45 @@
75
  .addbutton .btn:hover {
76
  background-color: #218838;
77
  }
 
 
 
 
 
 
 
78
  .customisable-text {
79
- color: #28a745;
80
- font-size: 12px;
81
- margin-left: 5px;
82
- margin-top: 1px;
 
83
  }
84
  .btn-primary {
85
- font-size: 13px;
86
  font-weight: bold;
87
- border-radius: 5px;
88
- width: 100px;
 
89
  background-color: #0FAA39;
90
  border-color: #0FAA39;
 
 
 
 
 
91
  }
92
  .btn-primary:hover {
93
- background-color: #0FAA39;
94
- border-color: #0FAA39;
 
95
  }
96
  .btn-primary:active,
97
  .btn-primary:focus {
98
- background-color: #0FAA39;
99
- border-color: #ffffff;
100
  box-shadow: none;
 
101
  }
102
  .view-cart-container {
103
  position: fixed;
@@ -309,7 +325,6 @@
309
  height: 40px;
310
  width: 40px;
311
  }
312
- /* Styles for Ingredients, Nutritional Info, and Allergens */
313
  .item-details {
314
  background-color: #f8f9fa;
315
  border-radius: 8px;
@@ -349,7 +364,6 @@
349
  .toggle-details:hover {
350
  text-decoration: underline;
351
  }
352
- /* Category Buttons */
353
  .category-buttons {
354
  display: flex;
355
  flex-wrap: wrap;
@@ -375,35 +389,33 @@
375
  .category-button:hover {
376
  background-color: #e6f4ea;
377
  }
378
- /* Quantity Selector for Soft Drinks */
379
  .quantity-selector {
380
  display: flex;
381
  align-items: center;
382
  gap: 5px;
383
  }
384
  .quantity-selector .btn {
385
- width: 30px;
386
- height: 30px;
387
  padding: 0;
388
- font-size: 14px;
389
- line-height: 30px;
390
  text-align: center;
391
  }
392
  .quantity-selector .quantity-display {
393
- width: 30px;
394
  text-align: center;
395
- font-size: 14px;
396
  font-weight: bold;
397
- line-height: 30px;
398
  }
399
  .quantity-selector .quantity-to-add,
400
  .quantity-selector .quantity-to-remove {
401
- width: 50px;
402
- height: 30px;
403
- font-size: 14px;
404
  padding: 0 5px;
405
  }
406
- /* Mobile View Adjustments */
407
  @media (max-width: 576px) {
408
  .fixed-top-bar {
409
  height: 60px;
@@ -448,6 +460,31 @@
448
  width: 40px;
449
  height: 35px;
450
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
451
  }
452
  </style>
453
  </head>
@@ -546,8 +583,6 @@
546
  ADD
547
  </button>
548
  {% endif %}
549
- </div>
550
- <div class="w-100 text-center">
551
  {% if item.Section__c != 'Apetizer' and item.Section__c != 'Customized dish' and item.Section__c !='Soft Drinks' %}
552
  <h5 class="customisable-text">Customisable</h5>
553
  {% endif %}
@@ -626,7 +661,6 @@
626
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
627
 
628
  <script>
629
- // Menu Item Details Data
630
  const menuItemDetails = {
631
  "Veg Manchurian": {
632
  ingredients: "Cauliflower, Onion, Ginger, Garlic, Soy Sauce, Cornflour, Green Chilies, Capsicum, Spring Onion",
@@ -720,7 +754,6 @@
720
  }
721
  };
722
 
723
- // Local Storage Fallback Functions (Temporary)
724
  function addToCartLocalStorage(payload) {
725
  let cart = JSON.parse(localStorage.getItem('cart')) || [];
726
  const existingItem = cart.find(item =>
@@ -759,7 +792,6 @@
759
  return JSON.parse(localStorage.getItem('cart')) || [];
760
  }
761
 
762
- // Populate Item Details on Page Load
763
  document.addEventListener('DOMContentLoaded', function () {
764
  const menuCards = document.querySelectorAll('.menu-card');
765
 
@@ -787,7 +819,6 @@
787
  }
788
  });
789
 
790
- // Lazy Load Menu Items and Images
791
  const menuImages = document.querySelectorAll('.menu-image');
792
 
793
  const cardObserver = new IntersectionObserver((entries, observer) => {
@@ -821,7 +852,6 @@
821
  menuCards.forEach(card => cardObserver.observe(card));
822
  menuImages.forEach(img => imageObserver.observe(img));
823
 
824
- // Toggle Details Functionality
825
  const toggleLinks = document.querySelectorAll('.toggle-details');
826
  toggleLinks.forEach(link => {
827
  link.addEventListener('click', function () {
@@ -832,7 +862,6 @@
832
  });
833
  });
834
 
835
- // Category Button Functionality
836
  const categoryButtons = document.querySelectorAll('.category-button');
837
  const categoryForm = document.getElementById('categoryForm');
838
  const selectedCategoryInput = document.getElementById('selectedCategoryInput');
@@ -852,7 +881,6 @@
852
  });
853
  });
854
 
855
- // Debounce Function for Search
856
  function debounce(func, wait) {
857
  let timeout;
858
  return function (...args) {
@@ -866,7 +894,7 @@
866
  document.getElementById('modal-price').innerText = `$${price}`;
867
  const modalImg = document.getElementById('modal-img');
868
  if (section.toLowerCase() === 'soft drinks') {
869
- modalImg.style.display = 'none'; // Hide image for Soft Drinks
870
  } else {
871
  modalImg.style.display = 'block';
872
  modalImg.src = image || '/static/placeholder.jpg';
@@ -1190,7 +1218,6 @@
1190
  .catch(err => {
1191
  console.error('Error adding item to cart:', err);
1192
  alert('An error occurred while adding the item to the cart: ' + err.message);
1193
- // Fallback to localStorage
1194
  const cart = addToCartLocalStorage(cartPayload);
1195
  updateCartUI(cart);
1196
  const modal = document.getElementById('itemModal');
@@ -1205,11 +1232,9 @@
1205
  const quantitySelector = buttonContainer.querySelector('.quantity-selector');
1206
  const quantityDisplay = quantitySelector.querySelector('.quantity-display');
1207
 
1208
- // Hide the ADD button and show the quantity selector
1209
  addButton.style.display = 'none';
1210
  quantitySelector.style.display = 'flex';
1211
 
1212
- // Add the item to the cart with quantity 1
1213
  const itemName = buttonContainer.getAttribute('data-item-name');
1214
  const itemPrice = parseFloat(buttonContainer.getAttribute('data-item-price'));
1215
  const itemImage = buttonContainer.getAttribute('data-item-image');
@@ -1244,11 +1269,10 @@
1244
  if (data.success) {
1245
  alert('Item added to cart successfully!');
1246
  updateCartUI(data.cart);
1247
- quantityDisplay.innerText = 1; // Set initial quantity
1248
  } else {
1249
  console.error('Failed to add item to cart:', data.error);
1250
  alert(data.error || 'Failed to add item to cart.');
1251
- // Revert UI if addition fails
1252
  addButton.style.display = 'block';
1253
  quantitySelector.style.display = 'none';
1254
  }
@@ -1256,7 +1280,6 @@
1256
  .catch(err => {
1257
  console.error('Error adding item to cart:', err);
1258
  alert('An error occurred while adding the item to the cart: ' + err.message);
1259
- // Fallback to localStorage
1260
  const cart = addToCartLocalStorage(cartPayload);
1261
  updateCartUI(cart);
1262
  quantityDisplay.innerText = 1;
@@ -1270,7 +1293,6 @@
1270
  const quantityToAdd = parseInt(quantityToAddSelect.value);
1271
  let currentQuantity = parseInt(quantityDisplay.innerText);
1272
 
1273
- // Update the displayed quantity
1274
  currentQuantity += quantityToAdd;
1275
  quantityDisplay.innerText = currentQuantity;
1276
 
@@ -1291,7 +1313,6 @@
1291
  quantity: quantityToAdd
1292
  };
1293
 
1294
- // Disable the button to prevent multiple clicks
1295
  button.disabled = true;
1296
 
1297
  fetch('/cart/add', {
@@ -1314,7 +1335,6 @@
1314
  } else {
1315
  console.error('Failed to add item to cart:', data.error);
1316
  alert(data.error || 'Failed to add item to cart.');
1317
- // Revert quantity if addition fails
1318
  currentQuantity -= quantityToAdd;
1319
  quantityDisplay.innerText = currentQuantity;
1320
  }
@@ -1322,12 +1342,11 @@
1322
  .catch(err => {
1323
  console.error('Error adding item to cart:', err);
1324
  alert('An error occurred while adding the item to the cart: ' + err.message);
1325
- // Fallback to localStorage
1326
  const cart = addToCartLocalStorage(cartPayload);
1327
  updateCartUI(cart);
1328
  })
1329
  .finally(() => {
1330
- button.disabled = false; // Re-enable the button
1331
  });
1332
  }
1333
 
@@ -1341,7 +1360,6 @@
1341
  let currentQuantity = parseInt(quantityDisplay.innerText);
1342
 
1343
  if (currentQuantity <= quantityToRemove) {
1344
- // Remove the item from the cart completely
1345
  const itemName = buttonContainer.getAttribute('data-item-name');
1346
  fetch(`/cart/remove?item_name=${encodeURIComponent(itemName)}&quantity=${currentQuantity}&instructions=&addons=[]`, {
1347
  method: 'POST',
@@ -1358,7 +1376,6 @@
1358
  .then(data => {
1359
  if (data.success) {
1360
  updateCartUI(data.cart);
1361
- // Hide quantity selector and show ADD button
1362
  addButton.style.display = 'block';
1363
  quantitySelector.style.display = 'none';
1364
  quantityDisplay.innerText = 0;
@@ -1370,7 +1387,6 @@
1370
  .catch(err => {
1371
  console.error('Error removing item from cart:', err);
1372
  alert('An error occurred while removing the item from the cart: ' + err.message);
1373
- // Fallback to localStorage
1374
  const cart = removeFromCartLocalStorage(itemName, currentQuantity, '', []);
1375
  updateCartUI(cart);
1376
  addButton.style.display = 'block';
@@ -1408,7 +1424,6 @@
1408
  .catch(err => {
1409
  console.error('Error removing item from cart:', err);
1410
  alert('An error occurred while removing the item from the cart: ' + err.message);
1411
- // Fallback to localStorage
1412
  const cart = removeFromCartLocalStorage(itemName, quantityToRemove, '', []);
1413
  updateCartUI(cart);
1414
  });
@@ -1425,7 +1440,6 @@
1425
  cartIcon.innerText = cart.length;
1426
  }
1427
 
1428
- // Update quantity displays for Soft Drinks
1429
  const buttonContainers = document.querySelectorAll('.button-container');
1430
  buttonContainers.forEach(container => {
1431
  const itemName = container.getAttribute('data-item-name');
@@ -1450,25 +1464,6 @@
1450
  });
1451
  }
1452
 
1453
- function updateCartDisplay(cart) {
1454
- if (!Array.isArray(cart)) {
1455
- console.error('Invalid cart data:', cart);
1456
- return;
1457
- }
1458
- const cartCountElement = document.getElementById('cart-count');
1459
- if (cartCountElement) {
1460
- cartCountElement.innerText = cart.reduce((total, item) => total + item.quantity, 0);
1461
- }
1462
-
1463
- const successNotification = document.createElement('div');
1464
- successNotification.classList.add('success-notification');
1465
- successNotification.innerText = 'Item added to cart!';
1466
- document.body.appendChild(successNotification);
1467
- setTimeout(() => {
1468
- successNotification.remove();
1469
- }, 2000);
1470
- }
1471
-
1472
  document.addEventListener('DOMContentLoaded', function () {
1473
  const decreaseBtn = document.getElementById('decreaseQuantity');
1474
  const increaseBtn = document.getElementById('increaseQuantity');
@@ -1488,7 +1483,6 @@
1488
  quantityInput.value = currentQuantity;
1489
  });
1490
 
1491
- // Fetch initial cart state to update UI
1492
  fetch('/cart/get')
1493
  .then(response => {
1494
  if (!response.ok) {
@@ -1501,18 +1495,16 @@
1501
  updateCartUI(data.cart);
1502
  } else {
1503
  console.error('Failed to fetch cart:', data.error);
1504
- // Fallback to localStorage
1505
  const cart = getCartLocalStorage();
1506
  updateCartUI(cart);
1507
  }
1508
  })
1509
  .catch(err => {
1510
  console.error('Error fetching cart:', err);
1511
- // Fallback to localStorage
1512
  const cart = getCartLocalStorage();
1513
  updateCartUI(cart);
1514
  });
1515
  });
1516
  </script>
1517
  </body>
1518
- </html>
 
75
  .addbutton .btn:hover {
76
  background-color: #218838;
77
  }
78
+ .button-container {
79
+ display: flex;
80
+ flex-direction: column;
81
+ align-items: center;
82
+ justify-content: center;
83
+ gap: 5px;
84
+ }
85
  .customisable-text {
86
+ color: #0FAA39;
87
+ font-size: 10px;
88
+ font-weight: 500;
89
+ margin: 0;
90
+ text-align: center;
91
  }
92
  .btn-primary {
93
+ font-size: 12px;
94
  font-weight: bold;
95
+ border-radius: 8px;
96
+ width: 70px;
97
+ height: 35px;
98
  background-color: #0FAA39;
99
  border-color: #0FAA39;
100
+ display: flex;
101
+ align-items: center;
102
+ justify-content: center;
103
+ padding: 0;
104
+ transition: background-color 0.3s ease, transform 0.1s ease;
105
  }
106
  .btn-primary:hover {
107
+ background-color: #0D9232;
108
+ border-color: #0D9232;
109
+ transform: scale(1.05);
110
  }
111
  .btn-primary:active,
112
  .btn-primary:focus {
113
+ background-color: #0B7A29;
114
+ border-color: #0B7A29;
115
  box-shadow: none;
116
+ transform: scale(0.98);
117
  }
118
  .view-cart-container {
119
  position: fixed;
 
325
  height: 40px;
326
  width: 40px;
327
  }
 
328
  .item-details {
329
  background-color: #f8f9fa;
330
  border-radius: 8px;
 
364
  .toggle-details:hover {
365
  text-decoration: underline;
366
  }
 
367
  .category-buttons {
368
  display: flex;
369
  flex-wrap: wrap;
 
389
  .category-button:hover {
390
  background-color: #e6f4ea;
391
  }
 
392
  .quantity-selector {
393
  display: flex;
394
  align-items: center;
395
  gap: 5px;
396
  }
397
  .quantity-selector .btn {
398
+ width: 25px;
399
+ height: 25px;
400
  padding: 0;
401
+ font-size: 12px;
402
+ line-height: 25px;
403
  text-align: center;
404
  }
405
  .quantity-selector .quantity-display {
406
+ width: 25px;
407
  text-align: center;
408
+ font-size: 12px;
409
  font-weight: bold;
410
+ line-height: 25px;
411
  }
412
  .quantity-selector .quantity-to-add,
413
  .quantity-selector .quantity-to-remove {
414
+ width: 45px;
415
+ height: 25px;
416
+ font-size: 12px;
417
  padding: 0 5px;
418
  }
 
419
  @media (max-width: 576px) {
420
  .fixed-top-bar {
421
  height: 60px;
 
460
  width: 40px;
461
  height: 35px;
462
  }
463
+ .btn-primary {
464
+ font-size: 11px;
465
+ width: 60px;
466
+ height: 30px;
467
+ }
468
+ .customisable-text {
469
+ font-size: 9px;
470
+ }
471
+ .quantity-selector .btn {
472
+ width: 20px;
473
+ height: 20px;
474
+ font-size: 10px;
475
+ line-height: 20px;
476
+ }
477
+ .quantity-selector .quantity-display {
478
+ width: 20px;
479
+ font-size: 10px;
480
+ line-height: 20px;
481
+ }
482
+ .quantity-selector .quantity-to-add,
483
+ .quantity-selector .quantity-to-remove {
484
+ width: 40px;
485
+ height: 20px;
486
+ font-size: 10px;
487
+ }
488
  }
489
  </style>
490
  </head>
 
583
  ADD
584
  </button>
585
  {% endif %}
 
 
586
  {% if item.Section__c != 'Apetizer' and item.Section__c != 'Customized dish' and item.Section__c !='Soft Drinks' %}
587
  <h5 class="customisable-text">Customisable</h5>
588
  {% endif %}
 
661
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
662
 
663
  <script>
 
664
  const menuItemDetails = {
665
  "Veg Manchurian": {
666
  ingredients: "Cauliflower, Onion, Ginger, Garlic, Soy Sauce, Cornflour, Green Chilies, Capsicum, Spring Onion",
 
754
  }
755
  };
756
 
 
757
  function addToCartLocalStorage(payload) {
758
  let cart = JSON.parse(localStorage.getItem('cart')) || [];
759
  const existingItem = cart.find(item =>
 
792
  return JSON.parse(localStorage.getItem('cart')) || [];
793
  }
794
 
 
795
  document.addEventListener('DOMContentLoaded', function () {
796
  const menuCards = document.querySelectorAll('.menu-card');
797
 
 
819
  }
820
  });
821
 
 
822
  const menuImages = document.querySelectorAll('.menu-image');
823
 
824
  const cardObserver = new IntersectionObserver((entries, observer) => {
 
852
  menuCards.forEach(card => cardObserver.observe(card));
853
  menuImages.forEach(img => imageObserver.observe(img));
854
 
 
855
  const toggleLinks = document.querySelectorAll('.toggle-details');
856
  toggleLinks.forEach(link => {
857
  link.addEventListener('click', function () {
 
862
  });
863
  });
864
 
 
865
  const categoryButtons = document.querySelectorAll('.category-button');
866
  const categoryForm = document.getElementById('categoryForm');
867
  const selectedCategoryInput = document.getElementById('selectedCategoryInput');
 
881
  });
882
  });
883
 
 
884
  function debounce(func, wait) {
885
  let timeout;
886
  return function (...args) {
 
894
  document.getElementById('modal-price').innerText = `$${price}`;
895
  const modalImg = document.getElementById('modal-img');
896
  if (section.toLowerCase() === 'soft drinks') {
897
+ modalImg.style.display = 'none';
898
  } else {
899
  modalImg.style.display = 'block';
900
  modalImg.src = image || '/static/placeholder.jpg';
 
1218
  .catch(err => {
1219
  console.error('Error adding item to cart:', err);
1220
  alert('An error occurred while adding the item to the cart: ' + err.message);
 
1221
  const cart = addToCartLocalStorage(cartPayload);
1222
  updateCartUI(cart);
1223
  const modal = document.getElementById('itemModal');
 
1232
  const quantitySelector = buttonContainer.querySelector('.quantity-selector');
1233
  const quantityDisplay = quantitySelector.querySelector('.quantity-display');
1234
 
 
1235
  addButton.style.display = 'none';
1236
  quantitySelector.style.display = 'flex';
1237
 
 
1238
  const itemName = buttonContainer.getAttribute('data-item-name');
1239
  const itemPrice = parseFloat(buttonContainer.getAttribute('data-item-price'));
1240
  const itemImage = buttonContainer.getAttribute('data-item-image');
 
1269
  if (data.success) {
1270
  alert('Item added to cart successfully!');
1271
  updateCartUI(data.cart);
1272
+ quantityDisplay.innerText = 1;
1273
  } else {
1274
  console.error('Failed to add item to cart:', data.error);
1275
  alert(data.error || 'Failed to add item to cart.');
 
1276
  addButton.style.display = 'block';
1277
  quantitySelector.style.display = 'none';
1278
  }
 
1280
  .catch(err => {
1281
  console.error('Error adding item to cart:', err);
1282
  alert('An error occurred while adding the item to the cart: ' + err.message);
 
1283
  const cart = addToCartLocalStorage(cartPayload);
1284
  updateCartUI(cart);
1285
  quantityDisplay.innerText = 1;
 
1293
  const quantityToAdd = parseInt(quantityToAddSelect.value);
1294
  let currentQuantity = parseInt(quantityDisplay.innerText);
1295
 
 
1296
  currentQuantity += quantityToAdd;
1297
  quantityDisplay.innerText = currentQuantity;
1298
 
 
1313
  quantity: quantityToAdd
1314
  };
1315
 
 
1316
  button.disabled = true;
1317
 
1318
  fetch('/cart/add', {
 
1335
  } else {
1336
  console.error('Failed to add item to cart:', data.error);
1337
  alert(data.error || 'Failed to add item to cart.');
 
1338
  currentQuantity -= quantityToAdd;
1339
  quantityDisplay.innerText = currentQuantity;
1340
  }
 
1342
  .catch(err => {
1343
  console.error('Error adding item to cart:', err);
1344
  alert('An error occurred while adding the item to the cart: ' + err.message);
 
1345
  const cart = addToCartLocalStorage(cartPayload);
1346
  updateCartUI(cart);
1347
  })
1348
  .finally(() => {
1349
+ button.disabled = false;
1350
  });
1351
  }
1352
 
 
1360
  let currentQuantity = parseInt(quantityDisplay.innerText);
1361
 
1362
  if (currentQuantity <= quantityToRemove) {
 
1363
  const itemName = buttonContainer.getAttribute('data-item-name');
1364
  fetch(`/cart/remove?item_name=${encodeURIComponent(itemName)}&quantity=${currentQuantity}&instructions=&addons=[]`, {
1365
  method: 'POST',
 
1376
  .then(data => {
1377
  if (data.success) {
1378
  updateCartUI(data.cart);
 
1379
  addButton.style.display = 'block';
1380
  quantitySelector.style.display = 'none';
1381
  quantityDisplay.innerText = 0;
 
1387
  .catch(err => {
1388
  console.error('Error removing item from cart:', err);
1389
  alert('An error occurred while removing the item from the cart: ' + err.message);
 
1390
  const cart = removeFromCartLocalStorage(itemName, currentQuantity, '', []);
1391
  updateCartUI(cart);
1392
  addButton.style.display = 'block';
 
1424
  .catch(err => {
1425
  console.error('Error removing item from cart:', err);
1426
  alert('An error occurred while removing the item from the cart: ' + err.message);
 
1427
  const cart = removeFromCartLocalStorage(itemName, quantityToRemove, '', []);
1428
  updateCartUI(cart);
1429
  });
 
1440
  cartIcon.innerText = cart.length;
1441
  }
1442
 
 
1443
  const buttonContainers = document.querySelectorAll('.button-container');
1444
  buttonContainers.forEach(container => {
1445
  const itemName = container.getAttribute('data-item-name');
 
1464
  });
1465
  }
1466
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1467
  document.addEventListener('DOMContentLoaded', function () {
1468
  const decreaseBtn = document.getElementById('decreaseQuantity');
1469
  const increaseBtn = document.getElementById('increaseQuantity');
 
1483
  quantityInput.value = currentQuantity;
1484
  });
1485
 
 
1486
  fetch('/cart/get')
1487
  .then(response => {
1488
  if (!response.ok) {
 
1495
  updateCartUI(data.cart);
1496
  } else {
1497
  console.error('Failed to fetch cart:', data.error);
 
1498
  const cart = getCartLocalStorage();
1499
  updateCartUI(cart);
1500
  }
1501
  })
1502
  .catch(err => {
1503
  console.error('Error fetching cart:', err);
 
1504
  const cart = getCartLocalStorage();
1505
  updateCartUI(cart);
1506
  });
1507
  });
1508
  </script>
1509
  </body>
1510
+ </html>