import { type FC, useEffect } from 'react' import { CloseCircle, NotificationBing, ShoppingBag, MessageText1 } from 'iconsax-react' import Button from '@/components/Button' import { NotificationSubject } from '@/types/notification.types' interface NotificationItemProps { id: string subject: string body: string onRemove: (id: string) => void audioEnabled: boolean } const NotificationItem: FC = ({ id, subject, body, onRemove, audioEnabled }) => { useEffect(() => { if (!audioEnabled) { return } const playNotificationSound = async () => { try { const audio = new Audio('/mixkit-correct-answer-tone-2870.wav') audio.volume = 0.5 audio.addEventListener('error', (err) => { console.error('❌ خطا در لود فایل صوتی:', err) }, { once: true }) await audio.play() } catch (err) { console.warn('خطا در پخش صدا:', err) } } playNotificationSound() }, [audioEnabled]) const getNotificationConfig = (subjectType: string) => { switch (subjectType) { case NotificationSubject.PAGER_CREATED: return { icon: , title: 'پیجر جدید', } case NotificationSubject.ORDER_CREATED: return { icon: , title: 'سفارش جدید', } default: return { icon: , title: 'اطلاعیه', } } } const config = getNotificationConfig(subject) return (
{config.icon}

{config.title}

{body || 'نوتیفیکیشن جدید'}

) } export default NotificationItem