Spaces:
Build error
Build error
Download components/AlertSettings.jsx from rbachina/anycoder-d4f3e582: direct link, hf CLI and curl.
- Browser
- Download file 5.33 kB
-
https://huggingface.co/spaces/rbachina/anycoder-d4f3e582/resolve/main/components/AlertSettings.jsx
- Command line
-
hf download hf://spaces/rbachina/anycoder-d4f3e582/components/AlertSettings.jsx
-
curl -L -o AlertSettings.jsx https://huggingface.co/spaces/rbachina/anycoder-d4f3e582/resolve/main/components/AlertSettings.jsx
5.33 kB
| import { useState, useEffect } from 'react'; | |
| import { Bell, Clock, Save, Check } from 'lucide-react'; | |
| export default function AlertSettings() { | |
| const [settings, setSettings] = useState({ | |
| enabled: true, | |
| frequency: 'hourly', | |
| startTime: '09:00', | |
| endTime: '17:00', | |
| sound: true | |
| }); | |
| const [saved, setSaved] = useState(false); | |
| useEffect(() => { | |
| const savedSettings = localStorage.getItem('microfit_alerts'); | |
| if (savedSettings) { | |
| setSettings(JSON.parse(savedSettings)); | |
| } | |
| }, []); | |
| const handleSave = () => { | |
| localStorage.setItem('microfit_alerts', JSON.stringify(settings)); | |
| setSaved(true); | |
| setTimeout(() => setSaved(false), 3000); | |
| }; | |
| return ( | |
| <div className="bg-white rounded-xl shadow-lg p-6 border border-gray-100"> | |
| <div className="flex items-center gap-3 mb-6"> | |
| <div className="p-3 bg-warning-100 rounded-lg"> | |
| <Bell className="w-6 h-6 text-warning-600" /> | |
| </div> | |
| <div> | |
| <h2 className="text-2xl font-bold text-gray-900">Snack Alerts</h2> | |
| <p className="text-gray-500 text-sm">Configure your workout reminders</p> | |
| </div> | |
| </div> | |
| <div className="space-y-6"> | |
| <div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg"> | |
| <div className="flex items-center gap-3"> | |
| <Bell className="w-5 h-5 text-gray-600" /> | |
| <div> | |
| <div className="font-semibold text-gray-900">Enable Alerts</div> | |
| <div className="text-sm text-gray-500">Get notified for scheduled snacks</div> | |
| </div> | |
| </div> | |
| <button | |
| onClick={() => setSettings(prev => ({ ...prev, enabled: !prev.enabled }))} | |
| className={`w-14 h-8 rounded-full transition-colors duration-200 relative ${settings.enabled ? 'bg-primary-600' : 'bg-gray-300'}`} | |
| > | |
| <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'}`} /> | |
| </button> | |
| </div> | |
| {settings.enabled && ( | |
| <> | |
| <div className="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| <div> | |
| <label className="block text-sm font-medium text-gray-700 mb-2">Start Time</label> | |
| <div className="relative"> | |
| <Clock className="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400" /> | |
| <input | |
| type="time" | |
| value={settings.startTime} | |
| onChange={(e) => setSettings(prev => ({ ...prev, startTime: e.target.value }))} | |
| className="input-field pl-10" | |
| /> | |
| </div> | |
| </div> | |
| <div> | |
| <label className="block text-sm font-medium text-gray-700 mb-2">End Time</label> | |
| <div className="relative"> | |
| <Clock className="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400" /> | |
| <input | |
| type="time" | |
| value={settings.endTime} | |
| onChange={(e) => setSettings(prev => ({ ...prev, endTime: e.target.value }))} | |
| className="input-field pl-10" | |
| /> | |
| </div> | |
| </div> | |
| </div> | |
| <div> | |
| <label className="block text-sm font-medium text-gray-700 mb-2">Reminder Frequency</label> | |
| <select | |
| value={settings.frequency} | |
| onChange={(e) => setSettings(prev => ({ ...prev, frequency: e.target.value }))} | |
| className="input-field" | |
| > | |
| <option value="30min">Every 30 minutes</option> | |
| <option value="hourly">Every hour</option> | |
| <option value="2hours">Every 2 hours</option> | |
| <option value="scheduled">Only scheduled workouts</option> | |
| </select> | |
| </div> | |
| <div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg"> | |
| <div className="flex items-center gap-3"> | |
| <div className="text-gray-600">🔔</div> | |
| <div className="font-semibold text-gray-900">Sound Notifications</div> | |
| </div> | |
| <button | |
| onClick={() => setSettings(prev => ({ ...prev, sound: !prev.sound }))} | |
| className={`w-14 h-8 rounded-full transition-colors duration-200 relative ${settings.sound ? 'bg-primary-600' : 'bg-gray-300'}`} | |
| > | |
| <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'}`} /> | |
| </button> | |
| </div> | |
| </> | |
| )} | |
| <button | |
| onClick={handleSave} | |
| 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'}`} | |
| > | |
| {saved ? ( | |
| <><Check className="w-5 h-5" /> Settings Saved!</> | |
| ) : ( | |
| <><Save className="w-5 h-5" /> Save Alert Settings</> | |
| )} | |
| </button> | |
| </div> | |
| </div> | |
| ); | |
| } |