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.

This commit is contained in:
PEDZEO
2026-01-19 01:15:48 +03:00
parent 89a219c3ef
commit 472cd27320
5 changed files with 69 additions and 10 deletions

View File

@@ -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 ? (
<span className="text-lg">🎫</span>
) : message.type === 'ticket.admin_reply' ? (
) : isAdminReply ? (
<span className="text-lg">💬</span>
) : (
<span className="text-lg">📨</span>
)
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 && (
<div className="absolute right-0 mt-2 w-80 sm:w-96 bg-dark-900/95 backdrop-blur-xl border border-dark-700/50 rounded-2xl shadow-2xl shadow-black/30 overflow-hidden z-50 animate-scale-in">
<div className="fixed sm:absolute top-16 sm:top-auto right-4 sm:right-0 left-4 sm:left-auto mt-0 sm:mt-2 w-auto sm:w-96 bg-dark-900/95 backdrop-blur-xl border border-dark-700/50 rounded-2xl shadow-2xl shadow-black/30 overflow-hidden z-50 animate-scale-in">
{/* Header */}
<div className="flex items-center justify-between px-4 py-3 border-b border-dark-700/50 bg-dark-800/30">
<h3 className="text-sm font-semibold text-dark-100">

View File

@@ -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",

View File

@@ -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": "ثبت نام",

View File

@@ -47,7 +47,11 @@
"newNotification": "Новое уведомление",
"clickToView": "Нажмите для просмотра",
"newTicket": "Новый тикет: {{title}}",
"newReply": "Новый ответ в тикете"
"newReply": "Новый ответ в тикете: {{title}}",
"newTicketTitle": "Новый тикет",
"newReplyTitle": "Новый ответ",
"newUserReply": "Ответ пользователя в тикете: {{title}}",
"newUserReplyTitle": "Ответ пользователя"
},
"auth": {
"login": "Вход",

View File

@@ -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": "注册",