From 472cd27320964ead8cc68ecf221eca6874e193c0 Mon Sep 17 00:00:00 2001 From: PEDZEO Date: Mon, 19 Jan 2026 01:15:48 +0300 Subject: [PATCH] Refactor TicketNotificationBell to improve toast notifications for new tickets and replies. Update localization files to include new notification strings for user replies and enhance existing messages. --- src/components/TicketNotificationBell.tsx | 31 +++++++++++++++++------ src/locales/en.json | 6 ++++- src/locales/fa.json | 18 +++++++++++++ src/locales/ru.json | 6 ++++- src/locales/zh.json | 18 +++++++++++++ 5 files changed, 69 insertions(+), 10 deletions(-) diff --git a/src/components/TicketNotificationBell.tsx b/src/components/TicketNotificationBell.tsx index 6518769..b2cd7da 100644 --- a/src/components/TicketNotificationBell.tsx +++ b/src/components/TicketNotificationBell.tsx @@ -35,22 +35,37 @@ export default function TicketNotificationBell({ isAdmin = false }: TicketNotifi // Show toast for WebSocket notification const showWSNotificationToast = useCallback((message: WSMessage) => { - const icon = message.type === 'ticket.new' ? ( + const isNewTicket = message.type === 'ticket.new' + const isAdminReply = message.type === 'ticket.admin_reply' + const isUserReply = message.type === 'ticket.user_reply' + + const icon = isNewTicket ? ( 🎫 - ) : message.type === 'ticket.admin_reply' ? ( + ) : isAdminReply ? ( 💬 ) : ( 📨 ) - const toastMessage = message.message || - (message.type === 'ticket.new' - ? t('notifications.newTicket', 'New ticket: {{title}}', { title: message.title }) - : t('notifications.newReply', 'New reply in ticket')) + const ticketTitle = message.title || '' + + let toastTitle: string + let toastMessage: string + + if (isNewTicket) { + toastTitle = t('notifications.newTicketTitle', 'New Ticket') + toastMessage = message.message || t('notifications.newTicket', 'New ticket: {{title}}', { title: ticketTitle }) + } else if (isUserReply) { + toastTitle = t('notifications.newUserReplyTitle', 'User Reply') + toastMessage = message.message || t('notifications.newUserReply', 'User replied in ticket: {{title}}', { title: ticketTitle }) + } else { + toastTitle = t('notifications.newReplyTitle', 'New Reply') + toastMessage = message.message || t('notifications.newReply', 'New reply in ticket: {{title}}', { title: ticketTitle }) + } showToast({ type: 'info', - title: message.type === 'ticket.new' ? t('notifications.newTicketTitle', 'New Ticket') : t('notifications.newReplyTitle', 'New Reply'), + title: toastTitle, message: toastMessage, icon, onClick: () => { @@ -189,7 +204,7 @@ export default function TicketNotificationBell({ isAdmin = false }: TicketNotifi {/* Dropdown */} {isOpen && ( -
+
{/* Header */}

diff --git a/src/locales/en.json b/src/locales/en.json index ab9d0ef..0e96d05 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -47,7 +47,11 @@ "newNotification": "New notification", "clickToView": "Click to view", "newTicket": "New ticket: {{title}}", - "newReply": "New reply in ticket" + "newReply": "New reply in ticket: {{title}}", + "newTicketTitle": "New Ticket", + "newReplyTitle": "New Reply", + "newUserReply": "User replied in ticket: {{title}}", + "newUserReplyTitle": "User Reply" }, "auth": { "login": "Login", diff --git a/src/locales/fa.json b/src/locales/fa.json index d0b5598..c0f1918 100644 --- a/src/locales/fa.json +++ b/src/locales/fa.json @@ -33,6 +33,24 @@ "info": "اطلاعات", "wheel": "چرخ شانس" }, + "notifications": { + "ticketNotifications": "اعلان‌های تیکت", + "markAllRead": "خواندن همه", + "noNotifications": "اعلانی وجود ندارد", + "justNow": "همین الان", + "minutesAgo": "{{count}} دقیقه پیش", + "hoursAgo": "{{count}} ساعت پیش", + "daysAgo": "{{count}} روز پیش", + "viewAll": "مشاهده همه تیکت‌ها", + "newNotification": "اعلان جدید", + "clickToView": "برای مشاهده کلیک کنید", + "newTicket": "تیکت جدید: {{title}}", + "newReply": "پاسخ جدید در تیکت: {{title}}", + "newTicketTitle": "تیکت جدید", + "newReplyTitle": "پاسخ جدید", + "newUserReply": "کاربر در تیکت پاسخ داد: {{title}}", + "newUserReplyTitle": "پاسخ کاربر" + }, "auth": { "login": "ورود", "register": "ثبت نام", diff --git a/src/locales/ru.json b/src/locales/ru.json index 9cb1f19..1513774 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -47,7 +47,11 @@ "newNotification": "Новое уведомление", "clickToView": "Нажмите для просмотра", "newTicket": "Новый тикет: {{title}}", - "newReply": "Новый ответ в тикете" + "newReply": "Новый ответ в тикете: {{title}}", + "newTicketTitle": "Новый тикет", + "newReplyTitle": "Новый ответ", + "newUserReply": "Ответ пользователя в тикете: {{title}}", + "newUserReplyTitle": "Ответ пользователя" }, "auth": { "login": "Вход", diff --git a/src/locales/zh.json b/src/locales/zh.json index bb0e0d2..8ce491a 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -33,6 +33,24 @@ "info": "信息", "wheel": "幸运转盘" }, + "notifications": { + "ticketNotifications": "工单通知", + "markAllRead": "全部标记已读", + "noNotifications": "暂无通知", + "justNow": "刚刚", + "minutesAgo": "{{count}}分钟前", + "hoursAgo": "{{count}}小时前", + "daysAgo": "{{count}}天前", + "viewAll": "查看所有工单", + "newNotification": "新通知", + "clickToView": "点击查看", + "newTicket": "新工单:{{title}}", + "newReply": "工单新回复:{{title}}", + "newTicketTitle": "新工单", + "newReplyTitle": "新回复", + "newUserReply": "用户回复了工单:{{title}}", + "newUserReplyTitle": "用户回复" + }, "auth": { "login": "登录", "register": "注册",