-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettings.tsx
More file actions
393 lines (367 loc) · 16.3 KB
/
Settings.tsx
File metadata and controls
393 lines (367 loc) · 16.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
import { useState } from "react";
import { SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar";
import { AppSidebar } from "@/components/AppSidebar";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Switch } from "@/components/ui/switch";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import {
User,
Bell,
Shield,
Heart,
Smartphone,
Moon,
Volume2,
Globe,
HelpCircle,
Download,
Share2,
LogOut,
Camera,
Edit3
} from "lucide-react";
import { useToast } from "@/hooks/use-toast";
export default function Settings() {
const [profile, setProfile] = useState({
name: "Sarah Johnson",
username: "sarah_j",
email: "sarah.johnson@email.com",
phone: "+1 (555) 123-4567",
profileImage: ""
});
const [preferences, setPreferences] = useState({
pushNotifications: true,
emailNotifications: false,
criticalAlerts: true,
vaccinationReminders: true,
feedingReminders: true,
nightMode: false,
soundEnabled: true,
language: "en",
units: "metric",
dataSync: true,
biometricLogin: false
});
const { toast } = useToast();
const handleProfileUpdate = () => {
toast({
title: "Profile Updated",
description: "Your profile information has been saved successfully.",
});
};
const handlePreferenceChange = (key: string, value: boolean | string) => {
setPreferences(prev => ({ ...prev, [key]: value }));
toast({
title: "Settings Updated",
description: "Your preferences have been saved.",
});
};
const handleLogout = () => {
toast({
title: "Logged Out",
description: "You have been successfully logged out.",
variant: "destructive",
});
};
return (
<SidebarProvider>
<div className="min-h-screen flex w-full">
<AppSidebar />
<div className="flex-1 flex flex-col">
<header className="h-16 border-b border-border flex items-center px-6 bg-gradient-to-r from-purple-600 to-pink-600 text-white">
<SidebarTrigger className="mr-4 text-white hover:bg-white/20" />
<div className="flex items-center gap-4 flex-1">
<div>
<h1 className="text-xl font-bold">Settings</h1>
<p className="text-sm text-purple-100">Manage your account and app preferences</p>
</div>
</div>
</header>
<main className="flex-1 p-6 space-y-6 overflow-auto bg-gradient-to-br from-blue-50 via-purple-50 to-pink-50">
{/* Profile Section */}
<Card className="bg-white/95 backdrop-blur-sm shadow-lg">
<CardHeader>
<CardTitle className="flex items-center gap-2">
<User className="h-5 w-5" />
Profile Information
</CardTitle>
</CardHeader>
<CardContent className="space-y-6">
<div className="flex items-center gap-4">
<div className="relative">
<Avatar className="h-20 w-20">
<AvatarImage src={profile.profileImage} />
<AvatarFallback className="bg-gradient-to-r from-blue-500 to-purple-500 text-white text-xl">
{profile.name.split(' ').map(n => n[0]).join('')}
</AvatarFallback>
</Avatar>
<Button
size="sm"
className="absolute -bottom-2 -right-2 h-8 w-8 rounded-full p-0 bg-blue-600 hover:bg-blue-700"
>
<Camera className="h-4 w-4" />
</Button>
</div>
<div className="flex-1">
<h3 className="text-lg font-semibold">{profile.name}</h3>
<p className="text-gray-600">@{profile.username}</p>
<p className="text-sm text-gray-500">{profile.email}</p>
</div>
<Button variant="outline" className="flex items-center gap-2">
<Edit3 className="h-4 w-4" />
Edit Profile
</Button>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div className="space-y-2">
<Label htmlFor="name">Full Name</Label>
<Input
id="name"
value={profile.name}
onChange={(e) => setProfile(prev => ({ ...prev, name: e.target.value }))}
/>
</div>
<div className="space-y-2">
<Label htmlFor="username">Username</Label>
<Input
id="username"
value={profile.username}
onChange={(e) => setProfile(prev => ({ ...prev, username: e.target.value }))}
/>
</div>
<div className="space-y-2">
<Label htmlFor="email">Email</Label>
<Input
id="email"
type="email"
value={profile.email}
onChange={(e) => setProfile(prev => ({ ...prev, email: e.target.value }))}
/>
</div>
<div className="space-y-2">
<Label htmlFor="phone">Phone Number</Label>
<Input
id="phone"
value={profile.phone}
onChange={(e) => setProfile(prev => ({ ...prev, phone: e.target.value }))}
/>
</div>
</div>
<Button onClick={handleProfileUpdate} className="bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-700 hover:to-purple-700">
Save Profile Changes
</Button>
</CardContent>
</Card>
{/* Notification Settings */}
<Card className="bg-white/95 backdrop-blur-sm shadow-lg">
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Bell className="h-5 w-5" />
Notification Settings
</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="flex items-center justify-between">
<div>
<Label className="text-base">Push Notifications</Label>
<p className="text-sm text-gray-600">Receive notifications on your device</p>
</div>
<Switch
checked={preferences.pushNotifications}
onCheckedChange={(checked) => handlePreferenceChange('pushNotifications', checked)}
/>
</div>
<div className="flex items-center justify-between">
<div>
<Label className="text-base">Email Notifications</Label>
<p className="text-sm text-gray-600">Receive updates via email</p>
</div>
<Switch
checked={preferences.emailNotifications}
onCheckedChange={(checked) => handlePreferenceChange('emailNotifications', checked)}
/>
</div>
<div className="flex items-center justify-between">
<div>
<Label className="text-base">Critical Health Alerts</Label>
<p className="text-sm text-gray-600">Immediate alerts for critical health issues</p>
</div>
<Switch
checked={preferences.criticalAlerts}
onCheckedChange={(checked) => handlePreferenceChange('criticalAlerts', checked)}
/>
</div>
<div className="flex items-center justify-between">
<div>
<Label className="text-base">Vaccination Reminders</Label>
<p className="text-sm text-gray-600">Reminders for upcoming vaccinations</p>
</div>
<Switch
checked={preferences.vaccinationReminders}
onCheckedChange={(checked) => handlePreferenceChange('vaccinationReminders', checked)}
/>
</div>
<div className="flex items-center justify-between">
<div>
<Label className="text-base">Feeding Reminders</Label>
<p className="text-sm text-gray-600">Reminders for feeding schedules</p>
</div>
<Switch
checked={preferences.feedingReminders}
onCheckedChange={(checked) => handlePreferenceChange('feedingReminders', checked)}
/>
</div>
</CardContent>
</Card>
{/* App Preferences */}
<Card className="bg-white/95 backdrop-blur-sm shadow-lg">
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Smartphone className="h-5 w-5" />
App Preferences
</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="flex items-center justify-between">
<div>
<Label className="text-base">Dark Mode</Label>
<p className="text-sm text-gray-600">Switch to dark theme</p>
</div>
<Switch
checked={preferences.nightMode}
onCheckedChange={(checked) => handlePreferenceChange('nightMode', checked)}
/>
</div>
<div className="flex items-center justify-between">
<div>
<Label className="text-base">Sound Effects</Label>
<p className="text-sm text-gray-600">Enable app sounds and alerts</p>
</div>
<Switch
checked={preferences.soundEnabled}
onCheckedChange={(checked) => handlePreferenceChange('soundEnabled', checked)}
/>
</div>
<div className="flex items-center justify-between">
<div>
<Label className="text-base">Automatic Data Sync</Label>
<p className="text-sm text-gray-600">Sync data across devices</p>
</div>
<Switch
checked={preferences.dataSync}
onCheckedChange={(checked) => handlePreferenceChange('dataSync', checked)}
/>
</div>
<div className="space-y-2">
<Label>Language</Label>
<Select value={preferences.language} onValueChange={(value) => handlePreferenceChange('language', value)}>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="en">English</SelectItem>
<SelectItem value="sw">Swahili</SelectItem>
<SelectItem value="fr">French</SelectItem>
<SelectItem value="ar">Arabic</SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<Label>Measurement Units</Label>
<Select value={preferences.units} onValueChange={(value) => handlePreferenceChange('units', value)}>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="metric">Metric (kg, cm)</SelectItem>
<SelectItem value="imperial">Imperial (lbs, ft)</SelectItem>
</SelectContent>
</Select>
</div>
</CardContent>
</Card>
{/* Security Settings */}
<Card className="bg-white/95 backdrop-blur-sm shadow-lg">
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Shield className="h-5 w-5" />
Security & Privacy
</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="flex items-center justify-between">
<div>
<Label className="text-base">Biometric Login</Label>
<p className="text-sm text-gray-600">Use fingerprint or face ID to login</p>
</div>
<Switch
checked={preferences.biometricLogin}
onCheckedChange={(checked) => handlePreferenceChange('biometricLogin', checked)}
/>
</div>
<div className="space-y-2">
<Button variant="outline" className="w-full justify-start">
<Shield className="h-4 w-4 mr-2" />
Change Password
</Button>
<Button variant="outline" className="w-full justify-start">
<Download className="h-4 w-4 mr-2" />
Export My Data
</Button>
<Button variant="outline" className="w-full justify-start">
<Share2 className="h-4 w-4 mr-2" />
Share with Healthcare Provider
</Button>
</div>
</CardContent>
</Card>
{/* Support & About */}
<Card className="bg-white/95 backdrop-blur-sm shadow-lg">
<CardHeader>
<CardTitle className="flex items-center gap-2">
<HelpCircle className="h-5 w-5" />
Support & About
</CardTitle>
</CardHeader>
<CardContent className="space-y-2">
<Button variant="outline" className="w-full justify-start">
<HelpCircle className="h-4 w-4 mr-2" />
Help Center
</Button>
<Button variant="outline" className="w-full justify-start">
<Globe className="h-4 w-4 mr-2" />
Privacy Policy
</Button>
<Button variant="outline" className="w-full justify-start">
<Heart className="h-4 w-4 mr-2" />
Terms of Service
</Button>
<div className="pt-4 border-t">
<p className="text-sm text-gray-600 text-center">
WeanWise Africa v2.1.0
</p>
</div>
</CardContent>
</Card>
{/* Logout */}
<Card className="bg-gradient-to-r from-red-50 to-pink-50 border-red-200">
<CardContent className="p-6">
<Button
onClick={handleLogout}
className="w-full bg-red-600 hover:bg-red-700 text-white flex items-center justify-center gap-2"
>
<LogOut className="h-4 w-4" />
Sign Out
</Button>
</CardContent>
</Card>
</main>
</div>
</div>
</SidebarProvider>
);
}