Files
maher 703f50a09d
Some checks failed
Build / run (push) Has been cancelled
first commit
2025-10-29 11:42:25 +01:00

33 lines
884 B
TypeScript
Executable File

import {useQuery} from '@tanstack/react-query';
import {PaginatedBackendResponse} from '@common/http/backend-response/pagination-response';
import {DatabaseNotification} from '@common/notifications/database-notification';
import {apiClient} from '@common/http/query-client';
const Endpoint = 'notifications';
export interface FetchUserNotificationsResponse
extends PaginatedBackendResponse<DatabaseNotification> {
//
}
interface Payload {
perPage?: number;
}
export function useUserNotifications(payload?: Payload) {
return useQuery({
queryKey: useUserNotifications.key,
queryFn: () => fetchUserNotifications(payload),
});
}
function fetchUserNotifications(
payload?: Payload,
): Promise<FetchUserNotificationsResponse> {
return apiClient
.get(Endpoint, {params: payload})
.then(response => response.data);
}
useUserNotifications.key = [Endpoint];