fix bugs in items form.

This commit is contained in:
Ahmed Bouhuolia
2020-04-15 01:29:46 +02:00
parent 26faaddfed
commit cac6620ffe
20 changed files with 378 additions and 129 deletions

View File

@@ -10,8 +10,14 @@ export const editItem = ({ id, form }) => {
};
export const fetchItems = ({ query }) => {
return (dispatch) => new Promise((resolve, reject) => {
ApiService.get(`items`).then(response => {
return (dispatch, getState) => new Promise((resolve, reject) => {
const pageQuery = getState().accounts.tableQuery;
dispatch({
type: t.ITEMS_TABLE_LOADING,
payload: { loading: true },
});
ApiService.get(`items`, { params: { ...pageQuery, ...query } }).then(response => {
dispatch({
type: t.ITEMS_SET,
items: response.data.items.results,
@@ -22,6 +28,10 @@ export const fetchItems = ({ query }) => {
customViewId: response.data.customViewId,
paginationMeta: response.data.items.pagination,
});
dispatch({
type: t.ITEMS_TABLE_LOADING,
payload: { loading: false },
});
resolve(response);
}).catch(error => { reject(error); });
});