55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import {
|
|
openDetail,
|
|
showNextItem,
|
|
showPrevItem,
|
|
toggleParticipated,
|
|
closeDetail
|
|
} from '../../redux/actions/ui';
|
|
import CIDetailView from './CIDetailView';
|
|
import { sendParticipation } from '../../redux/actions/participate';
|
|
|
|
const mapStateToProps = state => {
|
|
if (state.ui.activeItem === null) {
|
|
return {
|
|
catalog: state.catalog,
|
|
pending: state.ui.pending,
|
|
activeItem: null
|
|
};
|
|
}
|
|
|
|
let activeItemData = state.catalog[state.ui.activeItem];
|
|
if (activeItemData.inventory_number == undefined) {
|
|
activeItemData = state.catalog[state.ui.activeItem + 1];
|
|
}
|
|
|
|
const isFirst = state.ui.activeItem === 0;
|
|
const isLast = state.ui.activeItem === state.catalog.length - 1;
|
|
|
|
return {
|
|
activeItem: activeItemData,
|
|
isFirst,
|
|
isLast,
|
|
participated: state.ui.participated,
|
|
color: state.urls.color
|
|
};
|
|
};
|
|
|
|
const mapDispatchToProps = dispatch => {
|
|
return {
|
|
close: () => dispatch(closeDetail()),
|
|
openDetail: item => dispatch(openDetail(item)),
|
|
showNextItem: () => dispatch(showNextItem()),
|
|
showPrevItem: () => dispatch(showPrevItem()),
|
|
sendParticipation: data => dispatch(sendParticipation(data)),
|
|
toggleParticipated: () => dispatch(toggleParticipated())
|
|
};
|
|
};
|
|
|
|
const CIDetailViewContainer = connect(
|
|
mapStateToProps,
|
|
mapDispatchToProps
|
|
)(CIDetailView);
|
|
|
|
export default CIDetailViewContainer;
|