fix bugs.

This commit is contained in:
Ahmed Bouhuolia
2020-04-29 05:11:02 +02:00
parent f4520e4e5c
commit f6c5cae82e
42 changed files with 575 additions and 401 deletions

View File

@@ -11,12 +11,15 @@ export const editItem = ({ id, form }) => {
export const fetchItems = ({ query }) => {
return (dispatch, getState) => new Promise((resolve, reject) => {
const pageQuery = getState().accounts.tableQuery;
const pageQuery = getState().items.tableQuery;
dispatch({
type: t.ITEMS_TABLE_LOADING,
payload: { loading: true },
});
dispatch({
type: t.SET_DASHBOARD_REQUEST_LOADING,
});
ApiService.get(`items`, { params: { ...pageQuery, ...query } }).then(response => {
dispatch({
type: t.ITEMS_SET,
@@ -32,8 +35,16 @@ export const fetchItems = ({ query }) => {
type: t.ITEMS_TABLE_LOADING,
payload: { loading: false },
});
dispatch({
type: t.SET_DASHBOARD_REQUEST_COMPLETED,
});
resolve(response);
}).catch(error => { reject(error); });
}).catch((error) => {
dispatch({
type: t.SET_DASHBOARD_REQUEST_COMPLETED,
});
reject(error);
});
});
};