You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

56 lines
1.5 KiB

import React, { Component } from "react";
import { connect } from "react-redux";
import { publicApi } from "~/Redux/actions";
import Select from "./Select/index";
import dropdown from "../../../assets/icons/dropdown.png";
import "./index.scss";
class HomeSearch extends Component {
state = {
filters: {
levels: [],
search: null,
},
};
componentDidUpdate(prevProps, prevState) {
if (
prevState.filters.levels !== this.state.filters.levels ||
prevState.filters.search !== this.state.filters.search
) {
this.props.filterNewProducts(this.state.filters);
}
}
render() {
const { height, levels } = this.props;
return (
<div className="home-search d-flex">
<input
placeholder="جستجو در عناوین کتاب ..."
className="home-search__input d-flex"
type="text"
name="search"
onChange={(e) =>
this.setState({
filters: { ...this.state.filters, search: e.target.value },
})
}
/>
<div className="home-search__select">
<Select options={levels} name="levels" parent={this} />
<img src={dropdown} alt="فلش" />
</div>
<button className="home-search__submit">جستجو</button>
</div>
);
}
}
export default connect(
(state) => ({
levels: state.publicApi.levels,
}),
{ filterNewProducts: publicApi.filterNewProducts }
)(HomeSearch);