|
|
@ -1,6 +1,5 @@ |
|
|
|
import React, { Component } from "react"; |
|
|
|
import React, { Component } from "react"; |
|
|
|
import FilterListIcon from "@material-ui/icons/FilterList"; |
|
|
|
import FilterListIcon from "@material-ui/icons/FilterList"; |
|
|
|
import Loader from "~/components/Loader/index"; |
|
|
|
|
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { book } from "~/Redux/actions"; |
|
|
|
import { book } from "~/Redux/actions"; |
|
|
|
|
|
|
|
|
|
|
@ -27,11 +26,11 @@ const fontSize = { |
|
|
|
|
|
|
|
|
|
|
|
class Products extends Component { |
|
|
|
class Products extends Component { |
|
|
|
state = { |
|
|
|
state = { |
|
|
|
selectedSort: null, |
|
|
|
|
|
|
|
search: null, |
|
|
|
search: null, |
|
|
|
selectedFilters: { |
|
|
|
selectedFilters: { |
|
|
|
level: [], |
|
|
|
level: [], |
|
|
|
subject: [], |
|
|
|
subject: [], |
|
|
|
|
|
|
|
sort: null, |
|
|
|
}, |
|
|
|
}, |
|
|
|
firstFilters: [ |
|
|
|
firstFilters: [ |
|
|
|
{ id: 0, value: "محبوب ترین" }, |
|
|
|
{ id: 0, value: "محبوب ترین" }, |
|
|
@ -53,10 +52,6 @@ class Products extends Component { |
|
|
|
degree: "", |
|
|
|
degree: "", |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
componentDidMount() { |
|
|
|
|
|
|
|
this.props.getList(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handleProductSearch = (val) => { |
|
|
|
handleProductSearch = (val) => { |
|
|
|
this.setState({ |
|
|
|
this.setState({ |
|
|
|
search: val, |
|
|
|
search: val, |
|
|
@ -64,99 +59,74 @@ class Products extends Component { |
|
|
|
this.props.searchBook(val); |
|
|
|
this.props.searchBook(val); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps, prevState) { |
|
|
|
|
|
|
|
if (prevState.selectedFilters !== this.state.selectedFilters) { |
|
|
|
|
|
|
|
this.props.filterBook(this.state.selectedFilters); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
componentDidMount() { |
|
|
|
|
|
|
|
localStorage.removeItem("filter"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
render() { |
|
|
|
const { dateFilters, degreeFilters, firstFilters } = this.state; |
|
|
|
const { dateFilters, degreeFilters, firstFilters } = this.state; |
|
|
|
const { loading, list, page } = this.props; |
|
|
|
const { loading, list, page } = this.props; |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<> |
|
|
|
{window.innerWidth > 1000 ? ( |
|
|
|
{window.innerWidth > 1000 ? ( |
|
|
|
list ? ( |
|
|
|
<> |
|
|
|
<> |
|
|
|
<div className="products d-flex flex-column"> |
|
|
|
<div className="products d-flex flex-column"> |
|
|
|
<Navbar page={"products"} /> |
|
|
|
<Navbar page={"products"} /> |
|
|
|
<Breadcrumbs /> |
|
|
|
<Breadcrumbs /> |
|
|
|
<div className="products__body d-flex"> |
|
|
|
<div className="products__body d-flex"> |
|
|
|
<Filters parent={this} /> |
|
|
|
<Filters parent={this} /> |
|
|
|
<div className="products__body--left d-flex flex-column"> |
|
|
|
<div className="products__body--left d-flex flex-column"> |
|
|
|
<Sort |
|
|
|
<Sort |
|
|
|
parent={this} |
|
|
|
parent={this} |
|
|
|
selectedSort={this.state.selectedFilters.sort} |
|
|
|
selectedSort={this.state.selectedSort} |
|
|
|
/> |
|
|
|
/> |
|
|
|
<List /> |
|
|
|
<List parent={this} /> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<Footer /> |
|
|
|
|
|
|
|
</> |
|
|
|
|
|
|
|
) : ( |
|
|
|
|
|
|
|
<div |
|
|
|
|
|
|
|
className="d-flex justify-content-center align-items-center" |
|
|
|
|
|
|
|
style={{ height: "100vh", width: "100vw" }} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Loader /> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) |
|
|
|
<Footer /> |
|
|
|
|
|
|
|
</> |
|
|
|
) : null} |
|
|
|
) : null} |
|
|
|
{window.innerWidth < 1000 ? ( |
|
|
|
{window.innerWidth < 1000 ? ( |
|
|
|
list ? ( |
|
|
|
<> |
|
|
|
<> |
|
|
|
<div className="mobile-products d-flex flex-column"> |
|
|
|
<div className="mobile-products d-flex flex-column"> |
|
|
|
<Navbar page={"products"} /> |
|
|
|
<Navbar page={"products"} /> |
|
|
|
<div className="mobile-products__search d-flex"> |
|
|
|
<div className="mobile-products__search d-flex"> |
|
|
|
<input |
|
|
|
<input |
|
|
|
type="search" |
|
|
|
type="search" |
|
|
|
style={{ fontSize: fontSize.mobile.input }} |
|
|
|
style={{ fontSize: fontSize.mobile.input }} |
|
|
|
placeholder={"جستجو"} |
|
|
|
placeholder={"جستجو"} |
|
|
|
onChange={(e) => this.handleProductSearch(e.target.value)} |
|
|
|
onChange={(e) => this.handleProductSearch(e.target.value)} |
|
|
|
/> |
|
|
|
/> |
|
|
|
<img src={navbarSearch} alt="جستجو" /> |
|
|
|
<img src={navbarSearch} alt="جستجو" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className="mobile-products__filters d-flex"> |
|
|
|
<div className="mobile-products__filters d-flex"> |
|
|
|
<div className="d-flex"> |
|
|
|
<div className="d-flex"> |
|
|
|
<Select name="first" options={firstFilters} parent={this} /> |
|
|
|
<Select name="first" options={firstFilters} parent={this} /> |
|
|
|
<Select name="date" options={dateFilters} parent={this} /> |
|
|
|
<Select name="date" options={dateFilters} parent={this} /> |
|
|
|
<Select name="degree" options={degreeFilters} parent={this} /> |
|
|
|
<Select |
|
|
|
|
|
|
|
name="degree" |
|
|
|
|
|
|
|
options={degreeFilters} |
|
|
|
|
|
|
|
parent={this} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<FilterListIcon style={{ fontSize: 40, color: "#a5a5a5" }} /> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<div className="mobile-products__list d-flex flex-wrap"> |
|
|
|
|
|
|
|
{this.state.search |
|
|
|
|
|
|
|
? this.props.searchResult.map((item, i) => ( |
|
|
|
|
|
|
|
<Product product={item} key={i} id={i} /> |
|
|
|
|
|
|
|
)) |
|
|
|
|
|
|
|
: list.map((item, i) => ( |
|
|
|
|
|
|
|
<Product product={item} key={i} id={i} /> |
|
|
|
|
|
|
|
))} |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<FilterListIcon style={{ fontSize: 40, color: "#a5a5a5" }} /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</> |
|
|
|
<List search={this.state.search} /> |
|
|
|
) : ( |
|
|
|
|
|
|
|
<div |
|
|
|
|
|
|
|
className="d-flex justify-content-center align-items-center" |
|
|
|
|
|
|
|
style={{ height: "100vh", width: "100vw" }} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Loader /> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) |
|
|
|
</> |
|
|
|
) : null} |
|
|
|
) : null} |
|
|
|
</> |
|
|
|
</> |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export default connect( |
|
|
|
export default connect((state) => ({}), { |
|
|
|
(state) => ({ |
|
|
|
searchBook: book.searchBook, |
|
|
|
list: state.book.list, |
|
|
|
filterBook: book.filterBook, |
|
|
|
searchResult: state.book.searchResult, |
|
|
|
})(Products); |
|
|
|
loading: state.book.loading, |
|
|
|
|
|
|
|
// status: state.user.status,
|
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
{ getList: book.list, searchBook: book.searchBook } |
|
|
|
|
|
|
|
)(Products); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Products.defaultProps = { |
|
|
|
Products.defaultProps = { |
|
|
|
sortItems: [ |
|
|
|
sortItems: [ |
|
|
|