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 (
{hasUnknownTitle ? notification.title_key : titleText}
{hasUnknownBody ? notification.text_key : bodyText}
{/* Boolean actions */} {notification.type === 'boolean' && notification.positive_text_key && notification.negative_text_key && (