Spaces:
Runtime error
Runtime error
File size: 19,328 Bytes
d1dea61 a8784d0 d1dea61 34e95e1 0f056d7 a8784d0 527f1a4 a8784d0 34e95e1 5842196 34e95e1 a8784d0 34e95e1 c13feb6 a8784d0 34e95e1 c13feb6 34e95e1 c13feb6 d1dea61 34e95e1 d1dea61 34e95e1 d1dea61 34e95e1 d1dea61 527f1a4 d1dea61 a8784d0 d1dea61 a8784d0 34e95e1 a8784d0 34e95e1 527f1a4 a8784d0 34e95e1 a8784d0 34e95e1 a8784d0 34e95e1 a8784d0 34e95e1 a8784d0 34e95e1 a8784d0 34e95e1 a8784d0 d1dea61 a8784d0 db48a04 a8784d0 13a827e a8784d0 34e95e1 13a827e a8784d0 c13feb6 a8784d0 c13feb6 a8784d0 527f1a4 a8784d0 13a827e d1dea61 34e95e1 c13feb6 d9bcfb4 c13feb6 a8784d0 3d1786f a8784d0 527f1a4 5842196 34e95e1 a8784d0 205860b a8784d0 34e95e1 a8784d0 34e95e1 d1dea61 a8784d0 d1dea61 a8784d0 5236b64 34e95e1 d1dea61 34e95e1 a8784d0 34e95e1 d1dea61 a8784d0 34e95e1 a8784d0 5236b64 a8784d0 5236b64 a8784d0 527f1a4 205860b 527f1a4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search Menu</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
<style>
body {
font-family: Arial, sans-serif;
background-color: #fdf4e3;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
padding-bottom: 70px;
}
.container {
max-width: 900px;
}
.menu-card {
max-width: 350px;
border-radius: 15px;
overflow: hidden;
background-color: #fff;
margin: auto;
display: flex;
flex-direction: column;
opacity: 0;
transition: opacity 0.3s ease-in-out;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
cursor: pointer;
}
.menu-card.visible {
opacity: 1;
}
.menu-card:hover {
transform: scale(1.05);
box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}
.menu-card img {
height: 200px;
width: 100%;
object-fit: cover;
border-radius: 15px 15px 0 0;
background-color: #000;
}
.menu-card .card-body .card-title {
font-size: 1.2rem;
font-weight: 600;
margin: 10px 0;
color: #333333;
text-align: center;
}
.menu-card .card-body .card-text.section {
font-size: 0.9rem;
color: #6c757d;
text-align: center;
margin-bottom: 10px;
}
.avatar-dropdown-container {
position: absolute;
right: 10px;
top: 50%;
transform: translateY(-50%);
display: flex;
align-items: center;
justify-content: center;
}
.avatar-icon {
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #007bff;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 20px;
font-weight: bold;
}
.dropdown-menu {
position: absolute;
right: 0;
top: 100%;
background-color: #fff8f0;
border-radius: 5px;
width: 220px;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
display: none;
border: 1px solid #ffd8b1;
}
.dropdown-menu .dropdown-item {
padding: 12px 16px;
text-decoration: none;
color: #333;
border-bottom: 1px solid #ffd8b1;
display: block;
font-size: 15px;
transition: background-color 0.2s ease;
}
.dropdown-menu .dropdown-item:last-child {
border-bottom: none;
}
.dropdown-menu .dropdown-item:hover {
background-color: #ffe4c4;
color: #333;
}
.fixed-top-bar {
position: relative;
top: 0;
left: 0;
width: 100%;
height: 54px;
background: linear-gradient(45deg, #FFA07A, #FFB347);
color: white;
padding: 15px;
display: flex;
justify-content: space-between;
align-items: center;
z-index: 1000;
}
.back-arrow-container {
position: absolute;
left: 10px;
top: 50%;
transform: translateY(-50%);
display: flex;
align-items: center;
justify-content: center;
}
.back-arrow {
width: 36px;
height: 36px;
border-radius: 50%;
background: linear-gradient(45deg, #FFA07A, #FFB347);
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 20px;
cursor: pointer;
transition: transform 0.2s ease, background-color 0.2s ease;
text-decoration: none;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.back-arrow:hover {
background: linear-gradient(45deg, #FF8C61, #FF9E2C);
transform: scale(1.1);
}
.back-arrow:active {
transform: scale(0.95);
}
.search-bar-container {
position: absolute;
left: 60px;
top: 50%;
transform: translateY(-50%);
display: flex;
align-items: center;
width: 300px;
max-width: calc(90% - 60px);
}
.search-bar-container input {
width: 100%;
padding: 8px 40px 8px 40px;
font-size: 16px;
border-radius: 25px;
border: none;
background-color: #fff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
outline: none;
transition: border-bottom 0.3s ease;
}
.search-bar-container input:focus {
border-bottom: 2px solid #FFA07A;
}
.search-bar-container input::placeholder {
color: #888;
}
.search-icon {
position: absolute;
left: 15px;
font-size: 18px;
color: #888;
}
.mic-icon {
position: absolute;
right: 15px;
font-size: 18px;
color: #888;
cursor: pointer;
transition: color 0.3s ease;
}
.mic-icon.active {
color: #007bff;
}
.bottom-action-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background-color: white;
padding: 10px 20px;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
z-index: 1000;
max-width: 900px;
margin: 0 auto;
}
.bottom-action-bar .btn {
flex: 1;
margin: 0 5px;
padding: 10px 15px;
border-radius: 8px;
font-weight: bold;
font-size: 16px;
color: white;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
min-width: 0;
white-space: nowrap;
}
.bottom-action-bar .btn-order-history {
background-color: #FFA07A;
border-color: #FFA07A;
}
.bottom-action-bar .btn-order-history:hover {
background-color: #FF8C61;
border-color: #FF8C61;
}
.bottom-action-bar .btn-view-cart {
background-color: #0FAA39;
border-color: #0FAA39;
}
.bottom-action-bar .btn-view-cart:hover {
background-color: #0D9232;
border-color: #0D9232;
}
.cart-icon-badge {
background-color: white;
color: #0FAA39;
border-radius: 50%;
width: 20px;
height: 20px;
display: inline-flex;
align-items: center;
justify-content: center;
font-size: 12px;
margin-left: 8px;
}
.no-results {
text-align: center;
font-size: 1.2rem;
color: #6c757d;
margin-top: 20px;
}
@media (max-width: 576px) {
.fixed-top-bar {
height: 60px;
padding: 10px;
}
.back-arrow-container {
left: 8px;
}
.back-arrow {
width: 32px;
height: 32px;
font-size: 18px;
}
.search-bar-container {
width: calc(80% - 50px);
max-width: calc(100% - 50px);
left: 50px;
}
.search-bar-container input {
padding: 6px 35px 6px 35px;
font-size: 14px;
border-radius: 20px;
}
.search-icon {
left: 12px;
font-size: 16px;
}
.mic-icon {
right: 12px;
font-size: 16px;
}
.avatar-dropdown-container {
right: 10px;
}
.avatar-icon {
width: 40px;
height: 40px;
font-size: 20px;
}
.dropdown-menu {
width: 220px;
}
.dropdown-menu .dropdown-item {
padding: 12px 16px;
font-size: 15px;
}
.menu-card {
max-width: 100%;
}
.menu-card img {
height: 150px;
}
.menu-card .card-body .card-title {
font-size: 1rem;
}
.menu-card .card-body .card-text.section {
font-size: 0.8rem;
}
.bottom-action-bar {
padding: 8px 10px;
}
.bottom-action-bar .btn {
padding: 8px 10px;
font-size: 14px;
}
.cart-icon-badge {
width: 18px;
height: 18px;
font-size: 10px;
margin-left: 5px;
}
}
</style>
</head>
<body>
<div class="fixed-top-bar">
<div class="back-arrow-container">
<a href="{{ url_for('menu.menu') }}" class="back-arrow" aria-label="Back to Menu">
<i class="bi bi-arrow-left"></i>
</a>
</div>
<div class="avatar-dropdown-container">
<div class="avatar-icon">
<span>{{ first_letter }}</span>
</div>
<div class="dropdown-menu">
<a href="{{ url_for('user_details.customer_details') }}" class="dropdown-item">View Profile</a>
<a href="{{ url_for('orderhistory.order_history') }}" class="dropdown-item">Order History</a>
<a href="{{ url_for('combined_summary.combined_summary') }}" class="dropdown-item">MY Summary</a>
<a href="{{ url_for('logout') }}" class="dropdown-item">Logout</a>
</div>
</div>
<div class="search-bar-container">
<input type="text" id="searchBar" class="form-control" placeholder="Search items or sections..." autocomplete="off">
<i class="bi bi-search search-icon"></i>
<i class="bi bi-mic mic-icon" id="micIcon"></i>
</div>
</div>
<div class="container mt-4">
<div class="row" id="menuItems">
{% for section, items in ordered_menu.items() %}
{% for item in items %}
<div class="col-md-6 mb-4 menu-item" data-name="{{ item.Name | default('Unnamed Item') }}" data-section="{{ item.Section__c | default(section) }}">
<div class="card menu-card" onclick="selectItem('{{ item.Name | default('Unnamed Item') }}', '{{ item.Section__c | default(section) }}')">
<img src="{{ item.Image1__c | default('/static/placeholder.jpg') }}" alt="{{ item.Name | default('Unnamed Item') }}" class="card-img-top">
<div class="card-body">
<h5 class="card-title">{{ item.Name | default('Unnamed Item') }}</h5>
<p class="card-text section">{{ item.Section__c | default(section) }}</p>
</div>
</div>
</div>
{% endfor %}
{% endfor %}
</div>
<div class="no-results" id="noResults" style="display: none;">
No items found matching your search.
</div>
</div>
<div class="bottom-action-bar">
<a href="{{ url_for('orderhistory.order_history') }}" class="btn btn-order-history">
<i class="bi bi-clock-history"></i> Order History
</a>
<a href="{{ url_for('cart.cart') }}" class="btn btn-view-cart">
<i class="bi bi-cart"></i> View Cart
<span id="cart-item-count" class="cart-icon-badge" style="display: none;">0</span>
</a>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
<script>
const menuItems = [
{% for section, items in ordered_menu.items() %}
{% for item in items %}
{
name: "{{ item.Name | default('Unnamed Item') }}",
section: "{{ item.Section__c | default(section) }}"
},
{% endfor %}
{% endfor %}
];
function updateCartUI(cart) {
if (!Array.isArray(cart)) {
console.error('Invalid cart data:', cart);
return;
}
let totalQuantity = 0;
cart.forEach(item => {
totalQuantity += item.quantity;
});
const cartItemCount = document.getElementById('cart-item-count');
if (cartItemCount) {
cartItemCount.innerText = totalQuantity;
cartItemCount.style.display = totalQuantity > 0 ? 'inline-flex' : 'none';
}
}
function getCartLocalStorage() {
return JSON.parse(localStorage.getItem('cart')) || [];
}
function selectItem(itemName, section) {
localStorage.setItem('selectedItem', JSON.stringify({ name: itemName, section: section }));
window.location.href = '/menu';
}
function filterMenuItems(query) {
const menuItemElements = document.querySelectorAll('.menu-item');
const noResults = document.getElementById('noResults');
let hasResults = false;
menuItemElements.forEach(item => {
const name = item.getAttribute('data-name').toLowerCase();
const section = item.getAttribute('data-section').toLowerCase();
const matches = name.includes(query.toLowerCase()) || section.includes(query.toLowerCase());
item.style.display = matches ? '' : 'none';
if (matches) hasResults = true;
});
noResults.style.display = hasResults ? 'none' : 'block';
}
document.addEventListener('DOMContentLoaded', function () {
// Avatar Dropdown
const avatarContainer = document.querySelector('.avatar-dropdown-container');
const dropdownMenu = document.querySelector('.dropdown-menu');
avatarContainer.addEventListener('click', function (event) {
event.stopPropagation();
dropdownMenu.style.display = dropdownMenu.style.display === 'block' ? 'none' : 'block';
});
document.addEventListener('click', function (event) {
if (!avatarContainer.contains(event.target)) {
dropdownMenu.style.display = 'none';
}
});
const dropdownItems = document.querySelectorAll('.dropdown-item');
dropdownItems.forEach(item => {
item.addEventListener('click', function () {
dropdownMenu.style.display = 'none';
});
});
// Search Bar Functionality
const searchBar = document.getElementById('searchBar');
const searchQuery = localStorage.getItem('searchQuery');
if (searchQuery) {
searchBar.value = searchQuery;
filterMenuItems(searchQuery);
localStorage.removeItem('searchQuery');
}
searchBar.addEventListener('input', function () {
filterMenuItems(this.value);
});
// Voice Recognition
const micIcon = document.getElementById('micIcon');
if ('SpeechRecognition' in window || 'webkitSpeechRecognition' in window) {
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
const recognition = new SpeechRecognition();
recognition.lang = 'en-US';
recognition.onstart = () => micIcon.classList.add('active');
recognition.onresult = (event) => {
const query = event.results[0][0].transcript.trim();
searchBar.value = query;
filterMenuItems(query);
};
recognition.onend = () => micIcon.classList.remove('active');
recognition.onerror = (event) => {
micIcon.classList.remove('active');
console.error('Speech error:', event.error);
};
micIcon.addEventListener('click', () => {
recognition.start();
});
} else {
micIcon.style.display = 'none';
}
// Lazy Loading for Cards
const menuCards = document.querySelectorAll('.menu-card');
const cardObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
observer.unobserve(entry.target);
}
});
}, {
root: null,
rootMargin: '0px',
threshold: 0.1
});
menuCards.forEach(card => cardObserver.observe(card));
// Fetch Cart
fetch('/cart/get')
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then(data => {
if (data.success) {
updateCartUI(data.cart);
} else {
console.error('Failed to fetch cart:', data.error);
const cart = getCartLocalStorage();
updateCartUI(cart);
}
})
.catch(err => {
console.error('Error fetching cart:', err);
const cart = getCartLocalStorage();
updateCartUI(cart);
});
});
</script>
</body>
</html> |