-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomer.html
More file actions
677 lines (575 loc) · 30.5 KB
/
Copy pathcustomer.html
File metadata and controls
677 lines (575 loc) · 30.5 KB
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
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Menu - # SK cafe</title>
<link rel="manifest" href="manifest.json">
<link
href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap"
rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/remixicon@4.2.0/fonts/remixicon.css" rel="stylesheet">
<link rel="stylesheet" href="styles.css">
<style>
/* Hide scrollbar for clean UI */
::-webkit-scrollbar {
width: 0px;
background: transparent;
}
.hero-banner {
height: 250px;
position: relative;
background: url('https://images.unsplash.com/photo-1511920170033-f8396924c348?q=80&w=2787&auto=format&fit=crop') center/cover;
border-radius: 0 0 32px 32px;
margin-bottom: 24px;
display: flex;
align-items: flex-end;
padding: 24px;
}
.hero-banner::after {
content: '';
position: absolute;
inset: 0;
background: linear-gradient(to top, var(--bg-dark), transparent);
border-radius: 0 0 32px 32px;
}
.hero-text {
position: relative;
z-index: 2;
}
</style>
</head>
<body style="padding-bottom: 100px;"> <!-- Padding for bottom nav -->
<div class="bg-pattern"></div>
<div class="grain"></div>
<!-- Hero Section -->
<div class="hero-banner">
<div class="hero-text">
<div class="badge badge-warning" style="margin-bottom: 8px;">Table <span id="tableNum">0</span></div>
<h1 class="font-serif" style="font-size: 32px; line-height: 1.1;">Good Evening,<br><span
class="text-accent">Foodie!</span></h1>
</div>
<div style="position: absolute; top: 16px; right: 16px; z-index: 10; display: flex; gap: 12px;">
<button class="btn-icon" onclick="showOrders()"
style="background: rgba(0,0,0,0.5); backdrop-filter: blur(10px); color: #fff; border: none; width: auto; padding: 0 16px; border-radius: 100px; display: flex; align-items: center; gap: 8px;">
<i class="ri-file-list-3-line"></i>
<span style="font-size: 14px; font-weight: 600;">Orders</span>
</button>
<button class="btn-icon" onclick="toggleTheme()" id="themeBtn"
style="background: rgba(0,0,0,0.5); backdrop-filter: blur(10px); color: #fff; border: none;">
<i class="ri-moon-line" id="themeIcon"></i>
</button>
</div>
</div>
<!-- Instagram-style Stories (Categories) -->
<div class="story-scroll" id="categoryList">
<!-- Rendered by JS -->
</div>
<!-- Main Menu Content -->
<main class="main-container" style="padding-top: 0;">
<div class="desktop-layout">
<div class="menu-section">
<!-- Search -->
<div class="input"
style="display: flex; align-items: center; gap: 12px; margin-bottom: 24px; background: var(--bg-card); border-radius: 100px;">
<i class="ri-search-line" style="font-size: 20px; color: var(--text-muted);"></i>
<input type="text" id="searchInput" placeholder="What are you craving?"
style="background: transparent; border: none; width: 100%; color: inherit; outline: none; font-size: 16px;">
</div>
<!-- Trending -->
<div id="trendingSection" style="margin-bottom: 32px;">
<div
style="display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 16px;">
<h2 class="font-serif" style="font-size: 20px;">Trending Now <span class="text-accent">🔥</span>
</h2>
</div>
<div class="story-scroll" id="trendingList" style="padding: 0; margin: 0 -16px; padding: 0 16px;">
<!-- Rendered JS -->
</div>
</div>
<!-- Menu Grid -->
<h2 class="font-serif" style="font-size: 20px; margin-bottom: 16px;" id="menuTitle">All Menu</h2>
<div class="grid grid-2" id="menuGrid">
<!-- Rendered JS -->
</div>
<div id="emptyState" class="hidden"
style="text-align: center; padding: 60px 0; color: var(--text-muted);">
<i class="ri-search-2-line" style="font-size: 48px; margin-bottom: 16px;"></i>
<p>No delicious items found.</p>
</div>
</div>
<!-- Desktop Side Panel (Sticky Cart) -->
<aside class="side-panel">
<h2 class="font-serif"
style="font-size: 24px; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border);">
Your Order</h2>
<div id="desktopCartList"
style="flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px;">
<!-- Rendered JS -->
<p class="text-muted" style="text-align: center; margin-top: 40px;">Your cart is empty</p>
</div>
<div class="cart-footer">
<div
style="display: flex; justify-content: space-between; margin-bottom: 16px; font-weight: 700; font-size: 18px;">
<span>Total</span>
<span class="text-accent">₹<span id="desktopCartTotal">0</span></span>
</div>
<input type="text" class="input" id="desktopCustName" placeholder="Your Name"
style="margin-bottom: 12px;">
<textarea class="input" id="desktopCustNotes" placeholder="Any special requests? (e.g. less sugar)"
style="min-height: 60px; resize: none; margin-bottom: 12px;"></textarea>
<button class="btn btn-primary" style="width: 100%; padding: 14px;" onclick="placeOrder('desktop')">
Confirm Order <i class="ri-arrow-right-line"></i>
</button>
</div>
</aside>
</div>
</main>
<!-- Floating Cart Bar (Mobile Only) -->
<div class="cart-float" id="cartFloat" onclick="openCart()">
<span style="display: flex; align-items: center; gap: 8px;">
<span
style="width: 24px; height: 24px; background: #000; color: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px;"
id="cartCount">0</span>
items
</span>
<span>View Cart <i class="ri-arrow-right-line"></i></span>
</div>
<!-- Bottom Navigation -->
<nav class="bottom-nav">
<button class="nav-item active" onclick="scrollToTop()">
<i class="ri-home-5-line"></i>
Home
</button>
<button class="nav-item" onclick="document.getElementById('searchInput').focus()">
<i class="ri-search-line"></i>
Search
</button>
<button class="nav-item" onclick="showOrders()">
<i class="ri-file-list-3-line"></i>
Orders
</button>
</nav>
<!-- Cart Modal (Bottom Sheet - Mobile) -->
<div class="modal-overlay" id="overlay" onclick="closeCart()"></div>
<div class="modal modal-bottom" id="cartModal" style="z-index: 2000;">
<div
style="padding: 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center;">
<h2 class="font-serif" style="font-size: 24px;">Your Order</h2>
<button class="btn-icon" onclick="closeCart()"><i class="ri-close-line"></i></button>
</div>
<div style="padding: 24px; overflow-y: auto; max-height: 50vh;">
<div id="cartList" style="display: flex; flex-direction: column; gap: 16px;"></div>
<div style="margin-top: 24px;">
<input type="text" class="input" id="custName" placeholder="Your Name" style="margin-bottom: 12px;">
<textarea class="input" id="custNotes" placeholder="Any special requests? (e.g. less sugar)"
style="min-height: 80px; resize: none;"></textarea>
</div>
</div>
<div style="padding: 24px; border-top: 1px solid var(--border); background: var(--bg-card);">
<div style="display: flex; justify-content: space-between; margin-bottom: 16px; font-weight: 700;">
<span>Total</span>
<span class="text-accent">₹<span id="cartTotal">0</span></span>
</div>
<button class="btn btn-primary" style="width: 100%; padding: 16px;" onclick="placeOrder('mobile')">
Place Order <i class="ri-arrow-right-line"></i>
</button>
</div>
</div>
<!-- Order Status Modal -->
<div class="modal-overlay" id="ordersOverlay" onclick="closeOrders()"></div>
<div class="modal modal-bottom" id="ordersModal" style="z-index: 2000; height: 85vh;">
<div
style="padding: 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center;">
<h2 class="font-serif" style="font-size: 24px;">Track Order</h2>
<button class="btn-icon" onclick="closeOrders()"><i class="ri-close-line"></i></button>
</div>
<div style="padding: 24px; overflow-y: auto; height: 100%;" id="ordersContent"></div>
</div>
<script src="data.js"></script>
<script>
// Service Worker
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('./sw.js');
}
let cart = [];
let currentCat = 'all';
let isVegFilter = false;
let currentTable = 1;
// Init Logic
function init() {
// Instant Theme Load
const savedTheme = localStorage.getItem('sk_theme');
if (savedTheme === 'light') document.body.classList.add('light-mode');
updateThemeIcon();
// Params
const params = new URLSearchParams(window.location.search);
if (params.has('table')) currentTable = parseInt(params.get('table'));
document.getElementById('tableNum').textContent = currentTable;
renderCategories();
renderTrending();
renderMenu();
setupSearch();
// Initial Empty State for Desktop Cart
renderDesktopCart();
}
function toggleTheme() {
document.body.classList.toggle('light-mode');
const isLight = document.body.classList.contains('light-mode');
localStorage.setItem('sk_theme', isLight ? 'light' : 'dark');
updateThemeIcon();
}
function updateThemeIcon() {
const isLight = document.body.classList.contains('light-mode');
document.getElementById('themeIcon').className = isLight ? 'ri-sun-line' : 'ri-moon-line';
}
// Render Functions
function renderCategories() {
const list = document.getElementById('categoryList');
// Search Input area is actually a good place for filters, but let's put it on top of trending if we want.
// Or we can inject it before the category list but sticking with the requested design.
// Let's Add the Filter Toggle to the Right of the Search Bar in the Menu Section HTML
// But since I can't easily jump to that line without context, I'll inject the logic here:
// Actually, let's just make the "All" button behave normally, and I will inject a Filter Toggle
// dynamically into the Trending Section header or similar?
// BETTER: Let's prepend the "Veg Only" toggle to the Category List slightly separated?
// Actually user asked for a "Toggle Switch"
// I'll render it as the FIRST item in the story scroll but styled differently?
// Or better, let's inject it via the `trendingSection` header as shown in plan?
// Let's update the Trending Header to include the toggle
const trendingHeader = document.querySelector('#trendingSection h2');
if (trendingHeader && !document.getElementById('vegToggle')) {
const container = document.createElement('div');
container.style.display = 'flex';
container.style.justifyContent = 'space-between';
container.style.alignItems = 'center';
container.style.marginBottom = '16px';
container.innerHTML = `
<h2 class="font-serif" style="font-size: 20px; margin:0;">Trending Now <span class="text-accent">🔥</span></h2>
<div class="filter-toggle" id="vegToggle" onclick="toggleVegFilter()">
<div class="toggle-icon"><i class="ri-leaf-line"></i></div>
<span style="font-size: 13px; font-weight: 600;">Veg Only</span>
</div>
`;
trendingHeader.parentElement.replaceWith(container);
}
const allBtn = `
<div class="story-item" onclick="selectCat('all')">
<div class="story-circle ${currentCat === 'all' ? 'active' : ''}">🍽️</div>
<span class="${currentCat === 'all' ? 'text-accent' : 'text-muted'}">All</span>
</div>
`;
const cats = categories.filter(c => c.id !== 'all').map(c => `
<div class="story-item" onclick="selectCat('${c.id}')">
<div class="story-circle ${currentCat === c.id ? 'active' : ''}">${c.emoji}</div>
<span class="${currentCat === c.id ? 'text-accent' : 'text-muted'}">${c.name}</span>
</div>
`).join('');
list.innerHTML = allBtn + cats;
// Ensure the veg toggle state is reflected on initial render or category change
const vegToggleBtn = document.getElementById('vegToggle');
if (vegToggleBtn) {
if (isVegFilter) vegToggleBtn.classList.add('active');
else vegToggleBtn.classList.remove('active');
}
}
function toggleVegFilter() {
isVegFilter = !isVegFilter;
const btn = document.getElementById('vegToggle');
if (isVegFilter) btn.classList.add('active');
else btn.classList.remove('active');
renderMenu(document.getElementById('searchInput').value);
renderTrending(); // Refresh trending too
if (navigator.vibrate) navigator.vibrate(20);
}
function selectCat(id) {
currentCat = id;
if (navigator.vibrate) navigator.vibrate(20);
renderCategories();
renderMenu();
const title = id === 'all' ? 'All Menu' : categories.find(c => c.id === id).name;
document.getElementById('menuTitle').textContent = title;
// Don't hide trending based on cat, just search.
}
function renderTrending() {
let items = DataStore.getMenuItems().filter(i => i.trending && i.inStock);
if (isVegFilter) items = items.filter(i => i.isVeg); // Filter Trending
const list = document.getElementById('trendingList');
if (items.length === 0) {
list.innerHTML = `<div class="text-muted" style="padding:0 16px; font-size:14px;">No trending items available.</div>`;
return;
}
list.innerHTML = items.map(item => `
<div class="trending-card" onclick="addToCart(${item.id})">
<div style="position: relative;">
<img src="${item.image}" alt="${item.name}"
onerror="this.src='https://images.unsplash.com/photo-1546069901-ba9599a7e63c?w=400'">
<div class="badge badge-warning" style="position: absolute; top: 8px; left: 8px; font-size: 10px;">🔥 Hot</div>
</div>
<div class="content">
<div class="name">${item.name}</div>
<div class="price">₹${item.price}</div>
</div>
</div>
`).join('');
}
function setupSearch() {
document.getElementById('searchInput').addEventListener('input', (e) => {
renderMenu(e.target.value);
document.getElementById('trendingSection').style.display = e.target.value ? 'none' : 'block';
});
}
function renderMenu(search = '') {
let items = DataStore.getMenuItems().filter(i => i.inStock);
if (currentCat !== 'all') items = items.filter(i => i.category === currentCat);
if (search) items = items.filter(i => i.name.toLowerCase().includes(search.toLowerCase()));
if (isVegFilter) items = items.filter(i => i.isVeg); // Filter Logic
const grid = document.getElementById('menuGrid');
const empty = document.getElementById('emptyState');
if (items.length === 0) {
grid.innerHTML = '';
empty.classList.remove('hidden');
return;
}
empty.classList.add('hidden');
grid.innerHTML = items.map(item => {
const dietIcon = item.isVeg
? `<div class="diet-icon veg"><div ></div></div>`
: `<div class="diet-icon non-veg"><div></div></div>`;
const calorieBadge = item.calories
? `<div class="calorie-tag">${item.calories} kcal</div>`
: '';
return `
<div class="menu-card overflow-hidden" style="border-radius: 20px;">
<div class="menu-card-img" style="position: relative;">
<img src="${item.image}"
alt="${item.name}"
style="width: 100%; height: 100%; object-fit: cover;"
onerror="this.src='https://images.unsplash.com/photo-1546069901-ba9599a7e63c?w=400'">
<div class="add-btn-round" onclick="addToCart(${item.id})" aria-label="Add ${item.name} to cart">
<i class="ri-add-line"></i>
</div>
</div>
<div style="padding: 12px;">
<div style="display:flex; justify-content:space-between; align-items:start; margin-bottom: 4px;">
<div style="font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right:8px;">${item.name}</div>
${dietIcon}
</div>
<div class="text-accent" style="font-weight: 700;">₹${item.price}</div>
${calorieBadge}
</div>
</div>
`}).join('');
}
// Cart Logic
function addToCart(id) {
const item = DataStore.getMenuItems().find(i => i.id === id);
const existing = cart.find(c => c.id === id);
if (existing) existing.qty++;
else cart.push({ ...item, qty: 1 });
updateCartUI();
if (navigator.vibrate) navigator.vibrate(40);
showToast(`${item.emoji} Added to cart`);
}
function updateCartUI() {
const count = cart.reduce((s, i) => s + i.qty, 0);
const total = cart.reduce((s, i) => s + i.price * i.qty, 0);
// Mobile Float
document.getElementById('cartCount').textContent = count;
document.getElementById('cartTotal').textContent = total;
const float = document.getElementById('cartFloat');
if (count > 0) float.classList.add('show');
else float.classList.remove('show');
// Desktop Side Panel
document.getElementById('desktopCartTotal').textContent = total;
renderDesktopCart();
}
function renderDesktopCart() {
const list = document.getElementById('desktopCartList');
if (cart.length === 0) {
list.innerHTML = `<div style="flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; height:100%; color: var(--text-muted);">
<i class="ri-shopping-basket-2-line" style="font-size: 48px; margin-bottom:16px; opacity:0.5;"></i>
<p>Your cart is empty</p>
<p style="font-size:12px;">Add some yummy items!</p>
</div>`;
return;
}
list.innerHTML = cart.map(item => `
<div style="display: flex; align-items: center; gap: 12px; background: var(--bg-card-hover); padding: 8px; border-radius: 12px; margin-bottom: 12px;">
<img src="${item.image}" style="width: 40px; height: 40px; border-radius: 8px; object-fit: cover;">
<div style="flex: 1;">
<div style="font-weight: 600; font-size:13px;">${item.name}</div>
<div class="text-muted" style="font-size: 11px;">₹${item.price * item.qty}</div>
</div>
<div class="badge" style="background: var(--bg-card); padding: 4px 8px; display: flex; gap: 8px; font-size: 12px;">
<span style="cursor:pointer;" onclick="updateQty(${item.id}, -1)">-</span>
<span>${item.qty}</span>
<span style="cursor:pointer;" onclick="updateQty(${item.id}, 1)">+</span>
</div>
</div>
`).join('');
}
function openCart() {
if (cart.length === 0) return;
document.getElementById('overlay').classList.add('show');
document.getElementById('cartModal').classList.add('show');
renderCartList(); // Mobile modal render
}
function closeCart() {
document.getElementById('overlay').classList.remove('show');
document.getElementById('cartModal').classList.remove('show');
}
function renderCartList() {
document.getElementById('cartList').innerHTML = cart.map(item => `
<div style="display: flex; align-items: center; gap: 12px;">
<img src="${item.image}" style="width: 50px; height: 50px; border-radius: 12px; object-fit: cover;">
<div style="flex: 1;">
<div style="font-weight: 600;">${item.name}</div>
<div class="text-muted" style="font-size: 12px;">₹${item.price}</div>
</div>
<div class="badge" style="background: var(--bg-card-hover); padding: 4px 8px; display: flex; gap: 12px; font-size: 14px;">
<span onclick="updateQty(${item.id}, -1)">-</span>
<span>${item.qty}</span>
<span onclick="updateQty(${item.id}, 1)">+</span>
</div>
</div>
`).join('');
}
function updateQty(id, diff) {
const item = cart.find(c => c.id === id);
if (item) {
item.qty += diff;
if (item.qty <= 0) cart = cart.filter(c => c.id !== id);
updateCartUI();
renderCartList();
if (cart.length === 0) closeCart();
}
}
function placeOrder(source) {
if (cart.length === 0) {
showToast('Your cart is empty!', 'warning');
return;
}
// Handle different sources (Desktop vs Mobile inputs)
const nameId = source === 'desktop' ? 'desktopCustName' : 'custName';
const notesId = source === 'desktop' ? 'desktopCustNotes' : 'custNotes';
const name = document.getElementById(nameId).value.trim() || 'Guest';
const notesEl = document.getElementById(notesId);
const notes = notesEl ? notesEl.value.trim() : '';
// Calculate total for confirmation
const total = cart.reduce((s, i) => s + i.price * i.qty, 0);
const itemCount = cart.reduce((s, i) => s + i.qty, 0);
// Confirmation dialog
if (!confirm(`Confirm order?\n\n${itemCount} item(s) - ₹${total}\nName: ${name}${notes ? '\nNotes: ' + notes : ''}`)) {
return;
}
DataStore.createSession(currentTable, cart, name, notes);
DataStore.addKitchenOrder(currentTable, cart, name, notes);
// Clear cart
cart = [];
updateCartUI();
closeCart();
// Clear input fields
document.getElementById(nameId).value = '';
if (notesEl) notesEl.value = '';
showOrders();
createConfetti();
showToast('Order placed successfully! 🎉', 'success');
}
// Orders Logic
function showOrders() {
document.getElementById('ordersOverlay').classList.add('show');
document.getElementById('ordersModal').classList.add('show');
// Render initial status
renderOrderStatus();
// Start auto-refresh for real-time updates
startOrderAutoRefresh();
}
let orderRefreshInterval = null;
function closeOrders() {
document.getElementById('ordersOverlay').classList.remove('show');
document.getElementById('ordersModal').classList.remove('show');
// Stop auto-refresh when modal is closed
if (orderRefreshInterval) {
clearInterval(orderRefreshInterval);
orderRefreshInterval = null;
}
}
function startOrderAutoRefresh() {
// Clear any existing interval
if (orderRefreshInterval) {
clearInterval(orderRefreshInterval);
}
// Refresh order status every 5 seconds
orderRefreshInterval = setInterval(() => {
const modal = document.getElementById('ordersModal');
if (modal && modal.classList.contains('show')) {
renderOrderStatus();
} else {
clearInterval(orderRefreshInterval);
orderRefreshInterval = null;
}
}, 5000);
}
function renderOrderStatus() {
const session = DataStore.getSession(currentTable);
const container = document.getElementById('ordersContent');
if (!session) {
container.innerHTML = `<div style="text-align: center; padding: 40px; color: var(--text-muted);">No active orders</div>`;
return;
}
const kOrder = DataStore.getKitchenOrders().find(o => o.tableNum === currentTable && o.status !== 'completed');
let statusIdx = 0;
if (kOrder) {
if (kOrder.status === 'preparing') statusIdx = 1;
} else if (session.items.length > 0) {
statusIdx = 2;
}
const steps = ['Order Received', 'Preparing', 'Ready to Serve'];
const statusMessages = [
'Your order has been sent to the kitchen!',
'Our chefs are preparing your meal with love ❤️',
'Your order is ready! It will be served shortly 🎉'
];
container.innerHTML = `
<div style="text-align: center; margin-bottom: 24px;">
<h1 class="text-accent" style="font-size: 48px; margin-bottom: 8px;">#${session.tableNum}</h1>
<p class="text-muted">Order Ticket: #${Date.now().toString().slice(-4)}</p>
</div>
<div class="progress-track" style="margin-bottom: 40px;">
<div class="progress-line"></div>
<div class="progress-fill" style="width: ${statusIdx * 50}%"></div>
${steps.map((s, i) => `
<div style="position: relative; z-index: 1;">
<div class="progress-step ${i <= statusIdx ? 'active' : ''}">
<i class="ri-${i === 0 ? 'file-list' : (i === 1 ? 'fire' : 'check')}-line"></i>
</div>
<div style="position: absolute; top: 32px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 10px; font-weight: 600; color: ${i <= statusIdx ? 'var(--text-dark)' : 'var(--text-muted)'}">${s}</div>
</div>
`).join('')}
</div>
<div style="border: 1px dashed var(--border); border-radius: 16px; padding: 24px; background: var(--bg-card-hover);">
<h3 class="font-serif" style="margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 12px;">Items Ordered</h3>
${session.items.map(item => `
<div style="display: flex; justify-content: space-between; padding: 8px 0; font-size: 14px;">
<div><span style="font-weight: 700;">${item.qty}x</span> ${item.name}</div>
<div>₹${item.price * item.qty}</div>
</div>
`).join('')}
<div style="border-top: 1px solid var(--border); margin-top: 16px; padding-top: 16px; display: flex; justify-content: space-between; font-weight: 700; font-size: 18px;">
<span>Total Paid</span>
<span class="text-accent">₹${Math.round(session.items.reduce((s, i) => s + i.price * i.qty, 0))}</span>
</div>
</div>
<p style="text-align: center; margin-top: 24px; color: var(--text-muted); font-size: 12px;">
${statusMessages[statusIdx]}
</p>
`;
}
function scrollToTop() {
window.scrollTo({ top: 0, behavior: 'smooth' });
}
init();
</script>
</body>
</html>