mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
WIP item categories.
This commit is contained in:
31
client/src/connectors/ItemsCategory.connect.js
Normal file
31
client/src/connectors/ItemsCategory.connect.js
Normal 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);
|
||||
Reference in New Issue
Block a user