forked from NotThushar/SlotChain
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1717 lines (1567 loc) · 106 KB
/
index.html
File metadata and controls
1717 lines (1567 loc) · 106 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
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SlotChain - Book Your Grooming Station</title>
<!-- --- MODIFIED: Favicon updated to the new image --- -->
<link rel="icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABcc8IOAAAAAXNSR0IArs4c6QAAAzFJREFUeF7t1AEJAAAMAsHZv/RyPNwSyDxUtACECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIDAAn8BMwAB85NB53EAAAAASUVORK5CYII=" type="image/png">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/js/all.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
body { font-family: 'Inter', sans-serif; transition: all 0.3s ease; }
.gradient-bg { background: linear-gradient(135deg, #ff8c00 0%, #ff6b35 100%); }
.card-hover { transition: all 0.3s ease; }
.card-hover:hover { transform: translateY(-5px); box-shadow: 0 20px 40px rgba(0,0,0,0.1); }
.crypto-glow { box-shadow: 0 0 20px rgba(255, 140, 0, 0.3); }
.nft-glow { box-shadow: 0 0 20px rgba(139, 92, 246, 0.4); }
.secure-glow { box-shadow: 0 0 20px rgba(34, 197, 94, 0.4); }
.hbar-glossy, .crypto-glossy {
box-shadow:
inset 0 2px 0 rgba(255, 255, 255, 0.4),
inset 0 -2px 0 rgba(0, 0, 0, 0.15);
border: 2px solid rgba(255, 255, 255, 0.3);
transition: all 0.4s ease;
}
.hbar-glossy {
background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
box-shadow: 0 12px 40px rgba(139, 92, 246, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.4), inset 0 -2px 0 rgba(0, 0, 0, 0.15);
}
.crypto-glossy {
background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
box-shadow: 0 12px 40px rgba(249, 115, 22, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.4), inset 0 -2px 0 rgba(0, 0, 0, 0.15);
}
label:hover .hbar-glossy, label:hover .crypto-glossy {
box-shadow:
0 20px 60px rgba(139, 92, 246, 0.8),
inset 0 2px 0 rgba(255, 255, 255, 0.5),
inset 0 -2px 0 rgba(0, 0, 0, 0.2);
transform: translateY(-4px) scale(1.1);
}
label:hover .crypto-glossy {
box-shadow:
0 20px 60px rgba(249, 115, 22, 0.8),
inset 0 2px 0 rgba(255, 255, 255, 0.5),
inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}
.nft-shimmer { background: linear-gradient(45deg, #fbbf24 25%, #f59e0b 50%, #fbbf24 75%); background-size: 200% 100%; animation: shimmer 2s infinite; }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.booking-slot { transition: all 0.2s ease; }
.booking-slot:hover { background-color: #f3f4f6; }
.booking-slot.selected { background-color: #ff8c00; color: white; }
.notification { position: fixed; top: 20px; right: 20px; z-index: 1000; transform: translateX(100%); transition: transform 0.3s ease; opacity: 0; }
.notification.show { transform: translateX(0); opacity: 1; }
/* Dark Mode Styles */
.dark { background-color: #0a0a0a; color: #ffffff; }
.dark .bg-white { background-color: #1a1a1a; }
.dark .bg-gray-50 { background-color: #0f0f0f; }
.dark .bg-gray-100 { background-color: #2a2a2a; }
.dark .text-gray-900 { color: #ffffff; }
.dark .text-gray-700 { color: #d1d5db; }
.dark .text-gray-600 { color: #9ca3af; }
.dark .text-gray-500 { color: #6b7280; }
.dark .border-gray-300 { border-color: #4b5563; }
.dark .shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3); }
.dark .shadow-sm { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.4); }
.dark .booking-slot:hover { background-color: #374151; }
.dark .nft-shimmer { background: linear-gradient(45deg, #374151 25%, #4b5563 50%, #374151 75%); background-size: 200% 100%; }
.dark input, .dark select { background-color: #2a2a2a; color: #ffffff; border-color: #6b7280; }
.dark #citySelect, .dark #radiusSelect, .dark #locationInput { background-color: #2a2a2a; color: #ffffff; border-color: #6b7280; }
.dark input::placeholder { color: #6b7280; }
.dark .chatbot-window { background: #1a1a1a; }
.dark .chatbot-input-area { border-color: #4b5563; }
/* Dark mode setup station styles */
.dark .bg-gradient-to-r.from-orange-100.to-yellow-100 {
background: linear-gradient(to right, #7c2d12, #a16207);
border-color: #ea580c;
}
.dark .bg-gradient-to-r.from-orange-100.to-yellow-100 .text-gray-900 { color: #ffffff; }
.dark .bg-gradient-to-r.from-orange-100.to-yellow-100 .text-gray-800 { color: #f3f4f6; }
/* Chatbot Styles */
.chatbot-container { position: fixed; bottom: 20px; right: 20px; z-index: 1000; }
.chatbot-toggle { width: 60px; height: 60px; border-radius: 50%; background: linear-gradient(135deg, #ff8c00 0%, #ff6b35 100%); color: white; border: none; cursor: pointer; box-shadow: 0 4px 12px rgba(255, 140, 0, 0.3); transition: all 0.3s ease; }
.chatbot-toggle:hover { transform: scale(1.1); }
.chatbot-window { position: absolute; bottom: 80px; right: 0; width: 350px; height: 500px; background: white; border-radius: 12px; box-shadow: 0 20px 40px rgba(0,0,0,0.15); display: none; flex-direction: column; }
.dark .chatbot-window { background: #2d2d2d; }
.chatbot-header { padding: 16px; background: linear-gradient(135deg, #ff8c00 0%, #ff6b35 100%); color: white; border-radius: 12px 12px 0 0; }
.chatbot-messages { flex: 1; padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.chatbot-input-area { padding: 16px; border-top: 1px solid #e5e7eb; }
.dark .chatbot-input-area { border-color: #4b5563; }
.message { max-width: 80%; padding: 8px 12px; border-radius: 12px; }
.message.user { background: #ff8c00; color: white; align-self: flex-end; }
.message.bot { background: #f3f4f6; color: #374151; align-self: flex-start; }
.dark .message.bot { background: #374151; color: #d1d5db; }
.typing-indicator { display: none; align-self: flex-start; padding: 8px 12px; background: #f3f4f6; border-radius: 12px; }
.dark .typing-indicator { background: #374151; }
.typing-dots { display: flex; gap: 4px; }
.typing-dot { width: 6px; height: 6px; background: #9ca3af; border-radius: 50%; animation: typing 1.4s infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-10px); } }
/* Image Carousel Styles */
.image-carousel {
position: relative;
width: 100%;
height: 200px;
overflow: hidden;
border-radius: 12px 12px 0 0;
}
.carousel-image {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
opacity: 0;
transition: opacity 0.5s ease-in-out;
}
.carousel-image.active {
opacity: 1;
}
.carousel-controls {
position: absolute;
top: 50%;
transform: translateY(-50%);
background: rgba(0, 0, 0, 0.5);
color: white;
border: none;
width: 30px;
height: 30px;
border-radius: 50%;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.3s ease;
}
.carousel-controls:hover {
background: rgba(0, 0, 0, 0.7);
}
.carousel-prev {
left: 10px;
}
.carousel-next {
right: 10px;
}
.loading-spinner {
display: inline-block;
width: 20px;
height: 20px;
border: 3px solid #f3f3f3;
border-top: 3px solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* Theme Toggle */
.theme-toggle { position: relative; width: 50px; height: 24px; background: #d1d5db; border-radius: 12px; cursor: pointer; transition: background 0.3s ease; }
.theme-toggle.dark { background: #ff8c00; }
.theme-toggle-slider { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; background: white; border-radius: 50%; transition: transform 0.3s ease; }
.theme-toggle.dark .theme-toggle-slider { transform: translateX(26px); }
</style>
</head>
<body class="bg-gray-50 dark">
<!-- Notification System -->
<div id="notification" class="notification bg-green-500 text-white px-6 py-3 rounded-lg shadow-lg">
<div class="flex items-center justify-between">
<div class="flex items-center">
<i class="fas fa-check-circle mr-2"></i>
<span id="notificationText">Booking confirmed!</span>
</div>
<button id="closeNotification" class="ml-4 text-white hover:text-gray-200 transition-colors">
<i class="fas fa-times"></i>
</button>
</div>
</div>
<!-- Navigation -->
<nav class="bg-white shadow-lg sticky top-0 z-50">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex items-center">
<div class="flex-shrink-0 flex items-center">
<i class="fas fa-cut text-2xl text-orange-500 mr-2"></i>
<span class="text-2xl font-bold text-gray-900">SlotChain</span>
</div>
</div>
<div class="flex items-center space-x-4">
<button id="setupStationBtn" class="text-orange-500 hover:text-orange-600 px-3 py-2 rounded-md text-sm font-medium flex items-center">
<i class="fas fa-store mr-2"></i>
Setup Station
</button>
<button id="loginBtn" class="text-gray-700 hover:text-orange-500 px-3 py-2 rounded-md text-sm font-medium">Login</button>
<button id="signupBtn" class="bg-orange-500 hover:bg-orange-600 text-white px-4 py-2 rounded-md text-sm font-medium">Sign Up</button>
<div id="userMenu" class="hidden flex items-center space-x-4">
<span id="userName" class="text-gray-700 font-medium"></span>
<button id="dashboardBtn" class="text-orange-500 hover:text-orange-600">Dashboard</button>
<button id="logoutBtn" class="text-gray-500 hover:text-gray-700">Logout</button>
</div>
</div>
</div>
</div>
</nav>
<!-- Main Content -->
<div id="mainContent">
<!-- Hero Section -->
<section class="relative text-white py-20 overflow-hidden">
<!-- Background Image -->
<div class="absolute inset-0">
<img src="https://images.unsplash.com/photo-1585747860715-2ba37e788b70?w=1920&h=1080&fit=crop"
alt="Modern Indian barber shop interior"
class="w-full h-full object-cover">
<div class="absolute inset-0 bg-black bg-opacity-50"></div>
</div>
<!-- Content Overlay -->
<div class="relative z-10 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
<h1 class="text-5xl font-bold mb-6">Your next haircut or makeover, just a click away</h1>
<p class="text-xl mb-8 opacity-90">Secure blockchain-powered bookings with crypto payments and exclusive NFT rewards</p>
<div class="flex justify-center">
<button id="bookNowBtn" class="bg-white text-orange-500 px-8 py-3 rounded-lg font-semibold hover:bg-gray-100 transition duration-300">Book Now</button>
</div>
</div>
</section>
<!-- Features Section -->
<section class="py-16 bg-white">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="text-center mb-12">
<h2 class="text-3xl font-bold text-gray-900 mb-4">Why Choose SlotChain?</h2>
<p class="text-gray-600 max-w-2xl mx-auto">Experience the future of grooming bookings with blockchain technology</p>
</div>
<div class="grid md:grid-cols-3 gap-8">
<div class="text-center p-6 card-hover bg-gray-50 rounded-xl">
<div class="crypto-glow bg-orange-100 w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4">
<i class="fas fa-coins text-2xl text-orange-500"></i>
</div>
<h3 class="text-xl font-semibold mb-2">Crypto Payments</h3>
<p class="text-gray-600">Pay with Hedera HBAR or traditional cards</p>
</div>
<div class="text-center p-6 card-hover bg-gray-50 rounded-xl">
<div class="nft-glow bg-purple-100 w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4">
<i class="fas fa-gem text-2xl text-purple-600"></i>
</div>
<h3 class="text-xl font-semibold mb-2">NFT Rewards</h3>
<p class="text-gray-600">Earn exclusive collectible NFTs with each booking</p>
</div>
<div class="text-center p-6 card-hover bg-gray-50 rounded-xl">
<div class="secure-glow bg-green-100 w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4">
<i class="fas fa-shield-alt text-2xl text-green-600"></i>
</div>
<h3 class="text-xl font-semibold mb-2">Secure Booking</h3>
<p class="text-gray-600">Blockchain-secured appointments and data</p>
</div>
</div>
</div>
</section>
<!-- Network Section -->
<section id="stationsSection" class="py-16 bg-gray-50">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="text-center mb-12">
<h2 class="text-3xl font-bold text-gray-900 mb-4">SlotChain Network</h2>
<p class="text-gray-600 max-w-2xl mx-auto">Discover grooming stations in your area or join our network as a station owner</p>
</div>
<!-- Location Controls -->
<div class="bg-white rounded-xl shadow-sm p-6 mb-8">
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-4">
<button id="useLocationBtn" class="bg-indigo-600 text-white px-4 py-2 rounded-md hover:bg-indigo-700 transition duration-300 flex items-center justify-center">
<i class="fas fa-location-arrow mr-2"></i>
Use My Location
</button>
<div class="flex">
<input type="text" id="locationInput" placeholder="Enter city or address" class="flex-1 px-3 py-2 border border-gray-300 rounded-l-md focus:outline-none focus:ring-2 focus:ring-indigo-500 min-w-0">
<button id="searchLocationBtn" class="bg-gray-600 text-white px-4 py-2 rounded-r-md hover:bg-gray-700 transition duration-300 flex-shrink-0">
<i class="fas fa-search"></i>
</button>
</div>
<select id="citySelect" class="px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500 min-w-0">
<option value="">Select a city</option>
<option value="Bengaluru, Karnataka">Bengaluru</option>
<option value="Mysuru, Karnataka">Mysuru</option>
<option value="Hubli, Karnataka">Hubli</option>
<option value="Dharwad, Karnataka">Dharwad</option>
<option value="Mangaluru, Karnataka">Mangaluru</option>
<option value="Belagavi, Karnataka">Belagavi</option>
<option value="Davangere, Karnataka">Davangere</option>
<option value="Ballari, Karnataka">Ballari</option>
<option value="Vijayapura, Karnataka">Vijayapura</option>
<option value="Shivamogga, Karnataka">Shivamogga</option>
<option value="Tumakuru, Karnataka">Tumakuru</option>
<option value="Raichur, Karnataka">Raichur</option>
<option value="Bidar, Karnataka">Bidar</option>
<option value="Hospet, Karnataka">Hospet</option>
<option value="Hassan, Karnataka">Hassan</option>
<option value="Gadag, Karnataka">Gadag</option>
<option value="Udupi, Karnataka">Udupi</option>
<option value="Kolar, Karnataka">Kolar</option>
<option value="Mandya, Karnataka">Mandya</option>
<option value="Chikkamagaluru, Karnataka">Chikkamagaluru</option>
<option value="Chitradurga, Karnataka">Chitradurga</option>
</select>
<button id="searchCityBtn" class="bg-orange-500 text-white px-4 py-2 rounded-md hover:bg-orange-600 transition duration-300 whitespace-nowrap">
Search City
</button>
</div>
<div class="flex items-center justify-between">
<div class="flex items-center space-x-4">
<label class="text-sm font-medium text-gray-700">Search Radius:</label>
<select id="radiusSelect" class="px-3 py-1 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500">
<option value="5000">5 km</option>
<option value="10000" selected>10 km</option>
<option value="25000">25 km</option>
<option value="50000">50 km</option>
</select>
</div>
<div id="locationStatus" class="hidden text-sm text-gray-600">
<i class="fas fa-map-marker-alt mr-1"></i>
<span id="currentLocation">Searching...</span>
</div>
</div>
</div>
<!-- Action Buttons -->
<div class="flex justify-center space-x-4 mb-8">
<button id="browseStationsBtn" class="bg-indigo-600 text-white px-8 py-3 rounded-lg font-semibold hover:bg-indigo-700 transition duration-300 flex items-center">
<i class="fas fa-search mr-2"></i>
Browse Stations
</button>
<button id="setupStationMainBtn" class="border-2 border-indigo-600 text-indigo-600 px-8 py-3 rounded-lg font-semibold hover:bg-indigo-600 hover:text-white transition duration-300 flex items-center">
<i class="fas fa-store mr-2"></i>
Setup Your Station
</button>
</div>
<!-- Loading State -->
<div id="loadingStations" class="hidden text-center py-12">
<div class="loading-spinner mx-auto mb-4"></div>
<p class="text-gray-600">Finding grooming stations near you...</p>
</div>
<!-- Stations Display -->
<div id="stationsList" class="grid md:grid-cols-2 lg:grid-cols-3 gap-8">
<!-- Stations will be populated here -->
</div>
</div>
</section>
</div>
<!-- Auth Modal -->
<div id="authModal" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-xl p-8 max-w-md w-full mx-4 relative">
<button id="closeAuthModal" class="absolute top-4 right-4 text-gray-400 hover:text-gray-600">
<i class="fas fa-times"></i>
</button>
<div class="text-center mb-6">
<h3 id="authTitle" class="text-2xl font-bold text-gray-900">Welcome to SlotChain</h3>
<p class="text-gray-600 mt-2">Join the future of grooming bookings</p>
</div>
<form id="authForm">
<div id="nameField" class="hidden mb-4">
<label class="block text-sm font-medium text-gray-700 mb-2">Full Name</label>
<input type="text" id="fullName" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500">
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-2">Email</label>
<input type="email" id="email" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500" required>
</div>
<div class="mb-6">
<label class="block text-sm font-medium text-gray-700 mb-2">Password</label>
<input type="password" id="password" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500" required>
</div>
<button type="submit" id="authSubmit" class="w-full bg-indigo-600 text-white py-2 rounded-md hover:bg-indigo-700 transition duration-300">Sign In</button>
</form>
<div class="mt-4 text-center">
<button id="authToggle" class="text-indigo-600 hover:text-indigo-800">Don't have an account? Sign up</button>
</div>
</div>
</div>
<!-- Booking Modal -->
<div id="bookingModal" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white dark:bg-gray-800 rounded-xl p-8 max-w-2xl w-full mx-4 max-h-screen overflow-y-auto relative">
<button id="closeBookingModal" class="absolute top-4 right-4 text-gray-400 hover:text-gray-600 z-10">
<i class="fas fa-times text-xl"></i>
</button>
<div class="mb-6">
<h3 class="text-2xl font-bold text-gray-900">Book Your Appointment</h3>
</div>
<div id="bookingStep1" class="booking-step">
<h4 class="text-lg font-semibold mb-4">Select Service & Date</h4>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-2">Service</label>
<select id="serviceSelect" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500">
<option value="">Select a service</option>
<option value="haircut">Haircut</option>
<option value="beard-trim">Beard Trim</option>
<option value="full-service">Full Service</option>
<option value="styling">Hair Styling</option>
</select>
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-2">Date</label>
<input type="date" id="bookingDate" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500" required>
</div>
<div class="mb-6">
<label class="block text-sm font-medium text-gray-700 mb-2">Available Time Slots</label>
<div id="timeSlots" class="grid grid-cols-3 gap-2">
<!-- Time slots will be populated here -->
</div>
</div>
<button id="nextToPayment" class="w-full bg-indigo-600 text-white py-2 rounded-md hover:bg-indigo-700 transition duration-300 disabled:bg-gray-400" disabled>Continue to Payment</button>
</div>
<div id="bookingStep2" class="booking-step hidden">
<h4 class="text-lg font-semibold mb-4">Payment & NFT Minting</h4>
<div class="bg-gray-50 p-4 rounded-lg mb-6">
<div class="flex justify-between items-center mb-2">
<span>Service:</span>
<span id="selectedService" class="font-semibold"></span>
</div>
<div class="flex justify-between items-center mb-2">
<span>Date & Time:</span>
<span id="selectedDateTime" class="font-semibold"></span>
</div>
<div class="flex justify-between items-center text-lg font-bold">
<span>Total:</span>
<span id="totalAmount">$0</span>
</div>
</div>
<div class="mb-6">
<h5 class="font-semibold mb-3">Payment Method</h5>
<div class="space-y-3">
<label class="flex items-center p-4 border-2 border-purple-400 rounded-xl cursor-pointer hover:bg-gradient-to-r hover:from-purple-50 hover:to-indigo-50 dark:hover:from-purple-900/30 dark:hover:to-indigo-900/30 hover:border-purple-500 dark:hover:border-purple-500 transition-all duration-300 shadow-lg hover:shadow-xl transform hover:scale-105 bg-gradient-to-r from-purple-25 to-indigo-25">
<input type="radio" name="paymentMethod" value="hedera" class="mr-4">
<div class="hbar-glossy p-4 rounded-xl relative overflow-hidden">
<div class="absolute inset-0 bg-gradient-to-br from-purple-400 to-indigo-600 opacity-20"></div>
<div class="w-8 h-8 text-white relative z-10 flex items-center justify-center font-bold text-2xl">
<div class="relative">
<div class="text-white font-black text-2xl leading-none">H</div>
<div class="absolute top-1/2 left-0 right-0 h-0.5 bg-white transform -translate-y-1"></div>
<div class="absolute top-1/2 left-0 right-0 h-0.5 bg-white transform translate-y-1"></div>
</div>
</div>
</div>
<div class="ml-4 flex-1">
<div class="font-bold text-lg text-gray-900 dark:text-white">
Hedera HBAR
</div>
<div class="text-sm text-purple-800 dark:text-purple-300 font-semibold">Pay with cryptocurrency + Get exclusive NFT reward</div>
<div class="text-xs text-purple-700 dark:text-purple-400 mt-1 font-medium">✨ Earn collectible tokens with every booking</div>
</div>
</label>
<!-- --- MODIFIED: Added dark mode hover styles --- -->
<label class="flex items-center p-4 border-2 border-orange-400 rounded-xl cursor-pointer hover:bg-gradient-to-r hover:from-orange-50 hover:to-yellow-50 dark:hover:from-orange-900/30 dark:hover:to-yellow-900/30 transition-all duration-300 shadow-lg hover:shadow-xl transform hover:scale-105 bg-gradient-to-r from-orange-25 to-yellow-25">
<input type="radio" name="paymentMethod" value="crypto" class="mr-4">
<div class="crypto-glossy p-4 rounded-xl relative overflow-hidden">
<i class="fas fa-coins text-white text-2xl"></i>
</div>
<div class="ml-4 flex-1">
<div class="font-bold text-lg text-gray-900 dark:text-white">Other Crypto</div>
<div class="text-sm text-orange-800 dark:text-orange-300 font-semibold">Pay with ETH, SOL, TON, and more</div>
</div>
</label>
<label class="card-payment-option flex items-center p-4 border-2 border-emerald-500 rounded-xl cursor-pointer hover:bg-gradient-to-r hover:from-emerald-50 hover:to-green-50 dark:hover:from-emerald-900/30 dark:hover:to-green-900/30 hover:border-emerald-600 dark:hover:border-emerald-400 transition-all duration-300 shadow-lg hover:shadow-xl bg-gradient-to-r from-emerald-50/50 to-green-50/50 dark:bg-gradient-to-r dark:from-emerald-900/20 dark:to-green-900/20">
<input type="radio" name="paymentMethod" value="card" class="mr-4">
<div class="card-glossy p-4 rounded-xl">
<i class="fas fa-credit-card text-white text-xl"></i>
</div>
<div class="ml-4 flex-1">
<div class="font-bold text-lg text-emerald-900 dark:text-emerald-100">Credit/Debit Card</div>
<div class="text-sm text-emerald-800 dark:text-emerald-200 font-semibold">Traditional payment method</div>
</div>
</label>
</div>
</div>
<div id="nftPreview" class="hidden mb-6 p-6 bg-gradient-to-r from-purple-600 to-indigo-600 rounded-lg border-2 border-purple-400 shadow-lg">
<h5 class="font-bold mb-3 flex items-center text-white text-lg">
<i class="fas fa-gem text-yellow-300 mr-2 text-xl"></i>
Your Exclusive NFT Reward
</h5>
<div class="flex items-center space-x-4">
<div class="w-20 h-20 bg-gradient-to-br from-yellow-400 to-orange-500 rounded-lg flex items-center justify-center nft-shimmer shadow-lg border-2 border-yellow-300">
<i class="fas fa-cut text-white text-2xl"></i>
</div>
<div>
<div class="font-bold text-white text-lg">SlotChain Grooming NFT #<span id="nftNumber">001</span></div>
<div class="text-purple-100 font-medium">Collectible grooming experience token</div>
<div class="text-yellow-300 text-sm font-semibold mt-1">✨ Limited Edition ✨</div>
</div>
</div>
</div>
<div class="flex space-x-4">
<button id="backToBooking" class="flex-1 border border-gray-300 text-gray-700 py-2 rounded-md hover:bg-gray-50 transition duration-300">Back</button>
<!-- --- MODIFIED: Changed button text --- -->
<button id="proceedToCheckoutBtn" class="flex-1 bg-indigo-600 text-white py-2 rounded-md hover:bg-indigo-700 transition duration-300">Proceed to Checkout</button>
</div>
</div>
</div>
</div>
<!-- --- NEW: Card Payment Modal --- -->
<div id="cardPaymentModal" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-xl p-8 max-w-md w-full mx-4 relative">
<button id="closeCardModal" class="absolute top-4 right-4 text-gray-400 hover:text-gray-600">
<i class="fas fa-times"></i>
</button>
<h3 class="text-xl font-bold text-gray-900 mb-6">Enter Card Details</h3>
<form id="cardPaymentForm">
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-2">Card Number</label>
<input type="text" placeholder="0000 0000 0000 0000" class="w-full px-3 py-2 border border-gray-300 rounded-md" required>
</div>
<div class="grid grid-cols-2 gap-4 mb-6">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Expiry Date</label>
<input type="text" placeholder="MM/YY" class="w-full px-3 py-2 border border-gray-300 rounded-md" required>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">CVC</label>
<input type="text" placeholder="123" class="w-full px-3 py-2 border border-gray-300 rounded-md" required>
</div>
</div>
<button type="submit" class="w-full bg-green-500 text-white py-2 rounded-md hover:bg-green-600">Pay Now (Demo)</button>
</form>
</div>
</div>
<!-- --- NEW: NOWPayments Modal --- -->
<div id="nowPaymentsModal" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-xl p-8 max-w-lg w-full mx-4 relative">
<button id="closeNowPaymentsModal" class="absolute top-4 right-4 text-gray-400 hover:text-gray-600"><i class="fas fa-times"></i></button>
<h3 class="text-xl font-bold text-gray-900 mb-4">Complete Your Payment</h3>
<p class="text-gray-600 mb-6">Your booking is pending. Please complete your payment using the widget below to confirm your appointment.</p>
<div class="w-full h-[700px]">
<iframe id="nowPaymentsWidget" src="https://nowpayments.io/embeds/payment-widget?iid=5552980381" width="410" height="696" frameborder="0" scrolling="no" style="overflow-y: hidden;">
Can't load widget
</iframe>
</div>
</div>
</div>
<!-- Station Setup Modal -->
<div id="stationSetupModal" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-xl p-8 max-w-2xl w-full mx-4 max-h-screen overflow-y-auto relative">
<button id="closeStationSetupModal" class="absolute top-4 right-4 text-gray-400 hover:text-gray-600 z-10">
<i class="fas fa-times text-xl"></i>
</button>
<div class="mb-6">
<h3 class="text-2xl font-bold text-gray-900">Setup Your Grooming Station</h3>
</div>
<div class="mb-6">
<div class="bg-gradient-to-r from-orange-100 to-yellow-100 p-6 rounded-lg mb-6 border border-orange-200">
<h4 class="text-lg font-semibold mb-2 flex items-center text-gray-900">
<i class="fas fa-store text-orange-600 mr-2"></i>
Join the SlotChain Network
</h4>
<p class="text-gray-800 font-medium">List your grooming station on SlotChain and start accepting crypto payments with automatic NFT rewards for your customers!</p>
</div>
<form id="stationSetupForm">
<div class="grid md:grid-cols-2 gap-4 mb-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Station Name</label>
<input type="text" id="stationName" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="e.g., Downtown Cuts" required>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Owner Name</label>
<input type="text" id="ownerName" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Your full name" required>
</div>
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-2">Address</label>
<input type="text" id="stationAddress" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="123 Main St, City, State" required>
</div>
<div class="grid md:grid-cols-2 gap-4 mb-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Phone Number</label>
<input type="tel" id="stationPhone" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="(555) 123-4567" required>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Email</label>
<input type="email" id="stationEmail" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="contact@yourstation.com" required>
</div>
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-2">Services Offered</label>
<div class="grid grid-cols-2 gap-2">
<label class="flex items-center">
<input type="checkbox" value="haircut" class="mr-2 service-checkbox">
<span>Haircuts</span>
</label>
<label class="flex items-center">
<input type="checkbox" value="beard-trim" class="mr-2 service-checkbox">
<span>Beard Trimming</span>
</label>
<label class="flex items-center">
<input type="checkbox" value="styling" class="mr-2 service-checkbox">
<span>Hair Styling</span>
</label>
<label class="flex items-center">
<input type="checkbox" value="full-service" class="mr-2 service-checkbox">
<span>Full Service</span>
</label>
</div>
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-2">Station Features</label>
<div class="grid grid-cols-2 gap-2">
<label class="flex items-center">
<input type="checkbox" value="wifi" class="mr-2 feature-checkbox">
<span>WiFi</span>
</label>
<label class="flex items-center">
<input type="checkbox" value="parking" class="mr-2 feature-checkbox">
<span>Parking Available</span>
</label>
<label class="flex items-center">
<input type="checkbox" value="premium-products" class="mr-2 feature-checkbox">
<span>Premium Products</span>
</label>
<label class="flex items-center">
<input type="checkbox" value="massage-chairs" class="mr-2 feature-checkbox">
<span>Massage Chairs</span>
</label>
</div>
</div>
<div class="mb-6">
<label class="block text-sm font-medium text-gray-700 mb-2">Hedera HBAR Wallet Address</label>
<input type="text" id="walletAddress" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="0.0.123456 (for receiving crypto payments)" required>
<p class="text-sm text-gray-500 mt-1">This is where you'll receive HBAR payments from customers</p>
</div>
<div class="bg-yellow-50 border border-yellow-200 rounded-lg p-4 mb-6">
<div class="flex items-start">
<i class="fas fa-info-circle text-yellow-600 mr-2 mt-1"></i>
<div>
<h5 class="font-semibold text-yellow-800">Setup Process</h5>
<p class="text-sm text-yellow-700">After submitting, our team will review your application and contact you within 2-3 business days to complete the onboarding process.</p>
</div>
</div>
</div>
<button type="submit" class="w-full bg-orange-500 text-white py-3 rounded-md hover:bg-orange-600 transition duration-300 font-semibold">
Submit Station Application
</button>
</form>
</div>
</div>
</div>
<!-- Dashboard -->
<div id="dashboard" class="hidden bg-gray-50 dark min-h-screen">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<div class="mb-8">
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold text-gray-900">Your Dashboard</h1>
<p class="text-gray-600">Manage your bookings and view your NFT collection</p>
</div>
<button onclick="showMainContent()" class="bg-orange-500 hover:bg-orange-600 text-white px-4 py-2 rounded-md text-sm font-medium flex items-center">
<i class="fas fa-arrow-left mr-2"></i>
Back to Home
</button>
</div>
</div>
<div class="grid lg:grid-cols-3 gap-8">
<div class="lg:col-span-2">
<div class="bg-white rounded-xl shadow-sm p-6 mb-8">
<h2 class="text-xl font-semibold mb-4 text-gray-900 flex items-center">
<i class="fas fa-calendar-check text-orange-500 mr-2"></i>
Upcoming Appointments
</h2>
<div id="upcomingBookings" class="space-y-4">
<!-- Bookings will be populated here -->
</div>
</div>
<div class="bg-white rounded-xl shadow-sm p-6">
<h2 class="text-xl font-semibold mb-4 text-gray-900 flex items-center">
<i class="fas fa-history text-indigo-600 mr-2"></i>
Booking History
</h2>
<div id="bookingHistory" class="space-y-4">
<!-- History will be populated here -->
</div>
</div>
</div>
<div>
<div class="bg-white rounded-xl shadow-sm p-6 mb-6">
<h2 class="text-xl font-semibold mb-4 flex items-center text-gray-900">
<i class="fas fa-gem text-purple-600 mr-2"></i>
Your NFT Collection
</h2>
<div id="nftCollection" class="grid grid-cols-2 gap-4">
<!-- NFTs will be populated here -->
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Credits Section -->
<footer class="bg-gray-900 text-white py-8">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="text-center">
<div class="text-lg font-bold text-orange-400 mb-2" style="text-shadow: 0 0 10px rgba(255, 140, 0, 0.6), 0 0 20px rgba(255, 140, 0, 0.4), 0 0 30px rgba(255, 140, 0, 0.2);">
Team Hat
</div>
<div class="text-sm text-gray-300" style="text-shadow: 0 0 10px rgba(255, 140, 0, 0.6), 0 0 20px rgba(255, 140, 0, 0.4), 0 0 30px rgba(255, 140, 0, 0.2);">
Created by Harshit, Anshuman & Thushar
</div>
</div>
</div>
</footer>
<!-- Chatbot -->
<div class="chatbot-container">
<div id="chatbotWindow" class="chatbot-window">
<div class="chatbot-header">
<div class="flex justify-between items-center">
<div>
<h4 class="font-semibold">SlotChain Assistant</h4>
<p class="text-sm opacity-90">Ask me anything about bookings!</p>
</div>
<button id="closeChatbot" class="text-white hover:text-gray-200">
<i class="fas fa-times"></i>
</button>
</div>
</div>
<div id="chatbotMessages" class="chatbot-messages">
<div class="message bot">
Hi! I'm your SlotChain assistant. I can help you with booking questions, payment info, or anything about our grooming stations. How can I help you today?
</div>
</div>
<div class="typing-indicator" id="typingIndicator">
<div class="typing-dots">
<div class="typing-dot"></div>
<div class="typing-dot"></div>
<div class="typing-dot"></div>
</div>
</div>
<div class="chatbot-input-area">
<div class="flex space-x-2">
<input type="text" id="chatbotInput" placeholder="Type your message..." class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500">
<button id="sendMessage" class="bg-indigo-600 text-white px-4 py-2 rounded-md hover:bg-indigo-700 transition duration-300">
<i class="fas fa-paper-plane"></i>
</button>
</div>
</div>
</div>
<button id="chatbotToggle" class="chatbot-toggle">
<i class="fas fa-comments text-xl"></i>
</button>
</div>
<script>
// --- START OF SCRIPT ---
const AUTH_API_URL = '/api/auth';
const BOOKINGS_API_URL = '/api/bookings';
const NFT_API_URL = '/api/nfts';
// Application State
let currentUser = null;
let selectedStation = null;
let selectedSlot = null;
let bookings = [];
let nftCollection = JSON.parse(localStorage.getItem('slotchain_nfts') || '[]');
let currentBookingId = null;
let chatbotOpen = false;
let map = null;
let service = null;
let userLocation = null;
let groomingStations = [];
let stationCarousels = {};
const PERPLEXITY_API_KEY = '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';
const PERPLEXITY_API_URL = 'https://api.perplexity.ai/chat/completions';
const timeSlots = [
"09:00", "09:30", "10:00", "10:30", "11:00", "11:30",
"12:00", "12:30", "13:00", "13:30", "14:00", "14:30",
"15:00", "15:30", "16:00", "16:30", "17:00", "17:30"
];
window.addEventListener('load', function() {
initializeApp();
});
function initializeApp() {
setupEventListeners();
checkAuthState();
initMap();
initializeDummyStations();
const today = new Date().toISOString().split('T')[0];
document.getElementById('bookingDate').min = today;
document.getElementById('bookingDate').value = today;
}
function proceedToCheckout() {
if (!currentUser) {
showNotification('You must be logged in to make a booking.', 'error');
showAuthModal('login');
return;
}
const paymentMethod = document.querySelector('input[name="paymentMethod"]:checked');
if (!paymentMethod) {
showNotification('Please select a payment method', 'error');
return;
}
if (paymentMethod.value === 'hedera') {
handleHbarPayment();
} else if (paymentMethod.value === 'crypto') {
handleCryptoPayment();
} else {
handleCardPayment();
}
}
async function handleHbarPayment() {
const bookingId = await confirmBookingOnServer('hedera', 'pending');
if (bookingId) {
currentBookingId = bookingId;
const nowPaymentsUrl = `https://sandbox.nowpayments.io/payment?iid=5093316327&order_id=${bookingId}`;
window.open(nowPaymentsUrl, '_blank');
// --- REMOVED 10-SECOND DELAY ---
setTimeout(() => simulatePaymentConfirmation(bookingId, 'hedera'), 500);
}
}
function handleCardPayment() {
document.getElementById('cardPaymentModal').classList.remove('hidden');
}
async function processCardPayment(e) {
e.preventDefault();
showNotification('Processing card payment...', 'info');
const bookingId = await confirmBookingOnServer('card', 'pending');
setTimeout(async () => {
document.getElementById('cardPaymentModal').classList.add('hidden');
if (bookingId) {
await updateBookingStatus(bookingId, 'confirmed');
showNotification('Card payment successful!', 'success');
}
}, 2000);
}
async function handleCryptoPayment() {
const bookingId = await confirmBookingOnServer('crypto', 'pending');
if(bookingId) {
const widgetUrl = `https://nowpayments.io/embeds/payment-widget?iid=5552980381&order_id=${bookingId}`;
document.getElementById('nowPaymentsWidget').src = widgetUrl;
document.getElementById('nowPaymentsModal').classList.remove('hidden');
// --- REMOVED 10-SECOND DELAY ---
setTimeout(() => simulatePaymentConfirmation(bookingId, 'crypto'), 500);
}
}
async function handleAuth(e) {
e.preventDefault();
const mode = document.getElementById('authModal').dataset.mode;
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
const action = mode === 'signup' ? 'register' : 'login';
try {
const response = await fetch(AUTH_API_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action, email, password }),
});
const data = await response.json();
if (!response.ok) throw new Error(data.error || 'Something went wrong');
if (action === 'register') {
showNotification('Account created successfully! Please log in.');
showAuthModal('login');
} else {
localStorage.setItem('slotchain_token', data.token);
const decodedToken = JSON.parse(atob(data.token.split('.')[1]));
currentUser = { email: decodedToken.email, name: email.split('@')[0] };
localStorage.setItem('slotchain_user', JSON.stringify(currentUser));
updateAuthUI();
hideAuthModal();
showNotification('Logged in successfully!');
}
} catch (error) {
console.error('Authentication Error:', error);
showNotification(error.message, 'error');
}
}
async function confirmBookingOnServer(paymentMethodValue, status = 'confirmed') {
const service = document.getElementById('serviceSelect');
const selectedOption = service.options[service.selectedIndex];
const date = document.getElementById('bookingDate').value;
const token = localStorage.getItem('slotchain_token');
const totalAmountText = document.getElementById('totalAmount').textContent;
const amount = totalAmountText.replace('$', '');
if (!selectedStation) {
showNotification("Error: No station selected. Please go back and select a station.", "error");
return null;
}
const bookingData = {
stationId: selectedStation.id,
stationName: selectedStation.stationName || selectedStation.name,
stationAddress: selectedStation.address || selectedStation.location,
service: selectedOption.text,
date: date,
time: selectedSlot,
amount: amount,
paymentMethod: paymentMethodValue,
status: status,
};
try {
const response = await fetch(BOOKINGS_API_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify(bookingData),
});
const newBooking = await response.json();
if (!response.ok) throw new Error(newBooking.error || 'Failed to create booking.');
// --- NEW: Add the new booking to the local array ---
bookings.push(newBooking);
hideBookingModal();
showNotification(`Booking created! Please complete your payment.`);
return newBooking._id;
} catch (error) {
console.error('Booking Error:', error);
showNotification(error.message, 'error');
return null;
}
}
// --- FIXED: Added paymentMethod parameter ---
async function simulatePaymentConfirmation(bookingId, paymentMethod) {
await updateBookingStatus(bookingId, 'confirmed');
showNotification('Payment confirmed (Simulated)! Your booking is complete.', 'success');
document.getElementById('nowPaymentsModal').classList.add('hidden');
// --- NEW: Trigger NFT minting for crypto payments ---
if (paymentMethod === 'hedera' || paymentMethod === 'crypto') {
mintNftForBooking(bookingId);
}
}
// --- NEW: Function to handle NFT creation and storage ---
function mintNftForBooking(bookingId) {
const booking = bookings.find(b => b._id === bookingId);
if (!booking) {
console.error("Could not find booking to mint NFT for.");
return;
}