import type { Notification } from '@supabase/shared-types/out/notifications' import { useQuery, UseQueryOptions } from '@tanstack/react-query' import { get, handleError } from 'data/fetchers' import type { ResponseError } from 'types' import { notificationKeys } from './keys' export type NotificationsResponse = Notification[] export async function getNotificationsSummary(signal?: AbortSignal) { const { data, error } = await get('/platform/notifications/summary', { signal, }) if (error) handleError(error) return data } export type NotificationsData = Awaited> export type NotificationsError = ResponseError export const useNotificationsSummaryQuery = ( options: UseQueryOptions = {} ) => useQuery( notificationKeys.summary(), ({ signal }) => getNotificationsSummary(signal), options )