aboutsummaryrefslogtreecommitdiff
path: root/src/components/hooks/queries/useTeamsQuery.ts
blob: f1a09f4da5516ffb3a54cfdf338fe8ca65811a1f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import type { ReactQueryOptions } from '@/lib/types';
import { useApi } from '../useApi';
import { useModified } from '../useModified';
import { usePagedQuery } from '../usePagedQuery';

export function useTeamsQuery(params?: Record<string, any>, options?: ReactQueryOptions) {
  const { get } = useApi();
  const { modified } = useModified(`teams`);

  return usePagedQuery({
    queryKey: ['teams:admin', { modified, ...params }],
    queryFn: pageParams => {
      return get(`/admin/teams`, {
        ...pageParams,
        ...params,
      });
    },
    ...options,
  });
}