|
|
|
@ -32,36 +32,45 @@ class Products extends Component { |
|
|
|
|
subject: [], |
|
|
|
|
sort: null, |
|
|
|
|
}, |
|
|
|
|
firstFilters: [ |
|
|
|
|
{ id: 0, value: "محبوب ترین" }, |
|
|
|
|
{ id: 1, value: "جدیدترین" }, |
|
|
|
|
{ id: 2, value: "ارزان ترین" }, |
|
|
|
|
sortFilters: [ |
|
|
|
|
{ id: 0, value: "مرتب سازی" }, |
|
|
|
|
{ id: 1, value: "محبوب ترین" }, |
|
|
|
|
{ id: 2, value: "جدیدترین" }, |
|
|
|
|
{ id: 3, value: "ارزان ترین" }, |
|
|
|
|
], |
|
|
|
|
dateFilters: [ |
|
|
|
|
{ id: 0, value: "1400" }, |
|
|
|
|
{ id: 1, value: "`1399" }, |
|
|
|
|
{ id: 2, value: "1398" }, |
|
|
|
|
subjectFilters: [ |
|
|
|
|
{ id: 0, value: "نام کتاب" }, |
|
|
|
|
{ id: 1, value: "ریاضی" }, |
|
|
|
|
{ id: 2, value: "شیمی" }, |
|
|
|
|
{ id: 3, value: "علوم" }, |
|
|
|
|
], |
|
|
|
|
degreeFilters: [ |
|
|
|
|
{ id: 0, value: "اول" }, |
|
|
|
|
{ id: 1, value: "دوم" }, |
|
|
|
|
{ id: 2, value: "سوم" }, |
|
|
|
|
levelFilters: [ |
|
|
|
|
{ id: 0, value: "پایه تحصیلی" }, |
|
|
|
|
{ id: 1, value: "اول" }, |
|
|
|
|
{ id: 2, value: "دوم" }, |
|
|
|
|
{ id: 3, value: "سوم" }, |
|
|
|
|
{ id: 4, value: "چهارم" }, |
|
|
|
|
{ id: 5, value: "دهم" }, |
|
|
|
|
{ id: 6, value: "هفتم" }, |
|
|
|
|
], |
|
|
|
|
first: "", |
|
|
|
|
date: "", |
|
|
|
|
degree: "", |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
handleProductSearch = (val) => { |
|
|
|
|
this.setState({ |
|
|
|
|
search: val, |
|
|
|
|
}); |
|
|
|
|
this.props.searchBook(val); |
|
|
|
|
// this.props.searchBook(val);
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps, prevState) { |
|
|
|
|
if (prevState.selectedFilters !== this.state.selectedFilters) { |
|
|
|
|
this.props.filterBook(this.state.selectedFilters); |
|
|
|
|
if ( |
|
|
|
|
prevState.selectedFilters !== this.state.selectedFilters || |
|
|
|
|
prevState.search !== this.state.search |
|
|
|
|
) { |
|
|
|
|
this.props.filterBook({ |
|
|
|
|
...this.state.selectedFilters, |
|
|
|
|
search: this.state.search, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -70,8 +79,7 @@ class Products extends Component { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
|
const { dateFilters, degreeFilters, firstFilters } = this.state; |
|
|
|
|
const { loading, list, page } = this.props; |
|
|
|
|
const { levelFilters, subjectFilters, sortFilters } = this.state; |
|
|
|
|
return ( |
|
|
|
|
<> |
|
|
|
|
{window.innerWidth > 1000 ? ( |
|
|
|
@ -108,9 +116,9 @@ class Products extends Component { |
|
|
|
|
</div> |
|
|
|
|
<div className="mobile-products__filters d-flex"> |
|
|
|
|
<div className="d-flex"> |
|
|
|
|
<Select name="first" options={firstFilters} parent={this} /> |
|
|
|
|
<Select name="date" options={dateFilters} parent={this} /> |
|
|
|
|
<Select name="degree" options={degreeFilters} parent={this} /> |
|
|
|
|
<Select name="sort" options={sortFilters} parent={this} /> |
|
|
|
|
<Select name="level" options={subjectFilters} parent={this} /> |
|
|
|
|
<Select name="subject" options={levelFilters} parent={this} /> |
|
|
|
|
</div> |
|
|
|
|
<FilterListIcon style={{ fontSize: 40, color: "#a5a5a5" }} /> |
|
|
|
|
</div> |
|
|
|
|