diff --git a/backend/api/v1/notifications/views.py b/backend/api/v1/notifications/views.py index 4abc2352..16b94c5a 100644 --- a/backend/api/v1/notifications/views.py +++ b/backend/api/v1/notifications/views.py @@ -63,7 +63,8 @@ def get_notifications(request): { 'id': n.id, 'title': n.title, - 'message': n.message, # Полное сообщение для списка + 'message': n.message, + 'short_message': n.short_message or n.message[:150], # Краткое сообщение для превью 'category': n.notification_type.category.code, 'category_name': n.notification_type.category.name, 'icon': n.notification_type.category.icon, diff --git a/frontend/src/hooks/useApi.ts b/frontend/src/hooks/useApi.ts index 22bbaf9c..1b06901c 100644 --- a/frontend/src/hooks/useApi.ts +++ b/frontend/src/hooks/useApi.ts @@ -179,7 +179,8 @@ export function useNotifications() { async function fetchNotifications() { try { const data = await apiClient.getNotifications(); - const notifs = data.results || data; + // Бэкенд возвращает { notifications: [...] } + const notifs = data.notifications || data.results || data; // Убеждаемся что notifs это массив const notificationsArray = Array.isArray(notifs) ? notifs : []; setNotifications(notificationsArray); diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index a376f3bc..cdc080e6 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -792,13 +792,13 @@ class ApiClient { } async markNotificationAsRead(id: number): Promise { - await this.request(`/api/v1/notifications/${id}/mark_read/`, { + await this.request(`/api/v1/notifications/${id}/read/`, { method: 'POST', }); } async markAllNotificationsAsRead(): Promise { - await this.request('/api/v1/notifications/mark_all_read/', { + await this.request('/api/v1/notifications/read-all/', { method: 'POST', }); }