Files
old-new-wiaas/frontend/src/containers/coMarket/CoMarketNavContainer.jsx

53 lines
1.9 KiB
React
Raw Normal View History

2018-06-14 16:49:28 +02:00
import React, {Component} from 'react';
import {connect} from 'react-redux';
import {Row, Col, Input} from 'reactstrap';
2019-01-07 21:15:06 +01:00
import {searchShopPackages, fetchShopPackages} from '../../actions/coMarket/coMarketPackagesActions';
2018-06-14 16:49:28 +02:00
import {coMarketTexts} from '../../constants/coMarketConstants';
class CoMarketNavContainer extends Component {
constructor(props) {
super(props);
this.handleSearchChange = this.handleSearchChange.bind(this);
this.state = {
searchValue : ''
};
}
handleSearchChange(event) {
2019-01-07 21:15:06 +01:00
const s = event.target.value;
this.setState({searchValue: s});
if (this.props.selectedShop && s) {
this.props.dispatch(searchShopPackages(this.props.selectedShop, s));
} else if (this.props.selectedShop) {
this.props.dispatch(fetchShopPackages(this.props.selectedShop));
2018-10-15 05:06:46 +02:00
}
2018-06-14 16:49:28 +02:00
}
render() {
return (
<Row className="co-market-nav">
<Col className="col-auto co-market-nav-buttons">
2018-06-14 16:49:28 +02:00
<div className="co-market-nav-div">
{coMarketTexts.labels.NEW_PRODUCTS}
</div>
<div className="wiaas-divider"></div>
2018-06-14 16:49:28 +02:00
</Col>
<Col className="search-layer">
2018-06-14 16:49:28 +02:00
<div className="co-market-nav-div">
<i className="search-package-icon fa fa-search" aria-hidden="true"></i>
<Input className="wiaas-input" onChange={this.handleSearchChange} value={this.state.searchValue} placeholder={coMarketTexts.labels.SEARCH_PACKAGE}/>
</div>
</Col>
</Row>
);
}
}
const mapStateToProps = (state) => ({
2019-01-07 21:15:06 +01:00
selectedShop: state.coMarketPackagesReducer.selectedShop,
shopPage: state.coMarketPackagesReducer.shopPage,
2018-06-14 16:49:28 +02:00
});
export default connect(mapStateToProps)(CoMarketNavContainer);