diff --git a/apps/dashboard/src/api/activity.ts b/apps/dashboard/src/api/activity.ts index c5aae18ed7c..9c7c3129bec 100644 --- a/apps/dashboard/src/api/activity.ts +++ b/apps/dashboard/src/api/activity.ts @@ -1,3 +1,4 @@ +import { IEnvironment } from '@novu/shared'; import { get } from './api.client'; import type { Activity } from '@/hooks/use-activities'; @@ -15,7 +16,11 @@ interface ActivityResponse { pageSize: number; } -export function getActivityList(page = 0, filters?: IActivityFilters): Promise { +export function getActivityList( + environment: IEnvironment, + page = 0, + filters?: IActivityFilters +): Promise { const searchParams = new URLSearchParams(); searchParams.append('page', page.toString()); @@ -35,7 +40,9 @@ export function getActivityList(page = 0, filters?: IActivityFilters): Promise(`/notifications?${searchParams.toString()}`); + return get(`/notifications?${searchParams.toString()}`, { + environment, + }); } export function getActivityStats() { diff --git a/apps/dashboard/src/hooks/use-activities.ts b/apps/dashboard/src/hooks/use-activities.ts index 545f85d92c5..8679c60acc8 100644 --- a/apps/dashboard/src/hooks/use-activities.ts +++ b/apps/dashboard/src/hooks/use-activities.ts @@ -1,5 +1,6 @@ import { useQuery } from '@tanstack/react-query'; import { getActivityList, IActivityFilters } from '@/api/activity'; +import { useEnvironment } from '../context/environment/hooks'; interface UseActivitiesOptions { page?: number; @@ -83,9 +84,11 @@ interface ActivityResponse { } export function useActivities({ page = 0, filters }: UseActivitiesOptions = {}) { + const { currentEnvironment } = useEnvironment(); + const { data, isLoading, isFetching } = useQuery({ - queryKey: ['activitiesList', page, filters], - queryFn: () => getActivityList(page, filters), + queryKey: ['activitiesList', currentEnvironment?._id, page, filters], + queryFn: () => getActivityList(currentEnvironment!, page, filters), staleTime: 1000 * 60, // 1 minute });