Spaces:
Build error
Build error
Upload components/AlertSettings.jsx with huggingface_hub
Browse files- components/AlertSettings.jsx +127 -0
components/AlertSettings.jsx
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState, useEffect } from 'react';
|
| 2 |
+
import { Bell, Clock, Save, Check } from 'lucide-react';
|
| 3 |
+
|
| 4 |
+
export default function AlertSettings() {
|
| 5 |
+
const [settings, setSettings] = useState({
|
| 6 |
+
enabled: true,
|
| 7 |
+
frequency: 'hourly',
|
| 8 |
+
startTime: '09:00',
|
| 9 |
+
endTime: '17:00',
|
| 10 |
+
sound: true
|
| 11 |
+
});
|
| 12 |
+
const [saved, setSaved] = useState(false);
|
| 13 |
+
|
| 14 |
+
useEffect(() => {
|
| 15 |
+
const savedSettings = localStorage.getItem('microfit_alerts');
|
| 16 |
+
if (savedSettings) {
|
| 17 |
+
setSettings(JSON.parse(savedSettings));
|
| 18 |
+
}
|
| 19 |
+
}, []);
|
| 20 |
+
|
| 21 |
+
const handleSave = () => {
|
| 22 |
+
localStorage.setItem('microfit_alerts', JSON.stringify(settings));
|
| 23 |
+
setSaved(true);
|
| 24 |
+
setTimeout(() => setSaved(false), 3000);
|
| 25 |
+
};
|
| 26 |
+
|
| 27 |
+
return (
|
| 28 |
+
<div className="bg-white rounded-xl shadow-lg p-6 border border-gray-100">
|
| 29 |
+
<div className="flex items-center gap-3 mb-6">
|
| 30 |
+
<div className="p-3 bg-warning-100 rounded-lg">
|
| 31 |
+
<Bell className="w-6 h-6 text-warning-600" />
|
| 32 |
+
</div>
|
| 33 |
+
<div>
|
| 34 |
+
<h2 className="text-2xl font-bold text-gray-900">Snack Alerts</h2>
|
| 35 |
+
<p className="text-gray-500 text-sm">Configure your workout reminders</p>
|
| 36 |
+
</div>
|
| 37 |
+
</div>
|
| 38 |
+
|
| 39 |
+
<div className="space-y-6">
|
| 40 |
+
<div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
|
| 41 |
+
<div className="flex items-center gap-3">
|
| 42 |
+
<Bell className="w-5 h-5 text-gray-600" />
|
| 43 |
+
<div>
|
| 44 |
+
<div className="font-semibold text-gray-900">Enable Alerts</div>
|
| 45 |
+
<div className="text-sm text-gray-500">Get notified for scheduled snacks</div>
|
| 46 |
+
</div>
|
| 47 |
+
</div>
|
| 48 |
+
<button
|
| 49 |
+
onClick={() => setSettings(prev => ({ ...prev, enabled: !prev.enabled }))}
|
| 50 |
+
className={`w-14 h-8 rounded-full transition-colors duration-200 relative ${settings.enabled ? 'bg-primary-600' : 'bg-gray-300'}`}
|
| 51 |
+
>
|
| 52 |
+
<span className={`absolute top-1 w-6 h-6 bg-white rounded-full shadow transition-transform duration-200 ${settings.enabled ? 'translate-x-7' : 'translate-x-1'}`} />
|
| 53 |
+
</button>
|
| 54 |
+
</div>
|
| 55 |
+
|
| 56 |
+
{settings.enabled && (
|
| 57 |
+
<>
|
| 58 |
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
| 59 |
+
<div>
|
| 60 |
+
<label className="block text-sm font-medium text-gray-700 mb-2">Start Time</label>
|
| 61 |
+
<div className="relative">
|
| 62 |
+
<Clock className="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400" />
|
| 63 |
+
<input
|
| 64 |
+
type="time"
|
| 65 |
+
value={settings.startTime}
|
| 66 |
+
onChange={(e) => setSettings(prev => ({ ...prev, startTime: e.target.value }))}
|
| 67 |
+
className="input-field pl-10"
|
| 68 |
+
/>
|
| 69 |
+
</div>
|
| 70 |
+
</div>
|
| 71 |
+
<div>
|
| 72 |
+
<label className="block text-sm font-medium text-gray-700 mb-2">End Time</label>
|
| 73 |
+
<div className="relative">
|
| 74 |
+
<Clock className="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400" />
|
| 75 |
+
<input
|
| 76 |
+
type="time"
|
| 77 |
+
value={settings.endTime}
|
| 78 |
+
onChange={(e) => setSettings(prev => ({ ...prev, endTime: e.target.value }))}
|
| 79 |
+
className="input-field pl-10"
|
| 80 |
+
/>
|
| 81 |
+
</div>
|
| 82 |
+
</div>
|
| 83 |
+
</div>
|
| 84 |
+
|
| 85 |
+
<div>
|
| 86 |
+
<label className="block text-sm font-medium text-gray-700 mb-2">Reminder Frequency</label>
|
| 87 |
+
<select
|
| 88 |
+
value={settings.frequency}
|
| 89 |
+
onChange={(e) => setSettings(prev => ({ ...prev, frequency: e.target.value }))}
|
| 90 |
+
className="input-field"
|
| 91 |
+
>
|
| 92 |
+
<option value="30min">Every 30 minutes</option>
|
| 93 |
+
<option value="hourly">Every hour</option>
|
| 94 |
+
<option value="2hours">Every 2 hours</option>
|
| 95 |
+
<option value="scheduled">Only scheduled workouts</option>
|
| 96 |
+
</select>
|
| 97 |
+
</div>
|
| 98 |
+
|
| 99 |
+
<div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
|
| 100 |
+
<div className="flex items-center gap-3">
|
| 101 |
+
<div className="text-gray-600">🔔</div>
|
| 102 |
+
<div className="font-semibold text-gray-900">Sound Notifications</div>
|
| 103 |
+
</div>
|
| 104 |
+
<button
|
| 105 |
+
onClick={() => setSettings(prev => ({ ...prev, sound: !prev.sound }))}
|
| 106 |
+
className={`w-14 h-8 rounded-full transition-colors duration-200 relative ${settings.sound ? 'bg-primary-600' : 'bg-gray-300'}`}
|
| 107 |
+
>
|
| 108 |
+
<span className={`absolute top-1 w-6 h-6 bg-white rounded-full shadow transition-transform duration-200 ${settings.sound ? 'translate-x-7' : 'translate-x-1'}`} />
|
| 109 |
+
</button>
|
| 110 |
+
</div>
|
| 111 |
+
</>
|
| 112 |
+
)}
|
| 113 |
+
|
| 114 |
+
<button
|
| 115 |
+
onClick={handleSave}
|
| 116 |
+
className={`w-full py-3 rounded-lg font-semibold flex items-center justify-center gap-2 transition-all duration-200 ${saved ? 'bg-accent-600 text-white' : 'btn-primary'}`}
|
| 117 |
+
>
|
| 118 |
+
{saved ? (
|
| 119 |
+
<><Check className="w-5 h-5" /> Settings Saved!</>
|
| 120 |
+
) : (
|
| 121 |
+
<><Save className="w-5 h-5" /> Save Alert Settings</>
|
| 122 |
+
)}
|
| 123 |
+
</button>
|
| 124 |
+
</div>
|
| 125 |
+
</div>
|
| 126 |
+
);
|
| 127 |
+
}
|