WIP item categories.

This commit is contained in:
elforjani3
2020-04-04 19:32:05 +02:00
parent cf5f56ae32
commit cff8945889
15 changed files with 697 additions and 111 deletions

View File

@@ -0,0 +1,31 @@
import { connect } from 'react-redux';
import {
fetchItemCategories,
submitItemCategory,
deleteItemCategory,
editItemCategory
} from 'store/itemCategories/itemsCategory.actions';
import { getDialogPayload } from 'store/dashboard/dashboard.reducer';
import { getCategoryId } from 'store/itemCategories/itemsCategory.reducer';
export const mapStateToProps = (state, props) => {
const dialogPayload = getDialogPayload(state, 'item-form');
return {
categories: state.itemCategories.categories,
name: 'item-form',
payload: { action: 'new', id: null },
editItemCategory:
dialogPayload && dialogPayload.action === 'edit'
? state.itemCategories.categories[dialogPayload.id]
: {},
getCategoryId: id => getCategoryId(state, id)
};
};
export const mapDispatchToProps = dispatch => ({
requestSubmitItemCategory: form => dispatch(submitItemCategory({ form })),
requestFetchItemCategories: () => dispatch(fetchItemCategories()),
requestDeleteItemCategory: id => dispatch(deleteItemCategory(id)),
requestEditItemCategory: (id, form) => dispatch(editItemCategory(id, form))
});
export default connect(mapStateToProps, mapDispatchToProps);