|
|
|
@ -1,18 +1,17 @@ |
|
|
|
|
import React, { useState, useEffect, useCallback } from "react"; |
|
|
|
|
import ScrollContainer from "react-indiana-drag-scroll"; |
|
|
|
|
import { connect } from 'react-redux'; |
|
|
|
|
import { connect } from "react-redux"; |
|
|
|
|
import { Link } from "react-router-dom"; |
|
|
|
|
import filterIcon from '../../../assets/images/vuesax-linear-filter-tick.svg'; |
|
|
|
|
import { Carousel } from "@trendyol-js/react-carousel"; |
|
|
|
|
|
|
|
|
|
import Product from '../../../components/Product' |
|
|
|
|
import filterIcon from "../../../assets/images/vuesax-linear-filter-tick.svg"; |
|
|
|
|
import Product from "../../../components/Product"; |
|
|
|
|
import VodProduct from "../../../components/VodProduct"; |
|
|
|
|
import { book, publicApi } from "../../../redux/actions"; |
|
|
|
|
import posterImage from "../../../assets/images/poster.svg"; |
|
|
|
|
import arrow from "../../../assets/icons/slider-arrow.svg"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const Main = ({ isMobile, |
|
|
|
|
export const Main = ({ |
|
|
|
|
books, |
|
|
|
|
getList, |
|
|
|
|
grades, |
|
|
|
|
gradeFilter, |
|
|
|
|
selectedGrade, |
|
|
|
@ -20,28 +19,30 @@ export const Main = ({ isMobile, |
|
|
|
|
setHeaderOptions, |
|
|
|
|
headerOptions, |
|
|
|
|
videos, |
|
|
|
|
filter }) => { |
|
|
|
|
filter, |
|
|
|
|
}) => { |
|
|
|
|
useEffect(() => { |
|
|
|
|
window.scrollTo(0, 0) |
|
|
|
|
}, []) |
|
|
|
|
window.scrollTo(0, 0); |
|
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
const filteringNavItems = [ |
|
|
|
|
{ |
|
|
|
|
title: 'بیشترین بازدید' |
|
|
|
|
title: "بیشترین بازدید", |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: 'پرفروش ترین' |
|
|
|
|
title: "پرفروش ترین", |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: 'کمترین قیمت' |
|
|
|
|
title: "کمترین قیمت", |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: 'بیشترین قیمت' |
|
|
|
|
title: "بیشترین قیمت", |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: 'محبوب ترین' |
|
|
|
|
title: "محبوب ترین", |
|
|
|
|
}, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
const videosData = [ |
|
|
|
|
{ |
|
|
|
|
id: 0, |
|
|
|
@ -82,33 +83,51 @@ export const Main = ({ isMobile, |
|
|
|
|
grade: "پایه چهارم", |
|
|
|
|
imageUrl: "https://dnvn.ir/api/v1/file/2105", |
|
|
|
|
poster: posterImage, |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
return <div className="flex flex-col w-3/4 p-4"> |
|
|
|
|
}, |
|
|
|
|
]; |
|
|
|
|
return ( |
|
|
|
|
<div className="flex flex-col w-3/4 p-4 pb-20"> |
|
|
|
|
<div className="flex w-full bg-blue rounded-lg border border-solid border-gray-200 p-2 items-center my-1.5 justify-center text-blue52"> |
|
|
|
|
<div className='flex text-xs items-center mx-4'> |
|
|
|
|
<div className="flex text-xs items-center mx-4"> |
|
|
|
|
<img src={filterIcon} /> |
|
|
|
|
<span> |
|
|
|
|
مرتب سازی بر اساس |
|
|
|
|
</span> |
|
|
|
|
<span>مرتب سازی بر اساس</span> |
|
|
|
|
</div> |
|
|
|
|
<ul className='flex justify-between w-3/4 px-4 py-0 '> |
|
|
|
|
{ |
|
|
|
|
filteringNavItems.map(e => ( |
|
|
|
|
<li className='text-sm rounded py-2 px-6 transition-all duration-700 hover:bg-gray-300 hover:text-blueC0 cursor-pointer' onClick={() => console.log('a')}>{e.title}</li> |
|
|
|
|
)) |
|
|
|
|
} |
|
|
|
|
<ul className="flex justify-between w-3/4 px-4 py-0 "> |
|
|
|
|
{filteringNavItems.map((e) => ( |
|
|
|
|
<li |
|
|
|
|
className="text-sm rounded py-2 px-6 transition-all duration-700 hover:bg-gray-300 hover:text-blueC0 cursor-pointer" |
|
|
|
|
onClick={() => console.log("a")} |
|
|
|
|
> |
|
|
|
|
{e.title} |
|
|
|
|
</li> |
|
|
|
|
))} |
|
|
|
|
</ul> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<ScrollContainer className="flex"> |
|
|
|
|
{ |
|
|
|
|
videosData.map((video, index) => ( |
|
|
|
|
<Link |
|
|
|
|
to={"/videos/" + video.id} |
|
|
|
|
className="flex flex-col rounded-md ml-4 " |
|
|
|
|
|
|
|
|
|
<div className="relative w-full" style={{ direction: "ltr" }}> |
|
|
|
|
<Carousel |
|
|
|
|
show={Math.round(window.innerWidth / 500)} |
|
|
|
|
slide={2} |
|
|
|
|
swiping={true} |
|
|
|
|
useArrowKeys={true} |
|
|
|
|
transition={0.5} |
|
|
|
|
className="flex flex-row" |
|
|
|
|
rightArrow={ |
|
|
|
|
<img |
|
|
|
|
className="absolute top-1/2 transform -translate-y-1/2 cursor-pointer p-2" |
|
|
|
|
src={arrow} |
|
|
|
|
alt="" |
|
|
|
|
/> |
|
|
|
|
} |
|
|
|
|
leftArrow={ |
|
|
|
|
<img |
|
|
|
|
className="absolute top-1/2 transform -translate-y-1/2 -translate-x-5 cursor-pointer -rotate-180 p-2" |
|
|
|
|
src={arrow} |
|
|
|
|
alt="" |
|
|
|
|
/> |
|
|
|
|
} |
|
|
|
|
> |
|
|
|
|
{videosData.map((video, index) => ( |
|
|
|
|
<VodProduct |
|
|
|
|
productTitle={`دوره ی ویدیویی ${video.name}`} |
|
|
|
|
productCat={video.grade} |
|
|
|
@ -117,15 +136,13 @@ export const Main = ({ isMobile, |
|
|
|
|
discountPrice={false} |
|
|
|
|
key={index} |
|
|
|
|
index={index} |
|
|
|
|
minHeight={"250px"} |
|
|
|
|
height={"calc(100vh / 5)"} |
|
|
|
|
/> |
|
|
|
|
</Link> |
|
|
|
|
)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
</ScrollContainer> |
|
|
|
|
))} |
|
|
|
|
</Carousel> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<div className="w-full flex flex-row flex-wrap mt-0 border-t-2 border-solid border-gray-100 overflow-y-hidden justify-between"> |
|
|
|
|
<div className="w-full flex flex-row flex-wrap mt-0 border-t-2 border-solid border-gray-100 overflow-y-hidden justify-evenly"> |
|
|
|
|
{selectedGrade |
|
|
|
|
? gradeFilterBooks?.map((product, index) => ( |
|
|
|
|
<Product |
|
|
|
@ -139,51 +156,40 @@ export const Main = ({ isMobile, |
|
|
|
|
productPrice={100000} |
|
|
|
|
productImg={"https://dnvn.ir/api/v1/file/" + product?.fileIds} |
|
|
|
|
numberOfRegards={160} |
|
|
|
|
productTitleColor='text-blue5F' |
|
|
|
|
productCatTextColor='text-blueC0' |
|
|
|
|
productHolderBorder='' |
|
|
|
|
productHolderHoverBorder='shadow-md' |
|
|
|
|
productTitleColor="text-blue5F" |
|
|
|
|
productCatTextColor="text-blueC0" |
|
|
|
|
productHolderBorder="" |
|
|
|
|
productHolderHoverBorder="shadow-md" |
|
|
|
|
starRate={Math.floor(Math.random() * 5) + 1} |
|
|
|
|
imageSize={4.5} |
|
|
|
|
/> |
|
|
|
|
)) |
|
|
|
|
: books?.map((product, index) => ( |
|
|
|
|
<Link to={"/products/" + product?.id}> |
|
|
|
|
<Link |
|
|
|
|
to={"/products/" + product?.id} |
|
|
|
|
className="w-full lg:w-1/3 xl:w-1/4 2xl:w-1/5" |
|
|
|
|
> |
|
|
|
|
<Product |
|
|
|
|
key={index} |
|
|
|
|
productsType={filter.productsType} |
|
|
|
|
product={product} |
|
|
|
|
index={Number(index)} |
|
|
|
|
productName={`کتاب ${product?.name}`} |
|
|
|
|
productCat={`پایه ${grades[product?.gradeId]}`} |
|
|
|
|
productPrice={100000} |
|
|
|
|
productImg={"https://dnvn.ir/api/v1/file/" + product?.fileIds} |
|
|
|
|
numberOfRegards={160} |
|
|
|
|
productTitleColor='text-blue5F' |
|
|
|
|
productCatTextColor='text-blueC0' |
|
|
|
|
productHolderBorder='' |
|
|
|
|
productHolderHoverBorder='shadow-md' |
|
|
|
|
starRate={Math.floor(Math.random() * 5) + 2} |
|
|
|
|
imageSize={4.5} |
|
|
|
|
/> |
|
|
|
|
</Link> |
|
|
|
|
))} |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
</div>; |
|
|
|
|
</div> |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Main.defaultProps ={ |
|
|
|
|
videos: [ |
|
|
|
|
|
|
|
|
|
] |
|
|
|
|
} |
|
|
|
|
Main.defaultProps = { |
|
|
|
|
videos: [], |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
|
isDark: state.publicApi.isDark, |
|
|
|
|
isMobile: state.publicApi.isMobile, |
|
|
|
|
books: state.book.list, |
|
|
|
|
grades: state.publicApi.grades, |
|
|
|
|
gradeFilterBooks: state.book.gradeFilterBooks, |
|
|
|
|
selectedGrade: state.book.selectedGrade, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
|