// imports import { useQuery } from "@tanstack/vue-query"; import { API_ENDPOINTS, QUERY_KEYS } from "~/constants"; // types export type GetAllNotificationsResponse = ApiPaginated; export type GetAllNotificationsRequest = { sort: string | undefined; status: string | undefined; page: string | string[]; }; const useGetAllNotifications = (params: ComputedRef) => { // state const { $axios: axios } = useNuxtApp(); // methods const handleGetAllNotifications = async (params: GetAllNotificationsRequest) => { const { data } = await axios.get(API_ENDPOINTS.account.notifications.get_all, { params: { sort: params.sort, filter: params.status, offset: Number(params.page) * 10 - 10, limit: 10, }, }); return data; }; return useQuery({ queryKey: [QUERY_KEYS.notifications, params], queryFn: () => handleGetAllNotifications(params.value), }); }; export default useGetAllNotifications;