refactoring: sales tables.

refacoring: purchases tables.
This commit is contained in:
a.bouhuolia
2021-02-11 20:45:06 +02:00
parent 3901c336df
commit d48532a7e6
210 changed files with 2799 additions and 5392 deletions

View File

@@ -1,25 +1,37 @@
import { useMutation, useQuery, useQueryClient } from 'react-query';
import { defaultTo } from 'lodash';
import ApiService from 'services/ApiService';
const transformPaymentReceives = (response) => {
return {};
};
import { transformPagination } from 'utils';
/**
* Retrieve accounts list.
*/
export function usePaymentReceives(query, props) {
return useQuery(
const states = useQuery(
['PAYMENT_RECEIVES', query],
() =>
ApiService.get('sales/payment_receives', { params: query }).then(
transformPaymentReceives,
),
() => ApiService.get('sales/payment_receives', { params: query }),
{
initialData: [],
select: (res) => ({
paymentReceives: res.data.payment_receives,
pagination: transformPagination(res.data.pagination),
filterMeta: res.data.filter_meta,
}),
...props,
},
);
return {
...states,
data: defaultTo(states.data, {
paymentReceives: [],
pagination: {
page: 1,
pageSize: 12,
total: 0,
},
filterMeta: {},
}),
}
}
/**
@@ -77,15 +89,14 @@ export function useDeletePaymentReceive(props) {
* Retrieve specific payment receive.
*/
export function usePaymentReceive(id, props) {
return useQuery(
const states = useQuery(
['PAYMENT_RECEIVE', id],
() =>
ApiService.get(`sales/payment_receives/${id}`).then(
transformPaymentReceives,
),
{
initialData: [],
...props,
},
() => ApiService.get(`sales/payment_receives/${id}`),
props,
);
return {
...states,
data: defaultTo(states.data, {}),
}
}