-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenued.html
More file actions
1302 lines (1188 loc) · 47.8 KB
/
menued.html
File metadata and controls
1302 lines (1188 loc) · 47.8 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
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="icon"
type="image/png"
sizes="16x16"
href="images/favicon-16x16.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="images/favicon-32x32.png"
/>
<link
rel="apple-touch-icon"
sizes="180x180"
href="images/apple-touch-icon.png"
/>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<link rel="icon" href="images/favicon.ico" type="image/x-icon" />
<link rel="manifest" href="images/site.webmanifest" />
<meta name="msapplication-TileColor" content="#da532c" />
<meta name="theme-color" content="#ffffff" />
<title>Restaurant Menu Management</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap"
rel="stylesheet"
/>
<script src="https://cdn.tailwindcss.com"></script>
<script>
// Immediately set the correct theme to prevent flash
(function () {
const storedTheme = localStorage.getItem("color-theme");
const systemDark = window.matchMedia(
"(prefers-color-scheme: dark)"
).matches;
if (storedTheme === "dark" || (!storedTheme && systemDark)) {
document.documentElement.classList.add("dark");
}
})();
tailwind.config = {
darkMode: "class",
theme: {
extend: {
fontFamily: {
bebas: ['"Bebas Neue"', "sans-serif"],
inter: ['"Inter"', "sans-serif"],
},
colors: {
primary: {
yellow: "#FFC107",
"yellow-dark": "#FFB300",
},
dark: {
bg: "#1a1a2e",
"bg-secondary": "#16213e",
"bg-card": "#0f172a",
text: "#e8e8e8",
"text-secondary": "#cbd5e0",
},
},
transitionProperty: {
colors: "background-color, border-color, color, fill, stroke",
},
animation: {
"fade-in": "fadeIn 0.3s ease-in-out",
"slide-up": "slideUp 0.3s ease-out",
"bounce-gentle": "bounceGentle 0.6s ease-in-out",
},
keyframes: {
fadeIn: {
"0%": { opacity: "0" },
"100%": { opacity: "1" },
},
slideUp: {
"0%": { transform: "translateY(20px)", opacity: "0" },
"100%": { transform: "translateY(0)", opacity: "1" },
},
bounceGentle: {
"0%, 20%, 53%, 80%, 100%": { transform: "translateY(0)" },
"40%, 43%": { transform: "translateY(-10px)" },
"70%": { transform: "translateY(-5px)" },
"90%": { transform: "translateY(-2px)" },
},
},
},
},
};
</script>
<style>
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");
/* Base transitions */
html,
body {
transition: background-color 0.3s ease, color 0.3s ease;
}
/* Color transitions */
.bg-white,
.bg-gray-50,
.bg-gray-100,
.bg-gray-200,
.dark\:bg-slate-800,
.dark\:bg-slate-700,
.dark\:bg-slate-900,
.text-gray-700,
.dark\:text-yellow-400,
.text-gray-600,
.dark\:text-gray-300,
.text-white,
.dark\:text-gray-200,
.text-gray-800,
.dark\:text-white {
transition: background-color 0.3s ease, color 0.3s ease;
}
/* Border transitions */
.border-gray-200,
.dark\:border-slate-600,
.border-gray-300,
.dark\:border-slate-700 {
transition: border-color 0.3s ease;
}
/* Header specific transitions */
.bg-brand-yellow {
background: #ffc107;
transition: background-color 0.3s ease;
}
.dark\:bg-slate-900 {
transition: background-color 0.3s ease;
}
/* Hardware acceleration for performance */
.theme-toggle,
.bg-brand-yellow,
.dark\:bg-slate-900 {
will-change: auto;
}
/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
* {
transition: none !important;
animation: none !important;
}
}
body {
font-family: "Inter", sans-serif;
}
.bg-brand-yellow {
background: #ffc107;
}
.bg-brand-yellow-dark {
background: #ffb300;
}
.bg-gradient-primary-light {
background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}
.bg-gradient-header-light {
background: #ffc107;
}
.bg-gradient-primary-dark {
background: #0f172a;
}
.bg-gradient-header-dark {
background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}
.bg-gradient-button {
background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}
.bg-gradient-button-dark {
background: linear-gradient(135deg, #ffc107, #ffb300);
}
.bg-gradient-success {
background: linear-gradient(135deg, #10b981, #059669);
}
.bg-gradient-danger {
background: linear-gradient(135deg, #ef4444, #dc2626);
}
.bg-gradient-warning {
background: linear-gradient(135deg, #f59e0b, #d97706);
}
.bg-gradient-dark {
background: linear-gradient(135deg, #374151, #1f2937);
}
.bg-gradient-dark-mode {
background: linear-gradient(135deg, #0f172a, #1e293b);
}
.hover-lift:hover {
transform: translateY(-2px);
}
.hover-scale:hover {
transform: scale(1.05);
}
.glass {
backdrop-filter: blur(10px);
background: rgba(255, 255, 255, 0.9);
}
.glass-dark {
backdrop-filter: blur(10px);
background: rgba(15, 23, 42, 0.9);
}
.theme-toggle {
transition: all 0.3s ease;
}
.theme-toggle:hover {
background: rgba(255, 255, 255, 0.1);
}
.dark {
color: #e8e8e8;
}
.item-image {
width: 80px;
height: 60px;
object-fit: cover;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.btn-disabled {
opacity: 0.6;
cursor: not-allowed;
pointer-events: none;
}
/* Preview image styling */
.image-preview {
max-width: 150px;
max-height: 100px;
object-fit: contain;
border-radius: 8px;
margin-top: 10px;
display: none;
}
/* Disabled button styling */
.photo-btn-disabled {
opacity: 0.7;
cursor: not-allowed;
pointer-events: none;
background-color: #e5e7eb;
border-color: #d1d5db;
}
.dark .photo-btn-disabled {
background-color: #374151;
border-color: #4b5563;
}
/* Out of stock styling */
.out-of-stock-badge {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(239, 68, 68, 0.9);
color: white;
padding: 4px 8px;
border-radius: 4px;
font-weight: bold;
font-size: 12px;
}
</style>
</head>
<header>
<nav
class="bg-white border-gray-200 py-2.5 dark:bg-gray-900 transition-colors duration-300"
>
<div
class="flex flex-wrap items-center justify-between max-w-screen-xl px-4 mx-auto"
>
<a href="#" class="flex items-center">
<span
class="self-center text-xl font-semibold whitespace-nowrap dark:text-white transition-colors duration-300"
>
<img src="images/logo.png" alt="" class="h-20 w-20" />
</span>
</a>
<div class="flex items-center gap-4 lg:order-2">
<div class="z-50">
<button
id="darkModeToggle"
class="theme-toggle p-2 rounded-full bg-gray-200 dark:bg-gray-700 cursor-pointer transition-all duration-300 hover:bg-gray-300 dark:hover:bg-gray-600 hover:scale-110 hover:shadow-lg"
>
<svg
id="sunIcon"
xmlns="http://www.w3.org/2000/svg"
class="w-6 h-6 text-yellow-500 dark:hidden transition-colors duration-300"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"
/>
</svg>
<svg
id="moonIcon"
xmlns="http://www.w3.org/2000/svg"
class="w-6 h-6 text-yellow-400 hidden dark:block transition-colors duration-300"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"
/>
</svg>
</button>
</div>
<button
data-collapse-toggle="mobile-menu-2"
type="button"
class="inline-flex items-center p-2 text-sm text-gray-500 rounded-lg lg:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600 transition-colors duration-300"
aria-controls="mobile-menu-2"
aria-expanded="true"
>
<span class="sr-only">Open main menu</span>
<svg
class="hidden w-6 h-6"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
clip-rule="evenodd"
></path>
</svg>
</button>
</div>
<div
class="items-center justify-between w-full lg:flex lg:w-auto lg:order-1"
id="mobile-menu-2"
>
<ul
class="flex flex-col mt-4 font-medium lg:flex-row lg:space-x-8 lg:mt-0"
>
<nav
class="flex space-x-4 text-gray-800 dark:text-white transition-colors duration-300"
>
<a
href="/orders"
class="font-bebas text-2xl tracking-wider font-bold relative group transition-colors duration-300"
>
Orders
<span
class="block absolute bottom-0 left-0 w-0 h-0.5 bg-current transition-all duration-300 group-hover:w-full"
></span>
</a>
<a
href="/insights"
class="font-bebas text-2xl tracking-wider font-bold relative group transition-colors duration-300"
>
Insights
<span
class="block absolute bottom-0 left-0 w-0 h-0.5 bg-current transition-all duration-300 group-hover:w-full"
></span>
</a>
<a
href="/inventory"
class="font-bebas text-2xl tracking-wider font-bold relative group transition-colors duration-300"
>
Inventory
<span
class="block absolute bottom-0 left-0 w-0 h-0.5 bg-current transition-all duration-300 group-hover:w-full"
></span>
</a>
</nav>
</ul>
</div>
</div>
</nav>
</header>
<body
class="light:bg-gradient-primary-light dark:bg-gradient-primary-dark dark:bg-slate-900 min-h-screen p-5 transition-colors duration-300"
>
<div class="fixed top-6 right-6 z-50"></div>
<div
class="max-w-7xl mx-auto bg-white dark:bg-slate-900 rounded-3xl shadow-2xl overflow-hidden animate-slide-up transition-colors duration-300"
>
<div
class="bg-brand-yellow dark:bg-slate-900 text-gray-900 dark:text-white px-8 py-8 text-center relative overflow-hidden transition-colors duration-300"
>
<div
class="absolute inset-0 bg-gradient-to-r from-yellow-400/20 to-orange-400/20 dark:from-slate-700/20 dark:to-slate-600/20 transition-colors duration-300"
></div>
<div class="relative z-10">
<div class="flex items-center justify-center gap-6 mb-4">
<div class="w-24 h-24 flex items-center justify-center">
<img
src="./images/logo.png"
alt="Logo"
class="w-full h-full object-contain"
/>
</div>
<div class="text-left">
<div
class="text-2xl font-bold text-gray-700 dark:text-yellow-400 transition-colors duration-300"
>
MENU EDITOR
</div>
<p class="text-lg opacity-90 mt-1 transition-colors duration-300">
Manage your menu items and track inventory levels
</p>
</div>
</div>
</div>
</div>
<div
class="px-8 py-6 bg-gray-50 dark:bg-slate-800 border-b border-gray-200 dark:border-slate-600 transition-colors duration-300"
>
<div
class="flex flex-col md:flex-row justify-between items-center gap-4"
>
<div class="relative flex-1 max-w-md w-full">
<input
type="text"
id="searchInput"
placeholder="Search items..."
class="w-full pl-5 pr-12 py-3 border-2 border-gray-200 dark:border-slate-600 dark:bg-slate-700 dark:text-white rounded-full text-base focus:outline-none focus:border-indigo-500 focus:ring-4 focus:ring-indigo-100 transition-all duration-300"
/>
<span
class="absolute right-4 top-1/2 transform -translate-y-1/2 text-gray-400 transition-colors duration-300"
>🔍</span
>
</div>
<button
class="bg-gradient-button dark:bg-gradient-button-dark text-white px-6 py-3 rounded-full font-semibold hover-lift transition-all duration-300 hover:shadow-xl flex items-center gap-2 whitespace-nowrap"
onclick="openAddModal()"
>
➕ Add New Item
</button>
</div>
</div>
<div
class="overflow-x-auto bg-white dark:bg-slate-900 transition-colors duration-300"
>
<table class="w-full">
<thead
class="bg-gradient-dark dark:bg-gradient-dark-mode text-white transition-colors duration-300"
>
<tr>
<th
class="px-4 py-5 text-left font-semibold text-sm uppercase tracking-wider"
>
Image
</th>
<th
class="px-4 py-5 text-left font-semibold text-sm uppercase tracking-wider"
>
Name
</th>
<th
class="px-4 py-5 text-left font-semibold text-sm uppercase tracking-wider"
>
Price
</th>
<th
class="px-4 py-5 text-left font-semibold text-sm uppercase tracking-wider"
>
Status
</th>
<th
class="px-4 py-5 text-left font-semibold text-sm uppercase tracking-wider"
>
Actions
</th>
</tr>
</thead>
<tbody
id="inventoryTableBody"
class="divide-y divide-gray-200 dark:divide-slate-700 bg-gray-50 dark:bg-slate-800 transition-colors duration-300"
></tbody>
</table>
</div>
</div>
<div
id="itemModal"
class="fixed inset-0 bg-black bg-opacity-70 z-50 hidden transition-opacity duration-300"
>
<div class="flex items-center justify-center min-h-screen p-4">
<div
class="bg-white dark:bg-slate-800 rounded-3xl w-full max-w-2xl max-h-screen overflow-y-auto shadow-2xl animate-bounce-gentle border-2 border-gray-200 dark:border-slate-700 transition-colors duration-300"
>
<div class="p-8">
<div
class="flex justify-between items-center mb-8 pb-4 border-b border-gray-200 dark:border-slate-700 transition-colors duration-300"
>
<h2
id="modalTitle"
class="text-2xl md:text-3xl font-bold text-gray-800 dark:text-yellow-400 transition-colors duration-300"
>
Add New Item
</h2>
<button
class="text-gray-500 dark:text-gray-300 hover:text-gray-700 dark:hover:text-yellow-400 text-3xl font-light transition-colors duration-200"
onclick="closeModal()"
>
×
</button>
</div>
<form id="itemForm" class="space-y-6" autocomplete="off">
<div>
<label
for="itemName"
class="block text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2 transition-colors duration-300"
>Item Name *</label
>
<input
type="text"
id="itemName"
name="name"
required
class="w-full px-4 py-3 border-2 border-gray-200 dark:border-slate-700 dark:bg-slate-700 dark:text-white rounded-xl text-base focus:outline-none focus:border-indigo-500 dark:focus:border-yellow-400 focus:ring-4 focus:ring-indigo-100 dark:focus:ring-yellow-400/20 transition-all duration-300"
/>
</div>
<div>
<label
for="itemPrice"
class="block text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2 transition-colors duration-300"
>Price (₹) *</label
>
<input
type="number"
id="itemPrice"
name="price"
step="0.01"
min="0"
required
class="w-full px-4 py-3 border-2 border-gray-200 dark:border-slate-700 dark:bg-slate-700 dark:text-white rounded-xl text-base focus:outline-none focus:border-indigo-500 dark:focus:border-yellow-400 focus:ring-4 focus:ring-indigo-100 dark:focus:ring-yellow-400/20 transition-all duration-300"
/>
</div>
<div>
<label
class="block text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2 transition-colors duration-300"
>Photo</label
>
<input
type="file"
id="itemImageFile"
name="imageFile"
accept="image/*"
class="hidden"
onchange="handleFileSelect(this)"
/>
<button
type="button"
id="photoUploadBtn"
onclick="document.getElementById('itemImageFile').click()"
class="w-full px-4 py-3 border-2 border-dashed border-gray-300 dark:border-slate-600 bg-gray-50 dark:bg-slate-700 text-gray-700 dark:text-gray-300 rounded-xl text-base hover:border-indigo-500 dark:hover:border-yellow-400 hover:bg-gray-100 dark:hover:bg-slate-600 focus:outline-none focus:border-indigo-500 dark:focus:border-yellow-400 focus:ring-4 focus:ring-indigo-100 dark:focus:ring-yellow-400/20 transition-all duration-300 flex items-center justify-center gap-2"
>
📸 Select Single Photo
</button>
<div
id="selectedFileName"
class="mt-2 text-sm text-gray-600 dark:text-gray-400 hidden transition-colors duration-300"
>
<span class="flex items-center gap-2">
✅ <span id="fileName"></span>
<button
type="button"
onclick="clearPhotoSelection()"
class="text-red-500 hover:text-red-700 dark:hover:text-red-400"
>
✕ Remove
</button>
</span>
</div>
<img
id="imagePreview"
class="image-preview"
alt="Image Preview"
/>
</div>
<div class="flex items-center">
<input
type="checkbox"
id="itemOutOfStock"
name="out_of_stock"
class="w-4 h-4 text-yellow-600 bg-gray-100 border-gray-300 rounded focus:ring-yellow-500 dark:focus:ring-yellow-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"
/>
<label
for="itemOutOfStock"
class="ml-2 text-sm font-medium text-gray-900 dark:text-gray-300"
>
Mark as Out of Stock
</label>
</div>
<div
class="flex gap-4 justify-end mt-8 pt-6 border-t border-gray-200 dark:border-slate-700 transition-colors duration-300"
>
<button
type="button"
class="px-6 py-3 bg-gray-500 dark:bg-slate-700 text-white dark:text-gray-300 rounded-full font-semibold hover-lift transition-all duration-300 hover:shadow-lg hover:bg-gray-600 dark:hover:bg-slate-600"
onclick="closeModal()"
>
Cancel
</button>
<button
type="submit"
id="saveItemBtn"
class="bg-gradient-success dark:bg-gradient-to-r dark:from-yellow-500 dark:to-yellow-600 text-white px-6 py-3 rounded-full font-semibold hover-lift transition-all duration-300 hover:shadow-xl flex items-center gap-2"
>
<span id="saveItemText">💾 Save Item</span>
<span id="saveItemSpinner" class="hidden">⏳ Saving...</span>
</button>
</div>
</form>
</div>
</div>
</div>
</div>
<div
id="deleteModal"
class="fixed inset-0 bg-black bg-opacity-70 z-50 hidden transition-opacity duration-300"
>
<div class="flex items-center justify-center min-h-screen p-4">
<div
class="bg-white dark:bg-slate-800 rounded-3xl w-full max-w-md shadow-2xl animate-bounce-gentle border-2 border-gray-200 dark:border-slate-700 transition-colors duration-300"
>
<div class="p-8">
<div class="text-center mb-6">
<div
class="w-16 h-16 mx-auto mb-4 bg-red-100 dark:bg-red-900/30 rounded-full flex items-center justify-center transition-colors duration-300"
>
<span class="text-3xl">🗑️</span>
</div>
<h2
class="text-2xl font-bold text-gray-800 dark:text-red-400 mb-2 transition-colors duration-300"
>
Delete Item
</h2>
<p
class="text-gray-600 dark:text-gray-300 transition-colors duration-300"
>
Are you sure you want to delete this item? This action cannot be
undone.
</p>
</div>
<div class="flex gap-3 justify-center">
<button
id="cancelDeleteBtn"
class="px-6 py-3 bg-gray-500 dark:bg-slate-700 text-white dark:text-gray-300 rounded-full font-semibold hover-lift transition-all duration-300 hover:shadow-lg hover:bg-gray-600 dark:hover:bg-slate-600"
>
Cancel
</button>
<button
id="confirmDeleteBtn"
class="bg-gradient-danger dark:bg-gradient-to-r dark:from-red-600 dark:to-red-700 text-white px-6 py-3 rounded-full font-semibold hover-lift transition-all duration-300 hover:shadow-xl flex items-center gap-2"
>
🗑️ Delete
</button>
</div>
</div>
</div>
</div>
</div>
<script>
let editingItemId = null;
let inventory = [];
let itemToDelete = null;
let isSubmitting = false;
let currentImageUrl = ""; // Track current image URL for edits
// --- AWS S3 Configuration (Dynamically Loaded) ---
let S3_BUCKET_NAME = "";
let S3_REGION = "";
let S3_BASE_URL = ""; // Will be set after fetching config
// Function to fetch S3 configuration from the backend
async function fetchS3Config() {
try {
const response = await fetch("/api/s3-config");
if (!response.ok) {
throw new Error("Failed to fetch S3 configuration");
}
const config = await response.json();
S3_BUCKET_NAME = config.bucketName;
S3_REGION = config.region;
S3_BASE_URL = `https://${S3_BUCKET_NAME}.s3.${S3_REGION}.amazonaws.com/`;
console.log("S3 config loaded:", S3_BASE_URL);
} catch (error) {
console.error("Error loading S3 configuration:", error);
// Fallback or error handling if config cannot be loaded
S3_BASE_URL = "https://placehold.co/100x100/FF0000/FFFFFF?text=Error"; // Visual fallback
}
}
// Call fetchS3Config as soon as the script loads
// and ensure loadInventory() waits for it.
(async () => {
await fetchS3Config();
loadInventory(); // Now load inventory only after S3 config is ready
})();
// Handle file selection - ensures only one file is selected and shows preview
function handleFileSelect(input) {
if (input.files && input.files[0]) {
const file = input.files[0];
const fileNameDisplay = document.getElementById("selectedFileName");
const fileName = document.getElementById("fileName");
const imagePreview = document.getElementById("imagePreview");
const photoUploadBtn = document.getElementById("photoUploadBtn");
const clearImageContainer = document.getElementById(
"clearImageContainer"
); // Get the container
// Validate file type
if (!file.type.match("image.*")) {
alert("Please select an image file (JPEG, PNG, etc.)");
input.value = "";
return;
}
// Validate file size (max 5MB)
if (file.size > 5 * 1024 * 1024) {
alert("Image size should be less than 5MB");
input.value = "";
return;
}
fileName.textContent = file.name;
fileNameDisplay.classList.remove("hidden");
// Disable the photo upload button
photoUploadBtn.classList.add("photo-btn-disabled");
photoUploadBtn.disabled = true;
photoUploadBtn.innerHTML = "Photo Selected";
// Hide the "Clear Image" checkbox when a new file is selected
if (clearImageContainer) {
clearImageContainer.classList.add("hidden");
document.getElementById("clearImageCheckbox").checked = false; // Uncheck it
}
// Show image preview
const reader = new FileReader();
reader.onload = function (e) {
imagePreview.src = e.target.result;
imagePreview.style.display = "block";
};
reader.readAsDataURL(file);
}
}
// Clear photo selection
function clearPhotoSelection() {
const fileInput = document.getElementById("itemImageFile");
const fileNameDisplay = document.getElementById("selectedFileName");
const imagePreview = document.getElementById("imagePreview");
const photoUploadBtn = document.getElementById("photoUploadBtn");
const clearImageContainer = document.getElementById(
"clearImageContainer"
); // Get the container
fileInput.value = "";
fileNameDisplay.classList.add("hidden");
imagePreview.style.display = "none";
// Re-enable the photo upload button
photoUploadBtn.classList.remove("photo-btn-disabled");
photoUploadBtn.disabled = false;
photoUploadBtn.innerHTML = "📸 Select Single Photo";
// Show "Clear Image" checkbox if it was hidden and we are editing
if (clearImageContainer && editingItemId) {
clearImageContainer.classList.remove("hidden");
} else if (clearImageContainer) {
// For add new item, ensure it's hidden
clearImageContainer.classList.add("hidden");
document.getElementById("clearImageCheckbox").checked = false;
}
// Clear current image URL if editing and the user explicitly clicks remove
if (editingItemId) {
currentImageUrl = ""; // Explicitly clear if the user clicks remove
// Mark the checkbox as checked if user clicks clear, so it sends the signal
if (document.getElementById("clearImageCheckbox")) {
document.getElementById("clearImageCheckbox").checked = true;
}
}
}
// Theme toggle functionality
document.addEventListener("DOMContentLoaded", function () {
const darkModeToggle = document.getElementById("darkModeToggle");
// Function to set theme with transition
function setTheme(isDark) {
// Start transition
document.documentElement.classList.add("transition-colors");
document.documentElement.classList.add("duration-300");
if (isDark) {
document.documentElement.classList.add("dark");
localStorage.setItem("color-theme", "dark");
} else {
document.documentElement.classList.remove("dark");
localStorage.setItem("color-theme", "light");
}
// Remove transition classes after animation completes
setTimeout(() => {
document.documentElement.classList.remove("transition-colors");
document.documentElement.classList.remove("duration-300");
}, 300);
}
// Check for saved theme preference or use system preference
if (
localStorage.getItem("color-theme") === "dark" ||
(!("color-theme" in localStorage) &&
window.matchMedia("(prefers-color-scheme: dark)").matches)
) {
setTheme(true);
} else {
setTheme(false);
}
// Dark mode toggle click event
darkModeToggle.addEventListener("click", function () {
const isDark = !document.documentElement.classList.contains("dark");
setTheme(isDark);
});
});
// Disable/Enable submit button
function setSubmitButtonState(disabled) {
const saveBtn = document.getElementById("saveItemBtn");
const saveText = document.getElementById("saveItemText");
const saveSpinner = document.getElementById("saveItemSpinner");
if (disabled) {
saveBtn.classList.add("btn-disabled");
saveBtn.disabled = true;
saveText.classList.add("hidden");
saveSpinner.classList.remove("hidden");
} else {
saveBtn.classList.remove("btn-disabled");
saveBtn.disabled = false;
saveText.classList.remove("hidden");
saveSpinner.classList.add("hidden");
}
}
// Load inventory from server
// This function will now be called AFTER S3 config is loaded
function loadInventory() {
fetch("/menu")
.then((response) => response.json())
.then((data) => {
inventory = data.map((item) => ({
...item,
// Change from is_out_of_stock to stock
stock: item.stock !== undefined ? item.stock : true, // Default to true if not set
}));
renderInventory();
})
.catch((error) => console.error("Error fetching inventory:", error));
}
// Function to get image display element
function getImageDisplay(item) {
let imageUrl;
// Check if item.image already contains a full S3 URL (starts with https://)
if (item.image && item.image.startsWith("https://")) {
imageUrl = item.image;
} else if (item.image) {
// If it's just an S3 key (e.g., 'menu-items/image.jpg'), prepend the base URL.
imageUrl = `${S3_BASE_URL}${item.image}`;
} else {
// Fallback: Use no-image.jpg from S3. Assuming it's in the 'images' folder in your S3 bucket.
imageUrl = `${S3_BASE_URL}images/no-image.jpg`;
}
return `
<div class="relative">
<img src="${imageUrl}" alt="${item.name}" class="item-image"
onerror="this.style.display='none'; this.nextElementSibling.style.display='flex';">
<div class="item-image bg-gray-200 dark:bg-slate-600 flex items-center justify-center text-2xl text-gray-400 dark:text-gray-500 transition-colors duration-300" style="display: none;">
<img src="${S3_BASE_URL}images/no-image.jpg" alt="No Image" class="h-12 w-12 opacity-50">
</div>
${
!item.stock
? '<span class="out-of-stock-badge">Out of Stock</span>'
: ""
}
</div>`;
}
// Render inventory into table
function renderInventory() {
const tbody = document.getElementById("inventoryTableBody");
const searchTerm = document
.getElementById("searchInput")
.value.toLowerCase();
const filteredInventory = inventory.filter(
(item) =>
item && item.name && item.name.toLowerCase().includes(searchTerm)
);
tbody.innerHTML = filteredInventory
.map(
(item) => `
<tr class="transition-colors duration-200 bg-gray-50 dark:bg-slate-800">
<td class="px-4 py-5 ${!item.stock ? "opacity-70" : ""}">
${getImageDisplay(item)}
</td>
<td class="px-4 py-5 font-semibold text-gray-800 dark:text-gray-200 text-lg transition-colors duration-300 ${
!item.stock ? "opacity-70" : ""
}">
${item.name}
</td>
<td class="px-4 py-5 text-lg font-bold ${
!item.stock
? "text-gray-500 dark:text-gray-400 opacity-70"
: "text-green-600 dark:text-green-400"
} transition-colors duration-300">
₹${item.price}
</td>
<td class="px-4 py-5 ${!item.stock ? "opacity-70" : ""}">
${
!item.stock
? '<span class="bg-red-100 text-red-800 text-xs font-medium px-2.5 py-0.5 rounded dark:bg-red-900 dark:text-red-300">Out of Stock</span>'
: '<span class="bg-green-100 text-green-800 text-xs font-medium px-2.5 py-0.5 rounded dark:bg-green-900 dark:text-green-300">In Stock</span>'
}
</td>
<td class="px-4 py-5">
<div class="flex gap-2">
<button
class="bg-gradient-warning text-white px-4 py-2 rounded-full text-sm font-semibold hover-lift transition-all duration-300 hover:shadow-lg flex items-center gap-1 ${
!item.stock
? "opacity-30 pointer-events-none"
: ""
}"
onclick="editItem(${item.id})"
>
✏️ Edit
</button>
<button
class="bg-gradient-danger text-white px-4 py-2 rounded-full text-sm font-semibold hover-lift transition-all duration-300 hover:shadow-lg flex items-center gap-1 ${