Fix: specific item api & customer api

This commit is contained in:
elforjani3
2020-10-22 18:05:24 +02:00
parent 274bd2ea48
commit 099fa63245
7 changed files with 52 additions and 18 deletions

View File

@@ -55,8 +55,12 @@ export const fetchItem = ({ id }) => {
.then((response) => {
dispatch({
type: t.ITEM_SET,
item: response.data.item,
payload: {
id,
item: response.data.item,
},
});
resolve(response);
})
.catch((error) => {
reject(error);

View File

@@ -27,6 +27,11 @@ const itemsReducer = createReducer(initialState, {
};
},
[t.ITEM_SET]: (state, action) => {
const { id, item } = action.payload;
state.items[id] = { ...item };
},
[t.ITEMS_PAGE_SET]: (state, action) => {
const { items, customViewId, paginationMeta } = action;
@@ -42,10 +47,10 @@ const itemsReducer = createReducer(initialState, {
state.itemsRelation[item.id] = [];
}
const filteredRelation = state.itemsRelation[item.id].filter(
(relation) => (
(relation) =>
relation.viewId === viewId &&
relation.pageNumber === paginationMeta.page
));
relation.pageNumber === paginationMeta.page,
);
filteredRelation.push({
viewId,

View File

@@ -1,7 +1,6 @@
export default {
ITEMS_SET: 'ITEMS_SET',
ITEM_SET: 'ITEM_SET',
ITEMS_PAGE_SET: 'ITEMS_PAGE_SET',
ITEM_DELETE: 'ITEM_DELETE',
ITEM_BULK_ACTION_ADD: 'ITEM_BULK_ACTION_ADD',
@@ -12,6 +11,5 @@ export default {
ITEMS_TABLE_LOADING: 'ITEMS_TABLE_LOADING',
ITEMS_SET_CURRENT_VIEW: 'ITEMS_SET_CURRENT_VIEW',
ITEMS_BULK_DELETE:'ITEMS_BULK_DELETE'
ITEMS_BULK_DELETE: 'ITEMS_BULK_DELETE',
};