Pixel/links development. New validations folder. More refactoring.
This commit is contained in:
21
src/components/hooks/queries/useWebsiteCohortQuery.ts
Normal file
21
src/components/hooks/queries/useWebsiteCohortQuery.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { useApi } from '../useApi';
|
||||
import { useModified } from '@/components/hooks';
|
||||
import { keepPreviousData } from '@tanstack/react-query';
|
||||
import { ReactQueryOptions } from '@/lib/types';
|
||||
|
||||
export function useWebsiteCohortQuery(
|
||||
websiteId: string,
|
||||
cohortId: string,
|
||||
options?: ReactQueryOptions,
|
||||
) {
|
||||
const { get, useQuery } = useApi();
|
||||
const { modified } = useModified(`cohorts`);
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['website:cohorts', { websiteId, cohortId, modified }],
|
||||
queryFn: () => get(`/websites/${websiteId}/cohorts/${cohortId}`),
|
||||
enabled: !!(websiteId && cohortId),
|
||||
placeholderData: keepPreviousData,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user