import React from 'react' import { User, Check, X, ArrowRight, Trash2, CheckCheck, Mail } from 'lucide-react' import { useTranslation } from '../../i18n' import type { InAppNotification } from '../../store/inAppNotificationStore' 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 } /** The round tool beside a notification, quiet until it is pointed at. */ const TOOL = 'grid place-items-center w-7 h-7 rounded-lg transition-colors text-content-faint hover:text-content hover:bg-surface-card focus-visible:bg-surface-card focus-visible:text-content' /** An answer or a way on, as a pill under the words. */ const PILL = 'inline-flex items-center gap-1.5 h-7 px-3 rounded-full text-caption font-medium transition-colors' /** * One notification, as a card in the list: who sent it, what it says, and what * can be done with it. Unread ones carry a dot in the accent and a faint * ground; the tools to mark and delete come forward when the card is pointed * at or focused, so a list reads as messages rather than as rows of buttons. */ export default function InAppNotificationItem({ notification, onClose }: NotificationItemProps): React.ReactElement { const { t, locale } = useTranslation() const { responding, handleRespond, handleNavigate, markRead, markUnread, 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 const unread = !notification.is_read const answered = notification.response !== null return (
{hasUnknownTitle ? notification.title_key : titleText}
{hasUnknownBody ? notification.text_key : bodyText}
{/* Boolean actions */} {notification.type === 'boolean' && notification.positive_text_key && notification.negative_text_key && (