import React from 'react'; import { useTranslation } from 'react-i18next'; import { BellIcon, BellAlertIcon, ExclamationTriangleIcon, FolderIcon, FolderOpenIcon, ClockIcon, } from '@heroicons/react/24/outline'; import type { NotificationPreferences } from '../types'; interface NotificationsTabProps { isActive: boolean; notificationPreferences: NotificationPreferences | null | undefined; onChange: (preferences: NotificationPreferences) => void; } const DEFAULT_PREFERENCES: NotificationPreferences = { dueTasks: { inApp: true, email: false, push: false }, overdueTasks: { inApp: true, email: false, push: false }, dueProjects: { inApp: true, email: false, push: false }, overdueProjects: { inApp: true, email: false, push: false }, deferUntil: { inApp: true, email: false, push: false }, }; interface NotificationTypeRowProps { icon: React.ComponentType<{ className?: string }>; label: string; description: string; preferences: { inApp: boolean; email: boolean; push: boolean }; onToggle: (channel: 'inApp' | 'email' | 'push', value: boolean) => void; } const NotificationTypeRow: React.FC = ({ icon: Icon, label, description, preferences, onToggle, }) => { const renderToggle = ( channel: 'inApp' | 'email' | 'push', isEnabled: boolean, isAvailable: boolean ) => ( ); return (
{label}
{description}
{renderToggle('inApp', preferences.inApp, true)} {renderToggle('email', preferences.email, false)} {renderToggle('push', preferences.push, false)} ); }; const NotificationsTab: React.FC = ({ isActive, notificationPreferences, onChange, }) => { const { t } = useTranslation(); if (!isActive) return null; // Merge with defaults to ensure all types exist const preferences: NotificationPreferences = { ...DEFAULT_PREFERENCES, ...notificationPreferences, }; const handleToggle = ( notificationType: keyof NotificationPreferences, channel: 'inApp' | 'email' | 'push', value: boolean ) => { const updatedPreferences = { ...preferences, [notificationType]: { ...preferences[notificationType], [channel]: value, }, }; onChange(updatedPreferences); }; return (

{t('profile.tabs.notifications', 'Notification Preferences')}

{t( 'profile.notificationsDescription', 'Choose how you want to be notified about important events.' )}

{/* Notifications Table */}
handleToggle('dueTasks', channel, value) } /> handleToggle('overdueTasks', channel, value) } /> handleToggle('deferUntil', channel, value) } /> handleToggle('dueProjects', channel, value) } /> handleToggle('overdueProjects', channel, value) } />
{t( 'notifications.table.type', 'Notification Type' )} {t('notifications.channels.inApp', 'In-app')}
{t('notifications.channels.email', 'Email')} ({t('common.comingSoon', 'Coming Soon')} )
{t('notifications.channels.push', 'Push')} ({t('common.comingSoon', 'Coming Soon')} )
{/* Help Text */}

{t('notifications.info.title', 'Note:')} {' '} {t( 'notifications.info.message', 'Email and Push notifications are coming soon. In-app notifications are currently available.' )}

); }; export default NotificationsTab;