diff --git a/src/Pages/SOS.jsx b/src/Pages/SOS.jsx index 6eaa825..f505788 100644 --- a/src/Pages/SOS.jsx +++ b/src/Pages/SOS.jsx @@ -10,9 +10,7 @@ const SOSPage = () => { const [copiedNumber, setCopiedNumber] = useState(''); useEffect(() => { - const timer = setInterval(() => { - setCurrentTime(new Date()); - }, 1000); + const timer = setInterval(() => setCurrentTime(new Date()), 1000); return () => clearInterval(timer); }, []); @@ -27,20 +25,16 @@ const SOSPage = () => { }); setLocationError(''); }, - (error) => { - setLocationError('Unable to retrieve location. Please enable location services.'); - } + () => setLocationError('Unable to retrieve location. Please enable location services.') ); } else { setLocationError('Geolocation is not supported by this browser.'); } }; - useEffect(() => { - getLocation(); - }, []); + useEffect(() => { getLocation(); }, []); - const emergencyNumbers = [ + const emergencyNumbers = [ { name: 'Police Emergency', number: '100', icon: Shield, color: 'from-blue-500 to-blue-700', description: 'Police assistance and law enforcement' }, { name: 'Fire Emergency', number: '101', icon: AlertTriangle, color: 'from-red-500 to-red-700', description: 'Fire department and rescue services' }, { name: 'Medical Emergency / Ambulance', number: '108', icon: Heart, color: 'from-emerald-500 to-emerald-700', description: 'Ambulance and medical emergency' }, @@ -54,33 +48,27 @@ const SOSPage = () => { { name: 'Mental Health Helpline', number: '1800-599-0019', icon: Heart, color: 'from-rose-500 to-rose-700', description: 'Support for mental health and suicide prevention (KIRAN Helpline)' }, ]; - const navigate = useNavigate(); -const quickActions = [ - { name: 'Send Location to Emergency Contact', action: () => shareLocation(), icon: Send, color: 'from-indigo-500 to-indigo-700' }, - { name: 'Medical Information', action: () => navigate('/medical-info'), icon: Heart, color: 'from-rose-500 to-rose-700' }, - { name: 'Safe Word Alert', action: () => navigate('/safe-word'), icon: Shield, color: 'from-amber-500 to-amber-700' }, - { name: 'Record Audio', action: () => navigate('/record-audio'), icon: Zap, color: 'from-violet-500 to-violet-700' } - -]; - + const quickActions = [ + { name: 'Send Location to Emergency Contact', action: () => shareLocation(), icon: Send, color: 'from-indigo-500 to-indigo-700' }, + { name: 'Medical Information', action: () => navigate('/medical-info'), icon: Heart, color: 'from-rose-500 to-rose-700' }, + { name: 'Safe Word Alert', action: () => navigate('/safe-word'), icon: Shield, color: 'from-amber-500 to-amber-700' }, + { name: 'Record Audio', action: () => navigate('/record-audio'), icon: Zap, color: 'from-violet-500 to-violet-700' } + ]; - const callEmergencyNumber = (number) => { - }; + const callEmergencyNumber = (number) => { /* No-op for design */ }; const copyToClipboard = async (number) => { try { await navigator.clipboard.writeText(number); setCopiedNumber(number); setTimeout(() => setCopiedNumber(''), 2000); - } catch (err) { + } catch { const textArea = document.createElement('textarea'); textArea.value = number; document.body.appendChild(textArea); - textArea.select(); - document.execCommand('copy'); - document.body.removeChild(textArea); + textArea.select(); document.execCommand('copy'); document.body.removeChild(textArea); setCopiedNumber(number); setTimeout(() => setCopiedNumber(''), 2000); } @@ -90,10 +78,7 @@ const quickActions = [ if (location) { const locationText = `Emergency! My current location: https://maps.google.com/?q=${location.latitude},${location.longitude}`; if (navigator.share) { - navigator.share({ - title: 'Emergency Location', - text: locationText, - }); + navigator.share({ title: 'Emergency Location', text: locationText }); } else { copyToClipboard(locationText); alert('Location copied to clipboard!'); @@ -103,269 +88,215 @@ const quickActions = [ } }; - const sendSafeWordAlert = () => { - alert('Safe word alert would be sent to emergency contacts'); - }; - - const startRecording = () => { - alert('Audio recording feature would be activated'); - }; - return ( -
-
-
-
-
-
-
-
-
-
- -
-
-
-

- Emergency SOS -

-

Help is available 24/7 • Stay Safe

-
+
+ {/* Header */} +
+
+
+
+
+ + + + + + +
+

+ Emergency SOS +

+

Help is available 24/7 • Stay Safe

-
-
- - Current Time -
-
- {currentTime.toLocaleTimeString()} -
+
+
+
+ + Current Time +
+
+ {currentTime.toLocaleTimeString()}
-
+
-
-
+
+ {/* Location */} +
-
+

Your Location

- {location ? ( -
-
-
- +
+
+
+
-
-

- Coordinates: {location.latitude.toFixed(6)}, {location.longitude.toFixed(6)} -

-

+

+
+ {location.latitude.toFixed(6)}, {location.longitude.toFixed(6)} +
+
Accuracy: ±{Math.round(location.accuracy)} meters -

+
-
+
) : locationError ? ( -
-

{locationError}

+
+ {locationError} + className="bg-gradient-to-r from-amber-500 to-yellow-600 hover:from-amber-600 hover:to-yellow-800 text-white px-6 py-3 rounded-xl font-semibold transition" + >Try Again
) : ( -
-
-
-

Getting your location...

-
+
+ + Getting your location...
)} -
+
-
+ {/* Emergency Numbers */} +

Emergency Numbers

- -
- {emergencyNumbers.map((emergency, index) => { +
+ {emergencyNumbers.map((emergency, idx) => { const Icon = emergency.icon; return ( -
-
+
+
-
- -
+
-

{emergency.name}

-

+ {emergency.name} + {emergency.number} -

+
+ className="bg-gradient-to-r from-red-500 to-rose-600 hover:from-red-600 hover:to-rose-700 text-white px-5 py-3 rounded-xl font-semibold flex items-center gap-2 shadow transition hover:scale-105" + >Call
-

{emergency.description}

+
{emergency.description}
); })}
-
+
-
+ {/* Quick Actions */} +

Quick Actions

- -
- {quickActions.map((action, index) => { +
+ {quickActions.map((action, idx) => { const Icon = action.icon; return ( ); })}
-
+
-
+ {/* Safety Guidelines */} +

Safety Guidelines

- -
-
+
+

-
- -
+ Emergency Protocol

-
    -
  • -
    - Stay calm and assess the situation carefully -
  • -
  • -
    - Call the appropriate emergency number immediately -
  • -
  • -
    - Provide your exact location and situation details -
  • -
  • -
    - Follow the emergency operator's instructions precisely -
  • -
  • -
    - Stay on the line until professional help arrives -
  • +
      + {[ + "Stay calm and assess the situation carefully", + "Call the appropriate emergency number immediately", + "Provide your exact location and situation details", + "Follow the emergency operator's instructions precisely", + "Stay on the line until professional help arrives" + ].map((tip, i) => ( +
    • {tip}
    • + ))}
- -
+

-
- -
+ Preparedness Tips

-
    -
  • -
    - Keep emergency contacts readily accessible -
  • -
  • -
    - Share location with trusted family members -
  • -
  • -
    - Maintain your phone charge above 20% -
  • -
  • -
    - Keep medical information and allergies documented -
  • -
  • -
    - Always trust your instincts in potentially dangerous situations -
  • +
      + {[ + "Keep emergency contacts readily accessible", + "Share location with trusted family members", + "Maintain your phone charge above 20%", + "Keep medical information and allergies documented", + "Always trust your instincts in potentially dangerous situations" + ].map((tip, i) => ( +
    • {tip}
    • + ))}
- -
-
-
- -
-

- If you're in immediate danger, call emergency services right away. This application serves as a helpful tool, but professional emergency response should always be your primary priority. -

+
+
+ +
+
+ If you're in immediate danger, call emergency services right away. This app helps, but professional emergency response must be your priority.
-
-
+
+
); }; -export default SOSPage; \ No newline at end of file +export default SOSPage;