UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

133 lines 4.97 kB
import { NotificationEntityType, NotificationApiClient } from '../types/notifications'; import type { NotificationGroup, Notification } from '../types/notifications'; /** * Create a comprehensive notifications hook with formatting and navigation * This hook provides all notification functionality in a single interface * * @param apiClient - API client instance for notifications * @returns Hook with notification state, actions, and utilities */ export declare const createUseNotifications: (apiClient: NotificationApiClient) => () => { notifications: Notification[]; unreadCount: number; loading: boolean; error: string | null; hasMore: boolean; currentPage: number; fetchNotifications: (params?: import("..").FetchNotificationsParams) => Promise<void>; fetchUnreadCount: () => Promise<void>; markAsRead: (id: string) => Promise<void>; markAllAsRead: () => Promise<void>; deleteNotification: (id: string) => Promise<void>; clearNotifications: () => void; resetError: () => void; markAsReadAndNavigate: (id: string, entityType?: string, entityId?: string, onAfterNavigate?: () => void) => Promise<void>; refreshNotifications: () => Promise<void>; handleNavigate: (entityType?: string, entityId?: string, onAfterNavigate?: () => void) => void; getActionLabel: (entityType?: string) => string | undefined; getGroupedNotifications: () => NotificationGroup[]; getFormattedGroupedNotifications: () => { notifications: { time: string; entityType: NotificationEntityType | undefined; entityId: string | undefined; id: string; title: string; message: string; type: import("..").NotificationType; isRead: boolean; createdAt: Date; actionLink?: string | null; linkImg?: string | null; sender?: { id: string; user: { id: string; name: string; email: string; }; } | null; activity?: { id: string; title: string; type: string; } | null; recommendedClass?: { id: string; title: string; } | null; }[]; label: string; }[]; }; /** * Create a pre-configured notifications hook * This is a convenience function that returns a hook ready to use * * @param apiClient - API client instance for notifications * @returns Pre-configured useNotifications hook * * @example * // In your app setup * import { createNotificationsHook } from 'analytica-frontend-lib'; * import api from './services/api'; * * export const useNotifications = createNotificationsHook(api); * * // Then use directly in components * const { unreadCount, fetchNotifications } = useNotifications(); */ export declare const createNotificationsHook: (apiClient: NotificationApiClient) => () => { notifications: Notification[]; unreadCount: number; loading: boolean; error: string | null; hasMore: boolean; currentPage: number; fetchNotifications: (params?: import("..").FetchNotificationsParams) => Promise<void>; fetchUnreadCount: () => Promise<void>; markAsRead: (id: string) => Promise<void>; markAllAsRead: () => Promise<void>; deleteNotification: (id: string) => Promise<void>; clearNotifications: () => void; resetError: () => void; markAsReadAndNavigate: (id: string, entityType?: string, entityId?: string, onAfterNavigate?: () => void) => Promise<void>; refreshNotifications: () => Promise<void>; handleNavigate: (entityType?: string, entityId?: string, onAfterNavigate?: () => void) => void; getActionLabel: (entityType?: string) => string | undefined; getGroupedNotifications: () => NotificationGroup[]; getFormattedGroupedNotifications: () => { notifications: { time: string; entityType: NotificationEntityType | undefined; entityId: string | undefined; id: string; title: string; message: string; type: import("..").NotificationType; isRead: boolean; createdAt: Date; actionLink?: string | null; linkImg?: string | null; sender?: { id: string; user: { id: string; name: string; email: string; }; } | null; activity?: { id: string; title: string; type: string; } | null; recommendedClass?: { id: string; title: string; } | null; }[]; label: string; }[]; }; //# sourceMappingURL=useNotifications.d.ts.map