import React from 'react' import { User, Check, X, ArrowRight, Trash2, CheckCheck } from 'lucide-react' import { useTranslation } from '../../i18n' import type { InAppNotification } from '../../store/inAppNotificationStore' import { useSettingsStore } from '../../store/settingsStore' import { compactTime, useNotificationItemActions } from './useNotificationItemActions' function relativeTime(dateStr: string, locale: string): string { return compactTime(dateStr, locale === 'ar' ? 'الآن' : 'just now') } interface NotificationItemProps { notification: InAppNotification onClose?: () => void } export default function InAppNotificationItem({ notification, onClose }: NotificationItemProps): React.ReactElement { const { t, locale } = useTranslation() const { settings } = useSettingsStore() const darkMode = settings.dark_mode const dark = darkMode === true || darkMode === 'dark' || (darkMode === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) const { responding, handleRespond, handleNavigate, markRead, deleteNotification } = useNotificationItemActions(notification, onClose) const titleText = t(notification.title_key, notification.title_params) const bodyText = t(notification.text_key, notification.text_params) const hasUnknownTitle = titleText === notification.title_key const hasUnknownBody = bodyText === notification.text_key return (
{/* Sender avatar */}
{notification.sender_avatar ? ( ) : (
{notification.sender_username ? notification.sender_username.charAt(0).toUpperCase() : }
)}
{/* Content */}

{hasUnknownTitle ? notification.title_key : titleText}

{relativeTime(notification.created_at, locale)} {!notification.is_read && ( )}

{hasUnknownBody ? notification.text_key : bodyText}

{/* Boolean actions */} {notification.type === 'boolean' && notification.positive_text_key && notification.negative_text_key && (
)} {/* Navigate action */} {notification.type === 'navigate' && notification.navigate_text_key && notification.navigate_target && ( )}
) }