import React, {Component} from 'react'; import {connect} from 'react-redux'; import {Row, Col, Input} from 'reactstrap'; import '../style/OrdersList.css'; import {setViewAllOrdersFlag} from '../../../actions/orders/ordersActions'; import {orderTexts} from '../../../constants/ordersConstants'; class OrderListHeader extends Component { constructor(props) { super(props); this.state = { isViewAllOrdersChecked: false }; this.handleInputChange = this.handleInputChange.bind(this); } componentDidMount() { const isViewAllChecked = {}; isViewAllChecked[this.props.params] = this.state.isViewAllOrdersChecked; this.props.dispatch(setViewAllOrdersFlag(isViewAllChecked)); } handleInputChange(e) { this.setState({ isViewAllOrdersChecked: !this.state.isViewAllOrdersChecked }); const isViewAllChecked = {}; isViewAllChecked[this.props.params] = e.target.checked; this.props.dispatch(setViewAllOrdersFlag(isViewAllChecked)); } render() { const {isCompanyAdmin} = this.props; return ( {isCompanyAdmin && {orderTexts.labels.VIEW_ALL_ORDERS} } ); } } const mapStateToProps = (state) => ({ isCompanyAdmin: state.auth.isCompanyAdmin }); export default connect(mapStateToProps)(OrderListHeader);