updates
This commit is contained in:
@@ -4,6 +4,7 @@ import { toast } from 'react-toastify';
|
||||
import notificationService, { Notification } from '../services/notificationService';
|
||||
import { formatDate } from '../../../shared/utils/format';
|
||||
import useAuthStore from '../../../store/useAuthStore';
|
||||
import { getUserFriendlyError } from '../../../shared/utils/errorSanitizer';
|
||||
|
||||
const InAppNotificationBell: React.FC = () => {
|
||||
const { isAuthenticated, token, isLoading } = useAuthStore();
|
||||
@@ -108,7 +109,7 @@ const InAppNotificationBell: React.FC = () => {
|
||||
try {
|
||||
await notificationService.markAsRead(notificationId);
|
||||
setNotifications(notifications.map(n =>
|
||||
n.id === notificationId ? { ...n, status: 'read' as 'unread' | 'read', read_at: new Date().toISOString() } : n
|
||||
n.id === notificationId ? { ...n, status: 'read' as Notification['status'], read_at: new Date().toISOString() } : n
|
||||
));
|
||||
setUnreadCount(Math.max(0, unreadCount - 1));
|
||||
} catch (error: unknown) {
|
||||
@@ -121,7 +122,7 @@ const InAppNotificationBell: React.FC = () => {
|
||||
setLoading(true);
|
||||
const unread = notifications.filter(n => !n.read_at);
|
||||
await Promise.all(unread.map(n => notificationService.markAsRead(n.id)));
|
||||
setNotifications(notifications.map(n => ({ ...n, status: 'read' as 'read' | 'unread', read_at: new Date().toISOString() })));
|
||||
setNotifications(notifications.map(n => ({ ...n, status: 'read' as Notification['status'], read_at: new Date().toISOString() })));
|
||||
setUnreadCount(0);
|
||||
} catch (error: unknown) {
|
||||
toast.error(getUserFriendlyError(error) || 'Failed to mark all as read');
|
||||
|
||||
Reference in New Issue
Block a user