-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.jsx
More file actions
1086 lines (1001 loc) Β· 30.3 KB
/
Copy pathApp.jsx
File metadata and controls
1086 lines (1001 loc) Β· 30.3 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
import React, { useState, useEffect } from 'react';
// Auth Context for managing user authentication
const AuthContext = React.createContext();
const AuthProvider = ({ children }) => {
const [currentUser, setCurrentUser] = useState(null);
const [loading, setLoading] = useState(true);
const [token, setToken] = useState(localStorage.getItem('token'));
useEffect(() => {
if (token) {
checkAuth();
} else {
setLoading(false);
}
}, [token]);
const checkAuth = async () => {
try {
const response = await fetch('http://localhost:5000/api/auth/me', {
headers: {
'Authorization': `Bearer ${token}`
}
});
if (response.ok) {
const data = await response.json();
setCurrentUser(data.user);
} else {
logout();
}
} catch (error) {
console.error('Auth check failed:', error);
logout();
} finally {
setLoading(false);
}
};
const login = async (phone, password) => {
try {
const response = await fetch('http://localhost:5000/api/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ phone, password })
});
const data = await response.json();
if (response.ok) {
localStorage.setItem('token', data.token);
setToken(data.token);
setCurrentUser(data.user);
return { success: true, message: data.message };
} else {
return { success: false, message: data.message };
}
} catch (error) {
return { success: false, message: 'Login failed. Please try again.' };
}
};
const register = async (name, phone, password) => {
try {
const response = await fetch('http://localhost:5000/api/auth/register', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ name, phone, password })
});
const data = await response.json();
if (response.ok) {
localStorage.setItem('token', data.token);
setToken(data.token);
setCurrentUser(data.user);
return { success: true, message: data.message };
} else {
return { success: false, message: data.message };
}
} catch (error) {
return { success: false, message: 'Registration failed. Please try again.' };
}
};
const logout = () => {
localStorage.removeItem('token');
setToken(null);
setCurrentUser(null);
};
const value = {
currentUser,
login,
register,
logout,
loading
};
return (
<AuthContext.Provider value={value}>
{!loading && children}
</AuthContext.Provider>
);
};
const useAuth = () => {
return React.useContext(AuthContext);
};
// Auth Form Component
const AuthForm = () => {
const [isLogin, setIsLogin] = useState(true);
const [formData, setFormData] = useState({
name: '',
phone: '',
password: ''
});
const [message, setMessage] = useState('');
const [loading, setLoading] = useState(false);
const { login, register } = useAuth();
const handleChange = (e) => {
setFormData({
...formData,
[e.target.name]: e.target.value
});
};
const handleSubmit = async (e) => {
e.preventDefault();
setLoading(true);
setMessage('');
try {
let result;
if (isLogin) {
result = await login(formData.phone, formData.password);
} else {
result = await register(formData.name, formData.phone, formData.password);
}
if (result.success) {
setMessage(result.message);
} else {
setMessage(result.message);
}
} catch (error) {
setMessage('An error occurred. Please try again.');
} finally {
setLoading(false);
}
};
const toggleMode = () => {
setIsLogin(!isLogin);
setMessage('');
setFormData({ name: '', phone: '', password: '' });
};
const formStyle = {
backgroundColor: '#1f2937',
padding: '30px',
borderRadius: '12px',
border: '2px solid #ec4899',
maxWidth: '400px',
margin: '50px auto'
};
const inputStyle = {
width: '100%',
padding: '12px',
margin: '8px 0',
backgroundColor: '#374151',
border: '1px solid #4b5563',
borderRadius: '8px',
color: 'white',
fontSize: '16px'
};
const buttonStyle = {
width: '100%',
padding: '12px',
backgroundColor: '#ec4899',
color: 'white',
border: 'none',
borderRadius: '8px',
fontSize: '16px',
fontWeight: 'bold',
cursor: 'pointer',
marginTop: '10px'
};
return (
<div style={formStyle}>
<h2 style={{ color: '#ec4899', textAlign: 'center', marginBottom: '20px' }}>
{isLogin ? 'Login to FemSecure' : 'Create Account'}
</h2>
{message && (
<div style={{
padding: '10px',
backgroundColor: message.includes('success') ? '#15803d' : '#b91c1c',
borderRadius: '8px',
marginBottom: '15px',
textAlign: 'center'
}}>
{message}
</div>
)}
<form onSubmit={handleSubmit}>
{!isLogin && (
<input
type="text"
name="name"
placeholder="Full Name"
value={formData.name}
onChange={handleChange}
style={inputStyle}
required
/>
)}
<input
type="tel"
name="phone"
placeholder="Phone Number (e.g., +1234567890)"
value={formData.phone}
onChange={handleChange}
style={inputStyle}
required
/>
<input
type="password"
name="password"
placeholder="Password"
value={formData.password}
onChange={handleChange}
style={inputStyle}
required
minLength="6"
/>
<button
type="submit"
style={buttonStyle}
disabled={loading}
>
{loading ? 'Please wait...' : (isLogin ? 'Login' : 'Sign Up')}
</button>
</form>
<div style={{ textAlign: 'center', marginTop: '15px' }}>
<button
onClick={toggleMode}
style={{
background: 'none',
border: 'none',
color: '#ec4899',
cursor: 'pointer',
textDecoration: 'underline'
}}
>
{isLogin ? "Don't have an account? Sign up" : "Already have an account? Login"}
</button>
</div>
</div>
);
};
// API functions
const apiRequest = async (endpoint, options = {}) => {
const token = localStorage.getItem('token');
const response = await fetch(`http://localhost:5000/api${endpoint}`, {
headers: {
'Content-Type': 'application/json',
'Authorization': token ? `Bearer ${token}` : '',
...options.headers,
},
...options,
});
if (!response.ok) {
throw new Error(`API error: ${response.status}`);
}
return response.json();
};
const contactsAPI = {
getAll: () => apiRequest('/contacts'),
create: (contactData) => apiRequest('/contacts', { method: 'POST', body: JSON.stringify(contactData) }),
delete: (id) => apiRequest(`/contacts/${id}`, { method: 'DELETE' }),
};
const reportsAPI = {
getAll: () => apiRequest('/reports'),
create: (reportData) => apiRequest('/reports', { method: 'POST', body: JSON.stringify(reportData) }),
delete: (id) => apiRequest(`/reports/${id}`, { method: 'DELETE' }),
};
const profileAPI = {
updateLocation: (locationData) => apiRequest('/profile/location', { method: 'PUT', body: JSON.stringify(locationData) }),
};
// Main App Component
const MainApp = () => {
const { currentUser, logout } = useAuth();
const [location, setLocation] = useState('Click to get location');
const [safetyStatus, setSafetyStatus] = useState('Loading safety status...');
const [timerActive, setTimerActive] = useState(false);
const [timeRemaining, setTimeRemaining] = useState(0);
const [currentView, setCurrentView] = useState('home');
const [contacts, setContacts] = useState([]);
const [reports, setReports] = useState([]);
const [modal, setModal] = useState({ show: false, title: '', message: '' });
const [newContact, setNewContact] = useState({ name: '', phone: '' });
const [newReport, setNewReport] = useState({ type: 'Harassment', location: '' });
// Load data from backend when component mounts
useEffect(() => {
if (currentUser) {
loadContacts();
loadReports();
}
}, [currentUser]);
// Load contacts from backend
const loadContacts = async () => {
try {
const data = await contactsAPI.getAll();
setContacts(data);
} catch (error) {
console.error('Error loading contacts:', error);
setModal({
show: true,
title: 'Error',
message: 'Failed to load contacts. Please try again.'
});
}
};
// Load reports from backend
const loadReports = async () => {
try {
const data = await reportsAPI.getAll();
setReports(data);
} catch (error) {
console.error('Error loading reports:', error);
setModal({
show: true,
title: 'Error',
message: 'Failed to load reports. Please try again.'
});
}
};
// Get user location
const getLocation = () => {
setLocation('Getting location...');
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
async (position) => {
const { latitude, longitude } = position.coords;
const locationText = `Lat: ${latitude.toFixed(4)}, Lon: ${longitude.toFixed(4)}`;
setLocation(locationText);
updateSafetyStatus(latitude, longitude);
// Save location to backend
try {
await profileAPI.updateLocation({ latitude, longitude });
} catch (error) {
console.error('Error saving location:', error);
}
},
(error) => {
setLocation('Location access denied');
setSafetyStatus('β οΈ Unable to determine safety status');
}
);
} else {
setLocation('Geolocation not supported');
}
};
// Simulate safety status based on location
const updateSafetyStatus = (lat, lon) => {
let status = 'π’ Area is SAFE';
let color = '#15803d';
if ((lat > 30 && lat < 33) && (lon > 76 && lon < 80)) {
status = 'π‘ MODERATE RISK - Be cautious';
color = '#ca8a04';
} else if (lat < 25 || lat > 35) {
status = 'π΄ HIGH RISK - Take immediate action';
color = '#b91c1c';
}
setSafetyStatus(status);
};
// SOS Emergency Function
const handleSOS = () => {
setModal({
show: true,
title: 'π¨ EMERGENCY ALERT SENT',
message: `Emergency signal sent from your location: ${location}. Your ${contacts.length} emergency contacts have been notified. Police and emergency services alerted.`
});
};
// Check-in Timer Functions
const startTimer = (minutes) => {
setTimerActive(true);
setTimeRemaining(minutes * 60);
const timer = setInterval(() => {
setTimeRemaining(prev => {
if (prev <= 1) {
clearInterval(timer);
setTimerActive(false);
handleTimerExpired();
return 0;
}
return prev - 1;
});
}, 1000);
};
const handleTimerExpired = () => {
setModal({
show: true,
title: 'β° CHECK-IN MISSED',
message: `You missed your safety check-in! Your ${contacts.length} emergency contacts have been notified of your last known location: ${location}`
});
};
const checkIn = () => {
setTimerActive(false);
setModal({
show: true,
title: 'β
SAFE CHECK-IN',
message: 'Thank you for checking in! Your safety has been confirmed.'
});
};
// Contact Management with Backend
const addContact = async (e) => {
e.preventDefault();
try {
await contactsAPI.create(newContact);
setNewContact({ name: '', phone: '' });
loadContacts();
setModal({
show: true,
title: 'β
CONTACT ADDED',
message: `${newContact.name} has been added to your emergency contacts.`
});
} catch (error) {
setModal({
show: true,
title: 'Error',
message: 'Failed to add contact. Please try again.'
});
}
};
const deleteContact = async (id) => {
try {
await contactsAPI.delete(id);
loadContacts();
} catch (error) {
setModal({
show: true,
title: 'Error',
message: 'Failed to delete contact. Please try again.'
});
}
};
// Report Management with Backend
const addReport = async (e) => {
e.preventDefault();
try {
await reportsAPI.create(newReport);
setNewReport({ type: 'Harassment', location: '' });
loadReports();
setModal({
show: true,
title: 'β
REPORT SUBMITTED',
message: 'Your safety report has been recorded anonymously.'
});
} catch (error) {
setModal({
show: true,
title: 'Error',
message: 'Failed to submit report. Please try again.'
});
}
};
const deleteReport = async (id) => {
try {
await reportsAPI.delete(id);
loadReports();
} catch (error) {
setModal({
show: true,
title: 'Error',
message: 'Failed to delete report. Please try again.'
});
}
};
// Modal functions
const closeModal = () => {
setModal({ show: false, title: '', message: '' });
};
// Format time for timer display
const formatTime = (seconds) => {
const mins = Math.floor(seconds / 60);
const secs = seconds % 60;
return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
};
// Base styles
const appStyle = {
backgroundColor: '#111827',
minHeight: '100vh',
color: 'white',
fontFamily: 'Arial, sans-serif',
padding: '20px',
paddingBottom: '80px'
};
const headerStyle = {
backgroundColor: '#db2777',
color: 'white',
padding: '16px',
textAlign: 'center',
fontSize: '20px',
fontWeight: 'bold',
borderRadius: '10px',
marginBottom: '20px',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center'
};
const buttonStyle = {
backgroundColor: '#b91c1c',
color: 'white',
padding: '20px',
borderRadius: '15px',
border: 'none',
fontSize: '24px',
fontWeight: 'bold',
width: '100%',
marginBottom: '20px',
cursor: 'pointer'
};
const cardStyle = {
backgroundColor: '#1f2937',
padding: '20px',
borderRadius: '12px',
border: '2px solid #ec4899',
marginBottom: '20px'
};
const navButtonStyle = (isActive) => ({
color: isActive ? '#ec4899' : '#9ca3af',
fontWeight: isActive ? 'bold' : 'normal',
background: 'none',
border: 'none',
cursor: 'pointer',
fontSize: '14px'
});
// Render different views
const renderHomeView = () => (
<>
{/* SOS Button */}
<button style={buttonStyle} onClick={handleSOS}>
π¨ EMERGENCY SOS
</button>
{/* Location Card */}
<div style={cardStyle}>
<h2 style={{color: '#ec4899', marginBottom: '10px'}}>π Your Location</h2>
<button
onClick={getLocation}
style={{
backgroundColor: '#374151',
color: 'white',
padding: '10px',
borderRadius: '8px',
border: 'none',
width: '100%',
cursor: 'pointer',
marginBottom: '10px'
}}
>
{location}
</button>
<div style={{
backgroundColor: '#15803d',
padding: '10px',
borderRadius: '8px',
textAlign: 'center',
fontWeight: 'bold'
}}>
{safetyStatus}
</div>
</div>
{/* Check-in Timer */}
<div style={cardStyle}>
<h2 style={{color: '#ec4899', marginBottom: '10px'}}>β° Safety Check-in</h2>
{timerActive ? (
<div style={{textAlign: 'center'}}>
<div style={{fontSize: '32px', fontWeight: 'bold', margin: '10px 0'}}>
{formatTime(timeRemaining)}
</div>
<button
onClick={checkIn}
style={{
backgroundColor: '#15803d',
color: 'white',
padding: '10px 20px',
borderRadius: '8px',
border: 'none',
cursor: 'pointer'
}}
>
I'm Safe β
</button>
</div>
) : (
<div style={{display: 'flex', gap: '10px'}}>
<button
onClick={() => startTimer(5)}
style={{
backgroundColor: '#374151',
color: 'white',
padding: '10px',
borderRadius: '8px',
border: 'none',
flex: 1,
cursor: 'pointer'
}}
>
5 min
</button>
<button
onClick={() => startTimer(15)}
style={{
backgroundColor: '#374151',
color: 'white',
padding: '10px',
borderRadius: '8px',
border: 'none',
flex: 1,
cursor: 'pointer'
}}
>
15 min
</button>
<button
onClick={() => startTimer(30)}
style={{
backgroundColor: '#374151',
color: 'white',
padding: '10px',
borderRadius: '8px',
border: 'none',
flex: 1,
cursor: 'pointer'
}}
>
30 min
</button>
</div>
)}
</div>
{/* Quick Stats */}
<div style={cardStyle}>
<h2 style={{color: '#ec4899', marginBottom: '15px'}}>π Your Safety Dashboard</h2>
<div style={{display: 'flex', justifyContent: 'space-around', textAlign: 'center'}}>
<div>
<div style={{fontSize: '24px', fontWeight: 'bold', color: '#ec4899'}}>{contacts.length}</div>
<div>Emergency Contacts</div>
</div>
<div>
<div style={{fontSize: '24px', fontWeight: 'bold', color: '#ec4899'}}>{reports.length}</div>
<div>Safety Reports</div>
</div>
</div>
</div>
</>
);
const renderContactsView = () => (
<div>
<div style={cardStyle}>
<h2 style={{color: '#ec4899', marginBottom: '15px'}}>π Add Emergency Contact</h2>
<form onSubmit={addContact}>
<input
type="text"
placeholder="Contact Name"
value={newContact.name}
onChange={(e) => setNewContact({...newContact, name: e.target.value})}
style={{
width: '100%',
padding: '10px',
marginBottom: '10px',
backgroundColor: '#374151',
border: '1px solid #4b5563',
borderRadius: '8px',
color: 'white'
}}
required
/>
<input
type="tel"
placeholder="Phone Number (e.g., +1234567890)"
value={newContact.phone}
onChange={(e) => setNewContact({...newContact, phone: e.target.value})}
style={{
width: '100%',
padding: '10px',
marginBottom: '10px',
backgroundColor: '#374151',
border: '1px solid #4b5563',
borderRadius: '8px',
color: 'white'
}}
required
/>
<button type="submit" style={{
width: '100%',
padding: '12px',
backgroundColor: '#ec4899',
color: 'white',
border: 'none',
borderRadius: '8px',
cursor: 'pointer'
}}>
+ Add Contact
</button>
</form>
</div>
<div style={cardStyle}>
<h2 style={{color: '#ec4899', marginBottom: '15px'}}>Your Emergency Contacts ({contacts.length})</h2>
{contacts.length === 0 ? (
<p style={{textAlign: 'center', color: '#9ca3af'}}>No emergency contacts added yet.</p>
) : (
contacts.map(contact => (
<div key={contact._id} style={{
backgroundColor: '#374151',
padding: '15px',
borderRadius: '8px',
marginBottom: '10px',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center'
}}>
<div>
<div style={{fontWeight: 'bold'}}>{contact.name}</div>
<div style={{color: '#ec4899', fontSize: '14px'}}>{contact.phone}</div>
</div>
<button
onClick={() => deleteContact(contact._id)}
style={{
backgroundColor: '#b91c1c',
color: 'white',
border: 'none',
borderRadius: '5px',
padding: '5px 10px',
cursor: 'pointer'
}}
>
Delete
</button>
</div>
))
)}
</div>
</div>
);
const renderReportsView = () => (
<div>
<div style={cardStyle}>
<h2 style={{color: '#ec4899', marginBottom: '15px'}}>π Submit Safety Report</h2>
<form onSubmit={addReport}>
<select
value={newReport.type}
onChange={(e) => setNewReport({...newReport, type: e.target.value})}
style={{
width: '100%',
padding: '10px',
marginBottom: '10px',
backgroundColor: '#374151',
border: '1px solid #4b5563',
borderRadius: '8px',
color: 'white'
}}
>
<option value="Harassment">Verbal Harassment</option>
<option value="Poor Lighting">Poor Lighting / Danger Spot</option>
<option value="Suspicious">Suspicious Activity</option>
<option value="Theft">Attempted Theft</option>
<option value="Other">Other</option>
</select>
<input
type="text"
placeholder="Location details (optional)"
value={newReport.location}
onChange={(e) => setNewReport({...newReport, location: e.target.value})}
style={{
width: '100%',
padding: '10px',
marginBottom: '10px',
backgroundColor: '#374151',
border: '1px solid #4b5563',
borderRadius: '8px',
color: 'white'
}}
/>
<button type="submit" style={{
width: '100%',
padding: '12px',
backgroundColor: '#b91c1c',
color: 'white',
border: 'none',
borderRadius: '8px',
cursor: 'pointer'
}}>
+ Submit Report
</button>
</form>
</div>
<div style={cardStyle}>
<h2 style={{color: '#ec4899', marginBottom: '15px'}}>Your Safety Reports ({reports.length})</h2>
{reports.length === 0 ? (
<p style={{textAlign: 'center', color: '#9ca3af'}}>No safety reports submitted yet.</p>
) : (
reports.map(report => (
<div key={report._id} style={{
backgroundColor: '#374151',
padding: '15px',
borderRadius: '8px',
marginBottom: '10px'
}}>
<div style={{display: 'flex', justifyContent: 'space-between', alignItems: 'start'}}>
<div style={{fontWeight: 'bold', color: '#ec4899'}}>{report.type}</div>
<button
onClick={() => deleteReport(report._id)}
style={{
backgroundColor: 'transparent',
color: '#9ca3af',
border: 'none',
cursor: 'pointer'
}}
>
β
</button>
</div>
<div style={{fontSize: '14px', marginTop: '5px'}}>π {report.location || 'Not specified'}</div>
<div style={{fontSize: '12px', color: '#9ca3af', marginTop: '5px'}}>
π {new Date(report.createdAt).toLocaleString()}
</div>
</div>
))
)}
</div>
</div>
);
const renderResourcesView = () => (
<div style={cardStyle}>
<h2 style={{color: '#ec4899', marginBottom: '15px'}}>π Safety Resources</h2>
<div style={{lineHeight: '1.6'}}>
<div style={{marginBottom: '15px'}}>
<h3 style={{color: '#ec4899'}}>π¨ Emergency Numbers</h3>
<ul style={{paddingLeft: '20px', color: '#d1d5db'}}>
<li>Police: 100</li>
<li>Ambulance: 108</li>
<li>Women Helpline: 1091</li>
</ul>
</div>
<div style={{marginBottom: '15px'}}>
<h3 style={{color: '#ec4899'}}>π‘ Safety Tips</h3>
<ul style={{paddingLeft: '20px', color: '#d1d5db'}}>
<li>Always share your live location with trusted contacts</li>
<li>Use well-lit, populated routes when walking alone</li>
<li>Keep emergency contacts easily accessible</li>
<li>Trust your instincts - if something feels wrong, leave</li>
</ul>
</div>
</div>
</div>
);
const renderProfileView = () => (
<div style={cardStyle}>
<h2 style={{color: '#ec4899', marginBottom: '15px', textAlign: 'center'}}>π€ Your Profile</h2>
<div style={{textAlign: 'center', marginBottom: '20px'}}>
<div style={{
width: '80px',
height: '80px',
backgroundColor: '#ec4899',
borderRadius: '50%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
fontSize: '24px',
fontWeight: 'bold',
margin: '0 auto 15px'
}}>
{currentUser?.name?.charAt(0) || 'U'}
</div>
<h3 style={{marginBottom: '5px'}}>{currentUser?.name || 'User'}</h3>
<p style={{color: '#9ca3af'}}>{currentUser?.phone || 'No phone'}</p>
</div>
<div style={{
backgroundColor: '#374151',
padding: '15px',
borderRadius: '8px',
marginBottom: '15px',
textAlign: 'center'
}}>
<strong>Account Status:</strong> Active β
</div>
<button
onClick={logout}
style={{
width: '100%',
padding: '12px',
backgroundColor: '#b91c1c',
color: 'white',
border: 'none',
borderRadius: '8px',
cursor: 'pointer',
fontSize: '16px'
}}
>
Logout
</button>
</div>
);
return (
<div style={appStyle}>
{/* Header */}
<div style={headerStyle}>
<span>*FemSecure*</span>
<span style={{fontSize: '14px'}}>Hello, {currentUser?.name}</span>
</div>
{/* Main Content */}
{currentView === 'home' && renderHomeView()}
{currentView === 'contacts' && renderContactsView()}
{currentView === 'reports' && renderReportsView()}
{currentView === 'resources' && renderResourcesView()}
{currentView === 'profile' && renderProfileView()}
{/* Modal */}
{modal.show && (
<div style={{
position: 'fixed',
top: 0,
left: 0,
right: 0,
bottom: 0,
backgroundColor: 'rgba(0,0,0,0.7)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
zIndex: 1000
}}>
<div style={{
backgroundColor: '#1f2937',
padding: '20px',
borderRadius: '12px',