-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1464 lines (1263 loc) · 65.6 KB
/
index.html
File metadata and controls
1464 lines (1263 loc) · 65.6 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" class="light">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LinkUp</title>
<link rel="icon" href="favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
animation: {
'fade-in': 'fadeIn 0.6s ease-out',
'slide-in': 'slideIn 0.6s ease-out',
'pulse-slow': 'pulse 3s infinite',
'float': 'float 6s ease-in-out infinite',
'bob': 'bob 4s ease-in-out infinite',
'spin-slow': 'spin 15s linear infinite',
'zoom': 'zoom 10s ease infinite',
},
keyframes: {
fadeIn: {
'0%': { opacity: '0' },
'100%': { opacity: '1' }
},
slideIn: {
'0%': { transform: 'translateY(20px)', opacity: '0' },
'100%': { transform: 'translateY(0)', opacity: '1' }
},
float: {
'0%, 100%': { transform: 'translateY(0)' },
'50%': { transform: 'translateY(-20px)' }
},
bob: {
'0%, 100%': { transform: 'translateY(0) rotate(0deg)' },
'50%': { transform: 'translateY(-10px) rotate(5deg)' }
},
zoom: {
'0%, 100%': { transform: 'scale(1)' },
'50%': { transform: 'scale(1.05)' }
}
},
backgroundImage: {
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
},
colors: {
primary: {
50: '#f0f9ff',
100: '#e0f2fe',
200: '#bae6fd',
300: '#7dd3fc',
400: '#38bdf8',
500: '#0ea5e9',
600: '#0284c7',
700: '#0369a1',
800: '#075985',
900: '#0c4a6e'
},
secondary: {
50: '#faf5ff',
100: '#f3e8ff',
200: '#e9d5ff',
300: '#d8b4fe',
400: '#c084fc',
500: '#a855f7',
600: '#9333ea',
700: '#7e22ce',
800: '#6b21a8',
900: '#581c87'
},
tertiary: {
50: '#fff7ed',
100: '#ffedd5',
200: '#fed7aa',
300: '#fdba74',
400: '#fb923c',
500: '#f97316',
600: '#ea580c',
700: '#c2410c',
800: '#9a3412',
900: '#7c2d12'
}
}
}
}
}
</script>
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
* {
font-family: 'Outfit', sans-serif;
}
.floating-shape {
position: absolute;
opacity: 0.7;
border-radius: 50%;
filter: blur(20px);
z-index: 0;
}
#homepage {
display: none;
}
.animate-delay-1 {
animation-delay: 0.2s;
}
.animate-delay-2 {
animation-delay: 0.4s;
}
.animate-delay-3 {
animation-delay: 0.6s;
}
.animate-delay-4 {
animation-delay: 0.8s;
}
/* Sidebar hover effect */
.sidebar-item {
position: relative;
overflow: hidden;
}
.sidebar-item::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 0;
height: 100%;
background-color: rgba(255, 255, 255, 0.1);
transition: width 0.3s ease;
z-index: -1;
}
.sidebar-item:hover::after {
width: 100%;
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: rgba(156, 163, 175, 0.5);
border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
background: rgba(156, 163, 175, 0.8);
}
</style>
<!-- Add these styles to your existing <style> tag -->
<style>
/* Mobile optimizations */
@media (max-width: 640px) {
.floating-shape {
opacity: 0.4;
filter: blur(30px);
}
#contentArea {
padding: 1rem !important;
}
}
/* Tablet optimizations */
@media (min-width: 641px) and (max-width: 1024px) {
.floating-shape {
opacity: 0.5;
filter: blur(25px);
}
}
/* Animations for mobile */
@media (prefers-reduced-motion: reduce) {
.animate-float, .animate-bob, .animate-spin-slow, .animate-zoom {
animation: none !important;
}
}
/* Responsive sidebar */
@media (max-width: 768px) {
#sidebar {
width: 240px;
}
}
/* Smoother transitions */
.content-section {
transition: opacity 0.3s ease;
}
.content-section.hidden {
display: none;
opacity: 0;
}
/* Notification animation */
@keyframes slideInUp {
from {
transform: translateY(100%);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
.notification-enter {
animation: slideInUp 0.3s forwards;
}
/* Fix for mobile view content padding */
#contentArea {
transition: margin-left 0.3s ease;
}
/* Better mobile form experience */
input, select, textarea {
font-size: 16px !important; /* Prevents iOS zoom on focus */
}
.my-custom-icon {
display: inline-block;
width: 50px;
height: 50px;
background-image: url("linkuplogo.png"); /* Replace with your icon URL */
background-size: contain;
background-repeat: no-repeat;
background-position: center;
}
</style>
</head>
<body class="bg-gray-50 dark:bg-gray-900 transition-colors duration-300">
<!-- Auth Container -->
<div id="authPage" class="min-h-screen flex items-center justify-center p-4 bg-gradient-to-br from-primary-600 via-secondary-500 to-tertiary-400 dark:from-primary-800 dark:via-secondary-700 dark:to-tertiary-600 relative overflow-hidden">
<!-- Animated Background Shapes -->
<div class="floating-shape w-64 h-64 bg-blue-400 top-10 left-10 animate-float"></div>
<div class="floating-shape w-48 h-48 bg-purple-400 bottom-20 right-10 animate-bob"></div>
<div class="floating-shape w-56 h-56 bg-orange-300 bottom-40 left-1/4 animate-float" style="animation-delay: 1s;"></div>
<div class="floating-shape w-32 h-32 bg-blue-300 top-1/4 right-1/4 animate-spin-slow"></div>
<div class="floating-shape w-72 h-72 bg-purple-300 top-1/3 left-1/3 animate-zoom"></div>
<div class="w-full max-w-md p-8 rounded-2xl shadow-2xl backdrop-blur-lg bg-white/20 dark:bg-gray-800/20 border border-white/20 dark:border-gray-700/20 animate-fade-in z-10">
<div class="text-center mb-8">
<div class="w-20 h-20 mx-auto mb-4 bg-white dark:bg-gray-700 rounded-full flex items-center justify-center shadow-lg transform hover:rotate-12 transition-all duration-500">
<!-- <i class="bi bi-mortarboard-fill text-4xl text-primary-600 dark:text-primary-400"></i> -->
<span class="my-custom-icon text-4xl text-primary-600 dark:text-primary-400"></span>
</div>
<h1 class="text-3xl font-bold text-white dark:text-white mb-2 animate-pulse-slow">LinkUp</h1>
<p class="text-gray-200 dark:text-gray-300">Your college life, simplified.</p>
</div>
<!-- Auth Tabs -->
<div class="mb-6">
<div class="flex space-x-2 mb-6">
<button onclick="switchTab('login')" class="flex-1 py-2 px-4 rounded-lg bg-white/20 dark:bg-gray-700/30 text-white hover:bg-white/30 dark:hover:bg-gray-700/50 transition-all duration-300 transform hover:-translate-y-1 focus:ring-2 focus:ring-white/50 dark:focus:ring-gray-400/50 focus:outline-none" id="loginTab">Student Login</button>
<button onclick="switchTab('admin')" class="flex-1 py-2 px-4 rounded-lg bg-white/20 dark:bg-gray-700/30 text-white hover:bg-white/30 dark:hover:bg-gray-700/50 transition-all duration-300 transform hover:-translate-y-1 focus:ring-2 focus:ring-white/50 dark:focus:ring-gray-400/50 focus:outline-none" id="adminTab">Admin Login</button>
<button onclick="switchTab('register')" class="flex-1 py-2 px-4 rounded-lg bg-white/20 dark:bg-gray-700/30 text-white hover:bg-white/30 dark:hover:bg-gray-700/50 transition-all duration-300 transform hover:-translate-y-1 focus:ring-2 focus:ring-white/50 dark:focus:ring-gray-400/50 focus:outline-none" id="registerTab">Register</button>
</div>
<!-- Login Form -->
<form id="loginForm" class="space-y-4 animate-slide-in" onsubmit="handleLogin(event)">
<div class="group">
<div class="relative">
<span class="absolute left-3 top-3 text-white/70 dark:text-gray-400 transition-all duration-300 group-focus-within:text-primary-400">
<i class="bi bi-envelope"></i>
</span>
<input type="email" id="loginEmail" placeholder="Email" class="w-full p-3 pl-10 rounded-lg bg-white/20 dark:bg-gray-700/30 text-white dark:text-gray-200 placeholder-gray-300 dark:placeholder-gray-500 outline-none border border-transparent focus:border-white/50 dark:focus:border-gray-400/50 transition-all duration-300" required>
</div>
</div>
<div class="group">
<div class="relative">
<span class="absolute left-3 top-3 text-white/70 dark:text-gray-400 transition-all duration-300 group-focus-within:text-primary-400">
<i class="bi bi-lock"></i>
</span>
<input type="password" id="loginPassword" placeholder="Password" class="w-full p-3 pl-10 rounded-lg bg-white/20 dark:bg-gray-700/30 text-white dark:text-gray-200 placeholder-gray-300 dark:placeholder-gray-500 outline-none border border-transparent focus:border-white/50 dark:focus:border-gray-400/50 transition-all duration-300" required>
</div>
</div>
<div class="text-center mt-2">
<a href="#" id="forgotPasswordLink" class="text-sm text-blue-500 hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-300">
Forgot your password?
</a>
</div>
<button type="submit" class="w-full py-3 rounded-lg bg-white dark:bg-gray-800 text-primary-600 dark:text-primary-400 font-semibold hover:bg-opacity-90 dark:hover:bg-opacity-90 transition-all duration-300 shadow-lg hover:shadow-xl transform hover:-translate-y-1">
<span class="flex items-center justify-center">
<i class="bi bi-box-arrow-in-right mr-2"></i>
Login
</span>
</button>
</form>
<!-- Admin Form -->
<form id="adminForm" class="space-y-4 hidden animate-slide-in" onsubmit="handleAdminLogin(event)">
<div class="group">
<div class="relative">
<span class="absolute left-3 top-3 text-white/70 dark:text-gray-400 transition-all duration-300 group-focus-within:text-primary-400">
<i class="bi bi-shield-lock"></i>
</span>
<input type="password" id="adminPassword" placeholder="Admin Password" class="w-full p-3 pl-10 rounded-lg bg-white/20 dark:bg-gray-700/30 text-white dark:text-gray-200 placeholder-gray-300 dark:placeholder-gray-500 outline-none border border-transparent focus:border-white/50 dark:focus:border-gray-400/50 transition-all duration-300" required>
</div>
</div>
<button type="submit" class="w-full py-3 rounded-lg bg-white dark:bg-gray-800 text-primary-600 dark:text-primary-400 font-semibold hover:bg-opacity-90 dark:hover:bg-opacity-90 transition-all duration-300 shadow-lg hover:shadow-xl transform hover:-translate-y-1">
<span class="flex items-center justify-center">
<i class="bi bi-person-check mr-2"></i>
Admin Login
</span>
</button>
</form>
<!-- Register Form -->
<form id="registerForm" class="space-y-4 hidden animate-slide-in" onsubmit="handleRegister(event)">
<div class="group">
<div class="relative">
<span class="absolute left-3 top-3 text-white/70 dark:text-gray-400 transition-all duration-300 group-focus-within:text-primary-400">
<i class="bi bi-person"></i>
</span>
<input type="text" id="registerName" placeholder="Full Name" class="w-full p-3 pl-10 rounded-lg bg-white/20 dark:bg-gray-700/30 text-white dark:text-gray-200 placeholder-gray-300 dark:placeholder-gray-500 outline-none border border-transparent focus:border-white/50 dark:focus:border-gray-400/50 transition-all duration-300" required>
</div>
</div>
<div class="group">
<div class="relative">
<span class="absolute left-3 top-3 text-white/70 dark:text-gray-400 transition-all duration-300 group-focus-within:text-primary-400">
<i class="bi bi-envelope"></i>
</span>
<input type="email" id="registerEmail" placeholder="College Email" class="w-full p-3 pl-10 rounded-lg bg-white/20 dark:bg-gray-700/30 text-white dark:text-gray-200 placeholder-gray-300 dark:placeholder-gray-500 outline-none border border-transparent focus:border-white/50 dark:focus:border-gray-400/50 transition-all duration-300" required>
</div>
</div>
<div class="group">
<div class="relative">
<span class="absolute left-3 top-3 text-white/70 dark:text-gray-400 transition-all duration-300 group-focus-within:text-primary-400">
<i class="bi bi-lock"></i>
</span>
<input type="password" id="registerPassword" placeholder="Create Password" class="w-full p-3 pl-10 rounded-lg bg-white/20 dark:bg-gray-700/30 text-white dark:text-gray-200 placeholder-gray-300 dark:placeholder-gray-500 outline-none border border-transparent focus:border-white/50 dark:focus:border-gray-400/50 transition-all duration-300" required>
</div>
</div>
<div class="group">
<div class="relative">
<span class="absolute left-3 top-3 text-white/70 dark:text-gray-400 transition-all duration-300 group-focus-within:text-primary-400">
<i class="bi bi-lock-check"></i>
</span>
<input type="password" id="confirmPassword" placeholder="Confirm Password" class="w-full p-3 pl-10 rounded-lg bg-white/20 dark:bg-gray-700/30 text-white dark:text-gray-200 placeholder-gray-300 dark:placeholder-gray-500 outline-none border border-transparent focus:border-white/50 dark:focus:border-gray-400/50 transition-all duration-300" required>
</div>
</div>
<button type="submit" class="w-full py-3 rounded-lg bg-white dark:bg-gray-800 text-primary-600 dark:text-primary-400 font-semibold hover:bg-opacity-90 dark:hover:bg-opacity-90 transition-all duration-300 shadow-lg hover:shadow-xl transform hover:-translate-y-1">
<span class="flex items-center justify-center">
<i class="bi bi-person-plus mr-2"></i>
Register
</span>
</button>
</form>
</div>
</div>
</div>
<!-- Add this HTML to your login page -->
<!-- Forgot Password Modal -->
<div id="forgotPasswordModal" class="fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center transform transition-opacity duration-300 opacity-0 pointer-events-none">
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full mx-4 overflow-hidden">
<div class="p-5 border-b border-gray-200 dark:border-gray-700 flex justify-between items-center">
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">Reset Your Password</h3>
<button onclick="closeForgotPasswordModal()" class="text-gray-400 hover:text-gray-500 dark:hover:text-gray-300">
<i class="bi bi-x-lg"></i>
</button>
</div>
<div class="p-5">
<!-- Status message for feedback -->
<div id="passwordResetStatus" class="p-4 mb-4 rounded hidden"></div>
<!-- Email Section -->
<div id="emailSection">
<label for="resetEmail" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Email Address</label>
<input type="email" id="resetEmail" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm dark:bg-gray-700 dark:text-white" placeholder="Enter your email">
</div>
<!-- Reset Code Section (hidden by default) -->
<div id="resetCodeSection" class="hidden mt-4">
<label for="resetCode" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Verification Code</label>
<input type="text" id="resetCode" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm dark:bg-gray-700 dark:text-white" placeholder="Enter code from email">
</div>
<!-- New Password Section (hidden by default) -->
<div id="newPasswordSection" class="hidden mt-4">
<div class="mb-4">
<label for="newPassword" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">New Password</label>
<input type="password" id="newPassword" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm dark:bg-gray-700 dark:text-white" placeholder="Enter new password">
</div>
<div>
<label for="confirmNewPassword" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Confirm New Password</label>
<input type="password" id="confirmNewPassword" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm dark:bg-gray-700 dark:text-white" placeholder="Confirm new password">
</div>
</div>
<!-- Buttons -->
<div class="mt-5 flex justify-end">
<button onclick="closeForgotPasswordModal()" class="px-4 py-2 mr-2 border border-gray-300 dark:border-gray-600 rounded-md text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">
Cancel
</button>
<button id="resetPasswordBtn" onclick="handleForgotPassword(event)" class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
Send Reset Link
</button>
<button id="verifyCodeBtn" onclick="verifyResetCode()" class="hidden px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
Verify Code
</button>
<button id="setNewPasswordBtn" onclick="updatePasswordWithToken()" class="hidden px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
Update Password
</button>
</div>
</div>
</div>
</div>
<!-- Homepage with Navbar -->
<div id="homepage" class="min-h-screen bg-gray-50 dark:bg-gray-900 transition-colors duration-300">
<!-- Navbar -->
<nav class="bg-gradient-to-r from-primary-600 to-secondary-600 dark:from-primary-800 dark:to-secondary-800 text-white shadow-lg sticky top-0 z-50 transition-colors duration-300">
<div class="container mx-auto px-4">
<div class="flex justify-between items-center py-4">
<div class="flex items-center space-x-4">
<div class="flex items-center space-x-2">
<!-- <i class="bi bi-mortarboard-fill text-2xl"></i> -->
<h1 class="text-xl md:text-2xl font-bold">Student Companion</h1>
</div>
<span id="welcomeMessage" class="hidden md:inline text-sm bg-white/10 py-1 px-3 rounded-full">
<i class="bi bi-person-check mr-1"></i>
Welcome, <span id="userName" class="font-medium">User</span>!
</span>
</div>
<div class="flex items-center space-x-3">
<!-- Theme Toggle Button -->
<button id="themeToggleBtn" class="p-2 rounded-full bg-white/10 hover:bg-white/20 transition-all duration-300" onclick="toggleTheme()">
<i id="themeIcon" class="bi bi-sun text-lg"></i>
</button>
<button id="logoutBtn" class="py-1 px-2 md:py-2 md:px-4 text-xs md:text-base rounded-lg bg-white/20 hover:bg-white/30 transition-all duration-300 transform hover:-translate-y-1 flex items-center space-x-1" onclick="logout()">
<i class="bi bi-box-arrow-right"></i>
<span class="hidden md:inline">Logout</span>
</button>
</div>
</div>
</div>
</nav>
<!-- Mobile Menu -->
<div id="mobileMenu" class="hidden md:hidden bg-primary-700 dark:bg-primary-900 text-white transition-colors duration-300">
<div class="container mx-auto px-4 py-2">
<button class="w-full text-left py-2 px-4 hover:bg-primary-600 dark:hover:bg-primary-800 rounded-lg transition-colors duration-300 flex items-center space-x-2" onclick="logout()">
<i class="bi bi-box-arrow-right"></i>
<span>Logout</span>
</button>
</div>
</div>
<!-- Sidebar Navigation -->
<div class="flex flex-col md:flex-row">
<!-- Sidebar -->
<div id="sidebar" class="fixed md:relative w-64 bg-gradient-to-b from-primary-800 via-primary-700 to-secondary-700 dark:from-gray-800 dark:via-gray-800 dark:to-gray-900 text-white h-screen z-40 transform -translate-x-full md:translate-x-0 transition-transform duration-300 shadow-xl overflow-auto">
<div class="p-4">
<div class="mb-6 flex items-center justify-center">
<div class="w-12 h-12 rounded-full flex items-center justify-center bg-white/10 hover:bg-white/20 transition-all duration-300 cursor-pointer animate-pulse-slow">
<span class="my-custom-icon"></span>
</div>
</div>
<h2 class="text-xl font-semibold mb-6 pb-2 border-b border-white/20 dark:border-gray-700/50 flex items-center">
<i class="bi bi-grid-fill mr-2"></i>
Features
</h2>
<ul class="space-y-2">
<li class="sidebar-item">
<a href="notice.html" class="block py-3 px-4 rounded-lg hover:bg-white/10 dark:hover:bg-gray-700/30 transition-all duration-300 flex items-center space-x-3">
<div class="w-8 h-8 rounded-lg bg-white/10 flex items-center justify-center">
<i class="bi bi-megaphone"></i>
</div>
<span>Notice Board</span>
</a>
</li>
<li class="sidebar-item">
<a href="taxi-search.html" class="block py-3 px-4 rounded-lg hover:bg-white/10 dark:hover:bg-gray-700/30 transition-all duration-300 flex items-center space-x-3">
<div class="w-8 h-8 rounded-lg bg-white/10 flex items-center justify-center">
<i class="bi bi-car-front"></i>
</div>
<span>Taxi Search</span>
</a>
</li>
<li class="sidebar-item">
<a href="study.html" class="block py-3 px-4 rounded-lg hover:bg-white/10 dark:hover:bg-gray-700/30 transition-all duration-300 flex items-center space-x-3">
<div class="w-8 h-8 rounded-lg bg-white/10 flex items-center justify-center">
<i class="bi bi-book"></i>
</div>
<span>Study Materials</span>
</a>
</li>
<li class="sidebar-item">
<a href="mail.html" class="block py-3 px-4 rounded-lg hover:bg-white/10 dark:hover:bg-gray-700/30 transition-all duration-300 flex items-center space-x-3">
<div class="w-8 h-8 rounded-lg bg-white/10 flex items-center justify-center">
<i class="bi bi-envelope"></i>
</div>
<span>Mail Formats</span>
</a>
</li>
<li class="sidebar-item">
<a href="kyp.html" class="block py-3 px-4 rounded-lg hover:bg-white/10 dark:hover:bg-gray-700/30 transition-all duration-300 flex items-center space-x-3">
<div class="w-8 h-8 rounded-lg bg-white/10 flex items-center justify-center">
<i class="bi bi-people"></i>
</div>
<span>Know Your People</span>
</a>
</li>
<li class="sidebar-item">
<a href="outings.html" class="block py-3 px-4 rounded-lg hover:bg-white/10 dark:hover:bg-gray-700/30 transition-all duration-300 flex items-center space-x-3">
<div class="w-8 h-8 rounded-lg bg-white/10 flex items-center justify-center">
<i class="bi bi-geo"></i>
</div>
<span>Outings & Trips</span>
</a>
</li>
<li class="sidebar-item">
<a href="messmenu.html" class="block py-3 px-4 rounded-lg hover:bg-white/10 dark:hover:bg-gray-700/30 transition-all duration-300 flex items-center space-x-3">
<div class="w-8 h-8 rounded-lg bg-white/10 flex items-center justify-center">
<i class="bi bi-cup-hot"></i>
</div>
<span>Mess & Canteen</span>
</a>
</li>
</ul>
</div>
<!-- Sidebar Footer -->
<div class="mt-auto p-4 border-t border-white/10 dark:border-gray-700/30">
<div class="text-xs text-white/50 text-center">
<p>© 2025 Student Companion</p>
</div>
</div>
</div>
<!-- Mobile Sidebar Toggle -->
<div class="fixed bottom-6 left-6 z-40 md:hidden">
<button onclick="toggleSidebar()" class="bg-primary-600 dark:bg-primary-700 text-white p-4 rounded-full shadow-lg hover:bg-primary-500 dark:hover:bg-primary-600 transition-all duration-300">
<i id="sidebarIcon" class="bi bi-list text-xl"></i>
</button>
</div>
<!-- Main Content -->
<div class="flex-1 p-4 md:p-8">
<div id="contentArea" class="bg-white dark:bg-gray-800 rounded-xl shadow-lg p-6 transition-all duration-300 transform hover:shadow-2xl">
<!-- Default content (Notice Board) -->
<div id="notice" class="content-section">
<h2 class="text-2xl font-bold mb-6 text-gray-800 dark:text-white border-b pb-2 border-gray-200 dark:border-gray-700 flex items-center">
<i class="bi bi-megaphone mr-2 text-primary-600 dark:text-primary-400"></i>
Please Logout And Login Again
</h2>
</div>
</div>
</div>
</div>
</div>
<script>
// ==== THEME FUNCTIONALITY ====
function toggleTheme() {
// Check if currently in dark mode
const isDarkMode = document.documentElement.classList.contains('dark');
// Toggle the dark class on the html element
document.documentElement.classList.toggle('dark');
// Update the icon based on current theme
const themeIcon = document.getElementById('themeIcon');
if (isDarkMode) {
// Switching to light mode
themeIcon.classList.remove('bi-moon');
themeIcon.classList.add('bi-sun');
} else {
// Switching to dark mode
themeIcon.classList.remove('bi-sun');
themeIcon.classList.add('bi-moon');
}
// Save preference to localStorage
localStorage.setItem('theme', isDarkMode ? 'light' : 'dark');
}
// Function to initialize theme based on saved preference
function initializeTheme() {
// Check for saved theme preference or use system preference
const savedTheme = localStorage.getItem('theme');
if (savedTheme) {
// Apply saved preference
if (savedTheme === 'dark') {
document.documentElement.classList.add('dark');
document.getElementById('themeIcon').classList.remove('bi-sun');
document.getElementById('themeIcon').classList.add('bi-moon');
} else {
document.documentElement.classList.remove('dark');
document.getElementById('themeIcon').classList.remove('bi-moon');
document.getElementById('themeIcon').classList.add('bi-sun');
}
} else {
// Apply system preference
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.classList.add('dark');
document.getElementById('themeIcon').classList.remove('bi-sun');
document.getElementById('themeIcon').classList.add('bi-moon');
}
}
}
// ==== RESPONSIVE FUNCTIONALITY ====
function setupResponsiveness() {
// Adjust UI based on screen size
const handleResize = () => {
const width = window.innerWidth;
const sidebar = document.getElementById('sidebar');
const contentArea = document.getElementById('contentArea');
// Sidebar handling based on screen size
if (width < 768) { // Mobile view
sidebar.classList.add('-translate-x-full');
sidebar.classList.add('fixed');
sidebar.classList.remove('relative');
// Adjust content area
contentArea.classList.remove('ml-64');
} else { // Desktop view
sidebar.classList.remove('-translate-x-full');
sidebar.classList.remove('fixed');
sidebar.classList.add('relative');
// Reset content area
contentArea.classList.add('ml-64');
}
};
// Call once on load
handleResize();
// Add event listener for window resize
window.addEventListener('resize', handleResize);
}
// Toggle mobile sidebar
function toggleSidebar() {
const sidebar = document.getElementById('sidebar');
const sidebarIcon = document.getElementById('sidebarIcon');
sidebar.classList.toggle('-translate-x-full');
// Update icon based on sidebar state
if (sidebar.classList.contains('-translate-x-full')) {
sidebarIcon.classList.remove('bi-x-lg');
sidebarIcon.classList.add('bi-list');
} else {
sidebarIcon.classList.remove('bi-list');
sidebarIcon.classList.add('bi-x-lg');
}
}
// ==== AUTH FUNCTIONALITY ====
async function handleLogin(e) {
e.preventDefault();
const email = document.getElementById('loginEmail').value;
const password = document.getElementById('loginPassword').value;
try {
// First, authenticate the user
const { data, error } = await window.supabaseClient.auth.signInWithPassword({
email: email,
password: password,
});
if (error) {
// Better error handling for email confirmation
if (error.message.includes('Email not confirmed')) {
showNotification('Please confirm your email address before logging in.', 'warning');
return;
}
throw error;
}
// User authenticated successfully
console.log("User authenticated:", data.user.id);
// Get user profile from the profiles table
const { data: profiles, error: profileError } = await window.supabaseClient
.from('profiles')
.select('name')
.eq('id', data.user.id);
if (profileError) throw profileError;
// Check if we got any profiles back
if (!profiles || profiles.length === 0) {
console.log("No profile found, creating one");
// No profile found, create one
const { error: insertError } = await window.supabaseClient
.from('profiles')
.insert([
{
id: data.user.id,
name: email.split('@')[0], // Default name from email
email: email
}
]);
if (insertError) throw insertError;
// Use email username as default name
showHomepage(email.split('@')[0]);
} else {
// Use the first profile found
console.log("Profile found:", profiles[0]);
showHomepage(profiles[0].name);
}
showNotification('Login successful!', 'success');
} catch (error) {
showNotification('Error logging in: ' + error.message, 'error');
console.error("Login error details:", error);
}
}
async function handleAdminLogin(e) {
e.preventDefault();
const password = document.getElementById('adminPassword').value;
try {
// For admin login, you could use a special admin email or check roles
const { data, error } = await window.supabaseClient.auth.signInWithPassword({
email: 'hetchavadiya@gmail.com', // Replace with your admin email
password: password,
});
if (error) throw error;
// Check if user has admin role
const { data: profile, error: profileError } = await window.supabaseClient
.from('profiles')
.select('is_admin')
.eq('id', data.user.id)
.single();
if (profileError) throw profileError;
if (!profile.is_admin) {
throw new Error('You do not have admin privileges');
}
// Admin login successful
showHomepage('Admin');
showNotification('Admin login successful!', 'success');
} catch (error) {
showNotification('Invalid admin credentials: ' + error.message, 'error');
}
}
async function handleRegister(e) {
e.preventDefault();
const name = document.getElementById('registerName').value;
const email = document.getElementById('registerEmail').value;
const password = document.getElementById('registerPassword').value;
const confirmPassword = document.getElementById('confirmPassword').value;
// Form validation
if (!name || !email || !password || !confirmPassword) {
showNotification('Please fill in all fields', 'warning');
return;
}
// Check if passwords match
if (password !== confirmPassword) {
showNotification('Passwords do not match', 'warning');
return;
}
// Check if username is not "admin" or "Admin"
if (name.toLowerCase() === "admin") {
showNotification('Username cannot be "admin"', 'warning');
return;
}
try {
// Register user in Supabase Auth
const { data, error } = await window.supabaseClient.auth.signUp({
email: email,
password: password,
options: {
emailRedirectTo: window.location.origin,
data: {
name: name
}
}
});
if (error) throw error;
// Add user profile in profiles table
const { error: profileError } = await window.supabaseClient
.from('profiles')
.insert([
{ id: data.user.id, name: name, email: email }
]);
if (profileError) throw profileError;
// Check if email confirmation is needed
if (data.user && !data.user.confirmed_at) {
showNotification('Registration successful! Please check your email to confirm your account before logging in.', 'success');
} else {
showNotification('Registration successful! You can now log in.', 'success');
}
switchTab('login');
} catch (error) {
showNotification('Error registering: ' + error.message, 'error');
console.error('Detailed error:', error);
}
}
// ==== NAVIGATION FUNCTIONALITY ====
function loadContent(page) {
// Hide all content sections
document.querySelectorAll('.content-section').forEach(section => {
section.classList.add('hidden');
});
// Show selected content section
const selectedContent = document.getElementById(page);
if (selectedContent) {
selectedContent.classList.remove('hidden');
}
// Update URL without reloading
history.pushState(null, null, `?page=${page}`);
// On mobile, close sidebar after navigation
if (window.innerWidth < 768) {
const sidebar = document.getElementById('sidebar');
sidebar.classList.add('-translate-x-full');
// Update sidebar toggle icon
const sidebarIcon = document.getElementById('sidebarIcon');
sidebarIcon.classList.remove('bi-x-lg');
sidebarIcon.classList.add('bi-list');
}
}
// ==== UI HELPERS ====
function showNotification(message, type = 'info') {
// Create notification element
const notification = document.createElement('div');
notification.className = `fixed bottom-4 right-4 px-6 py-3 rounded-lg shadow-lg transform transition-all duration-500 text-white z-50`;
// Set background color based on type
switch(type) {
case 'success':
notification.classList.add('bg-green-500');
break;
case 'error':
notification.classList.add('bg-red-500');
break;
case 'warning':
notification.classList.add('bg-yellow-500');
break;
default:
notification.classList.add('bg-blue-500');
}
// Add content
notification.innerHTML = `
<div class="flex items-center">
<i class="bi ${type === 'success' ? 'bi-check-circle' :
type === 'error' ? 'bi-x-circle' :
type === 'warning' ? 'bi-exclamation-triangle' :
'bi-info-circle'} mr-2"></i>
<span>${message}</span>
</div>
`;
// Add to DOM
document.body.appendChild(notification);
// Animate in
setTimeout(() => {
notification.classList.add('translate-y-0');
notification.classList.remove('translate-y-12');
}, 10);
// Remove after 3 seconds
setTimeout(() => {
notification.classList.add('opacity-0');
setTimeout(() => {
document.body.removeChild(notification);
}, 300);
}, 3000);
}
function switchTab(tab) {
const forms = {
login: document.getElementById('loginForm'),
admin: document.getElementById('adminForm'),
register: document.getElementById('registerForm')
};
// Hide all forms with animation
Object.values(forms).forEach(form => {
form.classList.add('hidden');
form.classList.remove('animate-slide-in');
});
// Show selected form with animation
forms[tab].classList.remove('hidden');
setTimeout(() => {
forms[tab].classList.add('animate-slide-in');
}, 10);
// Update active tab styling
document.querySelectorAll('#loginTab, #adminTab, #registerTab').forEach(btn => {
btn.classList.remove('bg-white/30', 'dark:bg-gray-700/50');
btn.classList.add('bg-white/20', 'dark:bg-gray-700/30');
});
document.getElementById(`${tab}Tab`).classList.remove('bg-white/20', 'dark:bg-gray-700/30');
document.getElementById(`${tab}Tab`).classList.add('bg-white/30', 'dark:bg-gray-700/50');
}
function showHomepage(userName) {
const isRecoveryFlow = window.location.hash.includes('type=recovery');
const inPasswordResetFlow = sessionStorage.getItem('inPasswordResetFlow') === 'true';
// Hide auth page with animation
const authPage = document.getElementById('authPage');
authPage.classList.add('opacity-0');
setTimeout(() => {
// Hide auth page
authPage.style.display = 'none';
// Show homepage
const homepage = document.getElementById('homepage');
homepage.style.display = 'block';
homepage.classList.add('animate-fade-in');
// Set welcome message
document.getElementById('userName').textContent = userName;
document.getElementById('welcomeMessage').classList.remove('hidden');
// Setup responsive behavior
setupResponsiveness();
// Store user info in sessionStorage
sessionStorage.setItem('currentUserData', JSON.stringify({
name: userName,
email: document.getElementById('loginEmail')?.value || 'admin@example.com'
}));
// Only redirect if NOT in recovery flow and NOT in password reset flow
if (!isRecoveryFlow && !inPasswordResetFlow) {
window.location.href = 'notice.html';
} else {
console.log('Skipping redirect due to recovery/password reset flow');
}
}, 300);
}
// ==== FORGOT PASSWORD FUNCTIONALITY ====
function showForgotPasswordModal() {
const modal = document.getElementById('forgotPasswordModal');
// Make modal visible
modal.classList.remove('opacity-0', 'pointer-events-none');
document.getElementById('resetEmail').focus();
// Reset the form state
document.getElementById('resetCodeSection').classList.add('hidden');
document.getElementById('newPasswordSection').classList.add('hidden');
document.getElementById('passwordResetStatus').classList.add('hidden');
document.getElementById('resetPasswordBtn').classList.remove('hidden');
document.getElementById('verifyCodeBtn').classList.add('hidden');