fix(ReactQuery): add organization id in query keys.

This commit is contained in:
a.bouhuolia
2021-03-15 11:55:38 +02:00
parent 2e3fd64e2b
commit f1cf02c9df
27 changed files with 140 additions and 76 deletions

View File

@@ -1,4 +1,5 @@
import { useMutation, useQuery, useQueryClient } from 'react-query';
import { useMutation, useQueryClient } from 'react-query';
import { useQueryTenant } from '../useQueryTenant';
import { transformPagination } from 'utils';
import useApiRequest from '../useRequest';
import t from './types';
@@ -27,7 +28,7 @@ const commonInvalidateQueries = (queryClient) => {
export function useCustomers(query, props) {
const apiRequest = useApiRequest();
return useQuery(
return useQueryTenant(
[t.CUSTOMERS, query],
() => apiRequest.get(`customers`, { params: query }),
{
@@ -118,7 +119,7 @@ export function useCreateCustomer(props) {
export function useCustomer(id, props) {
const apiRequest = useApiRequest();
return useQuery(
return useQueryTenant(
[t.CUSTOMER, id],
() => apiRequest.get(`customers/${id}`),
{