'use client'; import { useState } from 'react'; interface NotificationSetting { id: string; label: string; description: string; enabled: boolean; } interface NotificationsFormProps { onSave?: (data: { emailNotifications: NotificationSetting[]; pushNotifications: NotificationSetting[]; }) => void; } export function NotificationsForm({ onSave }: NotificationsFormProps) { const [emailNotifications, setEmailNotifications] = useState([ { id: 'new_leads', label: 'New Leads', description: 'Get notified when you receive new leads', enabled: true, }, { id: 'messages', label: 'Messages', description: 'Get notified when you receive new messages', enabled: true, }, { id: 'connection_requests', label: 'Connection Requests', description: 'Get notified about new connection requests', enabled: true, }, { id: 'property_updates', label: 'Property Updates', description: 'Get notified about property status changes', enabled: false, }, { id: 'marketing', label: 'Marketing & Promotions', description: 'Receive marketing emails and promotions', enabled: false, }, ]); const [pushNotifications, setPushNotifications] = useState([ { id: 'push_messages', label: 'Messages', description: 'Push notifications for new messages', enabled: true, }, { id: 'push_leads', label: 'New Leads', description: 'Push notifications for new leads', enabled: true, }, { id: 'push_reminders', label: 'Reminders', description: 'Push notifications for scheduled reminders', enabled: false, }, ]); const toggleEmailNotification = (id: string) => { setEmailNotifications((prev) => prev.map((item) => item.id === id ? { ...item, enabled: !item.enabled } : item ) ); }; const togglePushNotification = (id: string) => { setPushNotifications((prev) => prev.map((item) => item.id === id ? { ...item, enabled: !item.enabled } : item ) ); }; const handleSave = () => { if (onSave) { onSave({ emailNotifications, pushNotifications }); } else { console.log('Saving notification settings:', { emailNotifications, pushNotifications, }); } }; const ToggleSwitch = ({ enabled, onToggle, }: { enabled: boolean; onToggle: () => void; }) => ( ); return ( <> {/* Email Notifications */}

Email Notifications

Manage your email notification preferences

{emailNotifications.map((item) => (

{item.label}

{item.description}

toggleEmailNotification(item.id)} />
))}
{/* Push Notifications */}

Push Notifications

Manage your push notification preferences

{pushNotifications.map((item) => (

{item.label}

{item.description}

togglePushNotification(item.id)} />
))}
{/* Save Button */}
); }