mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
fix(ReactQuery): add organization id in query keys.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
||||
import { useMutation, useQueryClient } from 'react-query';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
import useApiRequest from '../useRequest';
|
||||
import t from './types';
|
||||
|
||||
@@ -21,7 +22,7 @@ const commonInvalidateQueries = (query) => {
|
||||
export function useAccounts(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.ACCOUNTS, query],
|
||||
() => apiRequest.get('accounts', { params: query }),
|
||||
{
|
||||
@@ -46,7 +47,7 @@ export function useAccounts(query, props) {
|
||||
export function useAccount(id, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.ACCOUNT, id],
|
||||
() => apiRequest.get(`accounts/${id}`).then(transformAccount),
|
||||
{
|
||||
@@ -65,7 +66,7 @@ export function useAccount(id, props) {
|
||||
export function useAccountsTypes(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.ACCOUNTS_TYPES],
|
||||
() => apiRequest.get('account_types'),
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useQueryClient, useQuery, useMutation } from 'react-query';
|
||||
import { useQueryClient, useMutation } from 'react-query';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
import { defaultTo } from 'lodash';
|
||||
import { transformPagination } from 'utils';
|
||||
import useApiRequest from '../useRequest';
|
||||
@@ -100,7 +101,7 @@ export function useDeleteBill(props) {
|
||||
export function useBills(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
[t.BILLS, query],
|
||||
() =>
|
||||
apiRequest.get('purchases/bills', { params: query }),
|
||||
@@ -135,7 +136,7 @@ export function useBills(query, props) {
|
||||
export function useBill(id, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
[t.BILL, id],
|
||||
() => apiRequest.get(`/purchases/bills/${id}`),
|
||||
{
|
||||
@@ -157,7 +158,7 @@ export function useBill(id, props) {
|
||||
export function useDueBills(vendorId, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
[t.BILLS, t.BILLS_DUE, vendorId],
|
||||
() =>
|
||||
apiRequest.get(`purchases/bills/due`, {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from 'react-query';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
|
||||
/**
|
||||
* Retrieve the contact duplicate.
|
||||
@@ -7,7 +7,7 @@ import useApiRequest from '../useRequest';
|
||||
export function useContact(id, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(['CONTACT', id], () => apiRequest.get(`contacts/${id}`), {
|
||||
return useQueryTenant(['CONTACT', id], () => apiRequest.get(`contacts/${id}`), {
|
||||
select: (res) => res.data.customer,
|
||||
...props,
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useMutation, useQueryClient, useQuery } from 'react-query';
|
||||
import { useMutation, useQueryClient } from 'react-query';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
import useApiRequest from '../useRequest';
|
||||
import t from './types';
|
||||
|
||||
@@ -63,7 +64,7 @@ export function useDeleteCurrency(props) {
|
||||
export function useCurrencies(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.CURRENCIES],
|
||||
() => apiRequest.get('currencies').then((res) => res.data.currencies),
|
||||
{
|
||||
|
||||
@@ -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}`),
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useQueryClient, useQuery, useMutation } from 'react-query';
|
||||
import { useQueryClient, useMutation } from 'react-query';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { transformPagination } from 'utils';
|
||||
import t from './types';
|
||||
@@ -56,7 +57,7 @@ export function useEditEstimate(props) {
|
||||
export function useEstimate(id, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.SALE_ESTIMATE, id],
|
||||
() => apiRequest.get(`sales/estimates/${id}`),
|
||||
{
|
||||
@@ -76,7 +77,7 @@ export function useEstimate(id, props) {
|
||||
export function useEstimates(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.SALE_ESTIMATES, query],
|
||||
() => apiRequest.get('sales/estimates', { params: query }),
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useQuery, useMutation, useQueryClient } from 'react-query';
|
||||
import { useMutation, useQueryClient } from 'react-query';
|
||||
import { defaultTo } from 'lodash';
|
||||
import { transformPagination, transformResponse } from 'utils';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
import { transformPagination } from 'utils';
|
||||
import useApiRequest from '../useRequest';
|
||||
|
||||
const defaultPagination = {
|
||||
@@ -62,7 +63,7 @@ export function useDeleteExchangeRate(props) {
|
||||
export function useExchangeRates(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
['EXCHANGES_RATES', query],
|
||||
() => apiRequest.get('exchange_rates', { params: query }),
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useQuery, useMutation, useQueryClient } from 'react-query';
|
||||
import { useMutation, useQueryClient } from 'react-query';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
import { transformPagination } from 'utils';
|
||||
import t from './types';
|
||||
|
||||
@@ -28,7 +29,7 @@ const commonInvalidateQueries = (queryClient) => {
|
||||
export function useExpenses(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.EXPENSES, query],
|
||||
() => apiRequest.get(`expenses`, { params: { ...query } }),
|
||||
{
|
||||
@@ -57,7 +58,7 @@ export function useExpenses(query, props) {
|
||||
export function useExpense(id, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.EXPENSE, id],
|
||||
() => apiRequest.get(`expenses/${id}`),
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from 'react-query';
|
||||
import { defaultTo } from 'lodash';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
import {
|
||||
trialBalanceSheetReducer,
|
||||
balanceSheetRowsReducer,
|
||||
@@ -18,7 +18,7 @@ import t from './types';
|
||||
export function useBalanceSheet(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
[t.FINANCIAL_REPORT, t.BALANCE_SHEET, query],
|
||||
() =>
|
||||
apiRequest.get('/financial_statements/balance_sheet', {
|
||||
@@ -50,7 +50,7 @@ export function useBalanceSheet(query, props) {
|
||||
export function useTrialBalanceSheet(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
[t.FINANCIAL_REPORT, t.TRIAL_BALANCE_SHEET, query],
|
||||
() =>
|
||||
apiRequest.get('/financial_statements/trial_balance_sheet', {
|
||||
@@ -81,7 +81,7 @@ export function useTrialBalanceSheet(query, props) {
|
||||
export function useProfitLossSheet(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
[t.FINANCIAL_REPORT, t.PROFIT_LOSS_SHEET, query],
|
||||
() =>
|
||||
apiRequest.get('/financial_statements/profit_loss_sheet', {
|
||||
@@ -112,7 +112,7 @@ export function useProfitLossSheet(query, props) {
|
||||
export function useGeneralLedgerSheet(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
[t.FINANCIAL_REPORT, t.GENERAL_LEDGER, query],
|
||||
() =>
|
||||
apiRequest.get('/financial_statements/general_ledger', {
|
||||
@@ -143,7 +143,7 @@ export function useGeneralLedgerSheet(query, props) {
|
||||
export function useJournalSheet(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
[t.FINANCIAL_REPORT, t.JOURNAL, query],
|
||||
() => apiRequest.get('/financial_statements/journal', { params: query }),
|
||||
{
|
||||
@@ -171,7 +171,7 @@ export function useJournalSheet(query, props) {
|
||||
export function useARAgingSummaryReport(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.FINANCIAL_REPORT, t.AR_AGING_SUMMARY, query],
|
||||
() =>
|
||||
apiRequest.get('/financial_statements/receivable_aging_summary', {
|
||||
@@ -210,7 +210,7 @@ export function useARAgingSummaryReport(query, props) {
|
||||
export function useAPAgingSummaryReport(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.FINANCIAL_REPORT, t.AP_AGING_SUMMARY, query],
|
||||
() =>
|
||||
apiRequest.get('/financial_statements/payable_aging_summary', {
|
||||
|
||||
@@ -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';
|
||||
@@ -71,7 +72,7 @@ const inventoryAdjustmentsTransformer = (response) => {
|
||||
export function useInventoryAdjustments(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
['INVENTORY_ADJUSTMENTS', query],
|
||||
() => apiRequest.get('inventory_adjustments', { params: query })
|
||||
.then(inventoryAdjustmentsTransformer),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useMutation, useQuery } from 'react-query';
|
||||
import { useMutation } from 'react-query';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
import useApiRequest from '../useRequest';
|
||||
|
||||
/**
|
||||
@@ -20,7 +21,7 @@ export const useAuthInviteAccept = (props) => {
|
||||
export const useInviteMetaByToken = (token, props) => {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
['INVITE_META', token],
|
||||
() => apiRequest.get(`invite/invited/${token}`),
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useQueryClient, useQuery, useMutation } from 'react-query';
|
||||
import { useQueryClient, useMutation } from 'react-query';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
import { transformPagination } from 'utils';
|
||||
import useApiRequest from '../useRequest';
|
||||
import t from './types';
|
||||
@@ -95,7 +96,7 @@ export function useDeleteInvoice(props) {
|
||||
export function useInvoices(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.SALE_INVOICES, query],
|
||||
() => apiRequest.get('sales/invoices', { params: query }),
|
||||
{
|
||||
@@ -150,7 +151,7 @@ export function useDeliverInvoice(props) {
|
||||
export function useInvoice(invoiceId, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.SALE_INVOICE, invoiceId],
|
||||
() => apiRequest.get(`sales/invoices/${invoiceId}`),
|
||||
{
|
||||
@@ -173,7 +174,7 @@ export function useInvoice(invoiceId, props) {
|
||||
export function useDueInvoices(customerId, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.SALE_INVOICES, t.SALE_INVOICES_DUE, customerId],
|
||||
() =>
|
||||
apiRequest.get(`sales/invoices/payable`, {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
||||
import { transformPagination, transformResponse } from 'utils';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
import useApiRequest from '../useRequest';
|
||||
import t from './types';
|
||||
|
||||
@@ -126,8 +127,8 @@ const transformItemsResponse = (response) => {
|
||||
export function useItems(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
['ITEMS', query],
|
||||
return useQueryTenant(
|
||||
[t.ITEMS, query],
|
||||
() => apiRequest.get(`items`, { params: query }).then(transformItemsResponse),
|
||||
{
|
||||
initialDataUpdatedAt: 0,
|
||||
@@ -148,8 +149,8 @@ export function useItems(query, props) {
|
||||
export function useItem(id, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
['ITEM', id],
|
||||
return useQueryTenant(
|
||||
[t.ITEM, id],
|
||||
() => apiRequest.get(`items/${id}`).then((response) => response.data.item),
|
||||
{
|
||||
initialDataUpdatedAt: 0,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useQuery, useMutation, useQueryClient } from 'react-query';
|
||||
import { useMutation, useQueryClient } from 'react-query';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
import useApiRequest from '../useRequest';
|
||||
import t from './types';
|
||||
|
||||
@@ -73,7 +74,7 @@ export function useDeleteItemCategory(props) {
|
||||
export function useItemsCategories(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.ITEMS_CATEGORIES, query],
|
||||
() => apiRequest.get(`item_categories`, { params: query }),
|
||||
{
|
||||
@@ -100,7 +101,7 @@ export function useItemsCategories(query, props) {
|
||||
export function useItemCategory(id, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.ITEM_CATEGORY, id],
|
||||
() =>
|
||||
apiRequest.get(`item_categories/${id}`).then((res) => res.data.category),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { defaultTo } from 'lodash';
|
||||
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';
|
||||
@@ -113,7 +114,7 @@ export function usePublishJournal(props) {
|
||||
export function useJournals(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
[t.MANUAL_JOURNALS, query],
|
||||
() => apiRequest.get('manual-journals', { params: query }),
|
||||
{
|
||||
@@ -142,7 +143,7 @@ export function useJournals(query, props) {
|
||||
export function useJournal(id, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.MANUAL_JOURNAL, id],
|
||||
() => apiRequest.get(`manual-journals/${id}`),
|
||||
{
|
||||
|
||||
25
client/src/hooks/query/organization.js
Normal file
25
client/src/hooks/query/organization.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import t from 'store/types';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
|
||||
/**
|
||||
* Retrieve the contact duplicate.
|
||||
*/
|
||||
export function useOrganizations(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQueryTenant(
|
||||
[t.ORGANIZATIONS],
|
||||
() => apiRequest.get(`organization/all`),
|
||||
{
|
||||
select: (res) => res.data.organizations,
|
||||
initialDataUpdatedAt: 0,
|
||||
initialData: {
|
||||
data: {
|
||||
organizations: [],
|
||||
},
|
||||
},
|
||||
...props,
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { defaultTo } from 'lodash';
|
||||
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';
|
||||
@@ -35,7 +36,7 @@ const commonInvalidateQueries = (client) => {
|
||||
export function usePaymentMades(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
[t.PAYMENT_MADES, query],
|
||||
() => apiRequest.get('purchases/bill_payments', { params: query }),
|
||||
{
|
||||
@@ -127,7 +128,7 @@ export function useDeletePaymentMade(props) {
|
||||
export function usePaymentMadeEditPage(id, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
[t.PAYMENT_MADE_EDIT_PAGE, id],
|
||||
() => apiRequest.get(`purchases/bill_payments/${id}/edit-page`),
|
||||
{
|
||||
@@ -152,7 +153,7 @@ export function usePaymentMadeEditPage(id, props) {
|
||||
export function usePaymentMadeNewPageEntries(vendorId, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.PAYMENT_MADE_NEW_ENTRIES, vendorId],
|
||||
() =>
|
||||
apiRequest.get(`purchases/bill_payments/new-page/entries`, {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
||||
import { useMutation, useQueryClient } from 'react-query';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
import { defaultTo } from 'lodash';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { transformPagination, saveInvoke } from 'utils';
|
||||
@@ -32,7 +33,7 @@ const commonInvalidateQueries = (client) => {
|
||||
export function usePaymentReceives(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
[t.PAYMENT_RECEIVES, query],
|
||||
() => apiRequest.get('sales/payment_receives', { params: query }),
|
||||
{
|
||||
@@ -137,7 +138,7 @@ export function useDeletePaymentReceive(props) {
|
||||
export function usePaymentReceive(id, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
[t.PAYMENT_RECEIVE, id],
|
||||
() => apiRequest.get(`sales/payment_receives/${id}`),
|
||||
{
|
||||
@@ -161,7 +162,7 @@ export function usePaymentReceive(id, props) {
|
||||
export function usePaymentReceiveEditPage(id, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
[t.PAYMENT_RECEIVE_EDIT_PAGE, id],
|
||||
() => apiRequest.get(`sales/payment_receives/${id}/edit-page`),
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useQueryClient, useQuery, useMutation } from 'react-query';
|
||||
import { useQueryClient, useMutation } from 'react-query';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
import { defaultTo } from 'lodash';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { transformPagination } from 'utils';
|
||||
@@ -104,7 +105,7 @@ export function useCloseReceipt(props) {
|
||||
export function useReceipts(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
['SALE_RECEIPTS', query],
|
||||
() => apiRequest.get('sales/receipts', { params: query }),
|
||||
{
|
||||
@@ -137,7 +138,7 @@ export function useReceipts(query, props) {
|
||||
export function useReceipt(id, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
['SALE_RECEIPT', id],
|
||||
() => apiRequest.get(`sales/receipts/${id}`),
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useQuery, useMutation, useQueryClient } from 'react-query';
|
||||
import { useMutation, useQueryClient } from 'react-query';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import useApiRequest from '../useRequest';
|
||||
import t from 'store/types';
|
||||
@@ -23,7 +24,7 @@ function useSettingsQuery(key, query, props) {
|
||||
const dispatch = useDispatch();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const state = useQuery(
|
||||
const state = useQueryTenant(
|
||||
key,
|
||||
() => apiRequest.get('settings', { params: query }),
|
||||
{
|
||||
|
||||
@@ -89,6 +89,10 @@ const SETTING = {
|
||||
SETTING_MANUAL_JOURNALS: 'SETTING_MANUAL_JOURNALS',
|
||||
};
|
||||
|
||||
const ORGANIZATIONS = {
|
||||
ORGANIZATIONS: 'ORGANIZATIONS'
|
||||
};
|
||||
|
||||
export default {
|
||||
...ACCOUNTS,
|
||||
...BILLS,
|
||||
@@ -104,5 +108,6 @@ export default {
|
||||
...PAYMENT_RECEIVES,
|
||||
...SALE_INVOICES,
|
||||
...USERS,
|
||||
...SETTING
|
||||
...SETTING,
|
||||
...ORGANIZATIONS,
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useMutation, useQueryClient, useQuery } from 'react-query';
|
||||
import { useMutation, useQueryClient } from 'react-query';
|
||||
import { defaultTo } from 'lodash';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
import useApiRequest from '../useRequest';
|
||||
import t from './types';
|
||||
|
||||
@@ -26,7 +27,6 @@ export function useCreateInviteUser(props) {
|
||||
|
||||
/**
|
||||
* Edits the given user.
|
||||
*
|
||||
*/
|
||||
export function useEditUser(props) {
|
||||
const queryClient = useQueryClient();
|
||||
@@ -67,7 +67,7 @@ export function useDeleteUser(props) {
|
||||
export function useUsers(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const result = useQuery(
|
||||
const result = useQueryTenant(
|
||||
[t.USERS],
|
||||
() => apiRequest.get(`USERS`).then((response) => response.data.users),
|
||||
props,
|
||||
@@ -85,7 +85,7 @@ export function useUsers(props) {
|
||||
export function useUser(id, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
['USER', id],
|
||||
() => apiRequest.get(`users/${id}`).then((response) => response.data.item),
|
||||
props,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
||||
import { useMutation, useQueryClient } from 'react-query';
|
||||
import t from './types';
|
||||
import { transformPagination } from 'utils';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
|
||||
// Common invalidate queries.
|
||||
const commonInvalidateQueries = (queryClient) => {
|
||||
@@ -22,7 +23,7 @@ const commonInvalidateQueries = (queryClient) => {
|
||||
export function useVendors(query, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
[t.VENDORS, query],
|
||||
() => apiRequest.get(`vendors`, { params: query }),
|
||||
{
|
||||
@@ -107,7 +108,7 @@ export function useCreateVendor(props) {
|
||||
export function useVendor(id, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery([t.VENDOR, id], () => apiRequest.get(`vendors/${id}`), {
|
||||
return useQueryTenant([t.VENDOR, id], () => apiRequest.get(`vendors/${id}`), {
|
||||
select: (res) => res.data.vendor,
|
||||
initialDataUpdatedAt: 0,
|
||||
initialData: {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { useQuery } from 'react-query';
|
||||
import { defaultTo } from 'lodash';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { useQueryTenant } from '../useQueryTenant';
|
||||
|
||||
export function useResourceViews(resourceSlug) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
['RESOURCE_VIEW', resourceSlug],
|
||||
() => apiRequest.get(`views/resource/${resourceSlug}`)
|
||||
.then((response) => response.data.views),
|
||||
@@ -17,11 +17,10 @@ export function useResourceViews(resourceSlug) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function useResourceColumns(resourceSlug) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
return useQueryTenant(
|
||||
['RESOURCE_COLUMNS', resourceSlug],
|
||||
() => apiRequest.get(`resources/${resourceSlug}/columns`),
|
||||
{
|
||||
@@ -33,7 +32,7 @@ export function useResourceColumns(resourceSlug) {
|
||||
export function useResourceFields(resourceSlug, props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
const states = useQuery(
|
||||
const states = useQueryTenant(
|
||||
['RESOURCE_FIELDS', resourceSlug],
|
||||
() => apiRequest.get(`resources/${resourceSlug}/fields`)
|
||||
.then((res) => res.data.resource_fields),
|
||||
|
||||
Reference in New Issue
Block a user