|
|
@ -11,7 +11,7 @@ import searchLight from "../../assets/icons/search-light.svg"; |
|
|
|
const Product = ({ productsType, product, index, grades }) => { |
|
|
|
const Product = ({ productsType, product, index, grades }) => { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<> |
|
|
|
{productsType === "book" && ( |
|
|
|
{productsType === "کتاب" && ( |
|
|
|
<Link |
|
|
|
<Link |
|
|
|
to={"/products" + product?.name} |
|
|
|
to={"/products" + product?.name} |
|
|
|
className={`w-1/2 flex flex-col border-t border-grayDB dark:border-gray45 p-3 border-solid ${ |
|
|
|
className={`w-1/2 flex flex-col border-t border-grayDB dark:border-gray45 p-3 border-solid ${ |
|
|
@ -22,13 +22,33 @@ const Product = ({ productsType, product, index, grades }) => { |
|
|
|
src={"https://dnvn.ir/api/v1/file/" + product?.fileIds} |
|
|
|
src={"https://dnvn.ir/api/v1/file/" + product?.fileIds} |
|
|
|
className="w-full rounded-md mb-2" |
|
|
|
className="w-full rounded-md mb-2" |
|
|
|
/> |
|
|
|
/> |
|
|
|
<strong className="text-blue5F dark:text-white text-md font-bold mb-1"> |
|
|
|
<strong className="text-blue5F dark:text-white text-sm font-bold mb-1"> |
|
|
|
{product?.name} |
|
|
|
{product?.name} |
|
|
|
</strong> |
|
|
|
</strong> |
|
|
|
<span className="text-xs text-blueC0 dark:text-white font-light mb-4"> |
|
|
|
<span className="text-xs text-blueC0 dark:text-white font-light mb-4"> |
|
|
|
{"پایه" + " " + grades[product?.gradeId]} |
|
|
|
{"پایه" + " " + grades[product?.gradeId]} |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
<div className="w-full flex flex-row justify-center font-semibold text-md text-blue5F dark:text-white"> |
|
|
|
<div className="w-full flex flex-row justify-center font-medium text-sm text-blue5F dark:text-white"> |
|
|
|
|
|
|
|
{1399 + " " + "تومان"} |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</Link> |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
{productsType === "ویديو" && ( |
|
|
|
|
|
|
|
<Link |
|
|
|
|
|
|
|
to={"/products" + product?.name} |
|
|
|
|
|
|
|
className={`w-full flex flex-col border-grayDB dark:border-gray45 p-3 border-solid mb-2 shadow-md`} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<img |
|
|
|
|
|
|
|
src={"https://dnvn.ir/api/v1/file/" + product?.fileIds} |
|
|
|
|
|
|
|
className="w-full rounded-md mb-2" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
<strong className="text-blue5F dark:text-white text-sm font-bold mb-1"> |
|
|
|
|
|
|
|
{product?.name} |
|
|
|
|
|
|
|
</strong> |
|
|
|
|
|
|
|
<span className="text-xs text-blueC0 dark:text-white font-light mb-4"> |
|
|
|
|
|
|
|
{"پایه" + " " + grades[product?.gradeId]} |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
<div className="w-full flex flex-row justify-center font-medium text-sm text-blue5F dark:text-white"> |
|
|
|
{1399 + " " + "تومان"} |
|
|
|
{1399 + " " + "تومان"} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</Link> |
|
|
|
</Link> |
|
|
@ -37,11 +57,19 @@ const Product = ({ productsType, product, index, grades }) => { |
|
|
|
); |
|
|
|
); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export const Products = ({ isDark, books, getList, grades }) => { |
|
|
|
export const Products = ({ |
|
|
|
|
|
|
|
isDark, |
|
|
|
|
|
|
|
books, |
|
|
|
|
|
|
|
getList, |
|
|
|
|
|
|
|
grades, |
|
|
|
|
|
|
|
gradeFilter, |
|
|
|
|
|
|
|
selectedGrade, |
|
|
|
|
|
|
|
gradeFilterBooks, |
|
|
|
|
|
|
|
}) => { |
|
|
|
const [filter, setFilter] = useState({ |
|
|
|
const [filter, setFilter] = useState({ |
|
|
|
search: "", |
|
|
|
search: "", |
|
|
|
grade: "", |
|
|
|
grade: "", |
|
|
|
productsType: "book", |
|
|
|
productsType: "کتاب", |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const onChange = (name, value) => { |
|
|
|
const onChange = (name, value) => { |
|
|
@ -51,13 +79,17 @@ export const Products = ({ isDark, books, getList, grades }) => { |
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
getList(); |
|
|
|
getList(); |
|
|
|
}, []); |
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
gradeFilter(filter.grade); |
|
|
|
|
|
|
|
}, [filter]); |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<> |
|
|
|
{/* Portrait */} |
|
|
|
{/* Portrait */} |
|
|
|
<div className="w-full flex flex-col bg-transparent pt-20"> |
|
|
|
<div className="w-full flex flex-col bg-transparent"> |
|
|
|
<header className="w-full px-4"> |
|
|
|
<header className="w-full px-4"> |
|
|
|
<Search |
|
|
|
<Search |
|
|
|
backgroundColor="bg-grayF9 dark:bg-gray36" |
|
|
|
backgroundColor="bg-grayF9 dark:bg-gray2077" |
|
|
|
borderColor="border-grayDB dark:border-gray45" |
|
|
|
borderColor="border-grayDB dark:border-gray45" |
|
|
|
textColor="text-blueC0 dark:text-white" |
|
|
|
textColor="text-blueC0 dark:text-white" |
|
|
|
icon={searchLight} |
|
|
|
icon={searchLight} |
|
|
@ -67,7 +99,7 @@ export const Products = ({ isDark, books, getList, grades }) => { |
|
|
|
margin="ml-1" |
|
|
|
margin="ml-1" |
|
|
|
fill="fill-blueC0 dark:fill-white" |
|
|
|
fill="fill-blueC0 dark:fill-white" |
|
|
|
borderColor="border-grayDB dark:border-gray45" |
|
|
|
borderColor="border-grayDB dark:border-gray45" |
|
|
|
backgroundColor="bg-grayF9 dark:bg-gray36" |
|
|
|
backgroundColor="bg-grayF9 dark:bg-gray2077" |
|
|
|
onChange={onChange} |
|
|
|
onChange={onChange} |
|
|
|
name="productsType" |
|
|
|
name="productsType" |
|
|
|
options={["کتاب", "ویديو", "اشتراک"]} |
|
|
|
options={["کتاب", "ویديو", "اشتراک"]} |
|
|
@ -77,7 +109,7 @@ export const Products = ({ isDark, books, getList, grades }) => { |
|
|
|
margin="mr-1" |
|
|
|
margin="mr-1" |
|
|
|
fill="fill-blueC0 dark:fill-white" |
|
|
|
fill="fill-blueC0 dark:fill-white" |
|
|
|
borderColor="border-grayDB dark:border-gray45" |
|
|
|
borderColor="border-grayDB dark:border-gray45" |
|
|
|
backgroundColor="bg-grayF9 dark:bg-gray36" |
|
|
|
backgroundColor="bg-grayF9 dark:bg-gray2077" |
|
|
|
onChange={onChange} |
|
|
|
onChange={onChange} |
|
|
|
name="grade" |
|
|
|
name="grade" |
|
|
|
options={Object.values(grades)} |
|
|
|
options={Object.values(grades)} |
|
|
@ -86,7 +118,17 @@ export const Products = ({ isDark, books, getList, grades }) => { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</header> |
|
|
|
</header> |
|
|
|
<div className="w-full flex flex-row flex-wrap mt-3"> |
|
|
|
<div className="w-full flex flex-row flex-wrap mt-3"> |
|
|
|
{books?.map((product, index) => ( |
|
|
|
{selectedGrade |
|
|
|
|
|
|
|
? gradeFilterBooks?.map((product, index) => ( |
|
|
|
|
|
|
|
<Product |
|
|
|
|
|
|
|
key={index} |
|
|
|
|
|
|
|
productsType={filter.productsType} |
|
|
|
|
|
|
|
product={product} |
|
|
|
|
|
|
|
index={Number(index)} |
|
|
|
|
|
|
|
grades={grades} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
)) |
|
|
|
|
|
|
|
: books?.map((product, index) => ( |
|
|
|
<Product |
|
|
|
<Product |
|
|
|
key={index} |
|
|
|
key={index} |
|
|
|
productsType={filter.productsType} |
|
|
|
productsType={filter.productsType} |
|
|
@ -105,8 +147,13 @@ const mapStateToProps = (state) => ({ |
|
|
|
isDark: state.publicApi.isDark, |
|
|
|
isDark: state.publicApi.isDark, |
|
|
|
books: state.book.list, |
|
|
|
books: state.book.list, |
|
|
|
grades: state.publicApi.grades, |
|
|
|
grades: state.publicApi.grades, |
|
|
|
|
|
|
|
gradeFilterBooks: state.book.gradeFilterBooks, |
|
|
|
|
|
|
|
selectedGrade: state.book.selectedGrade, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { getList: book.list }; |
|
|
|
const mapDispatchToProps = { |
|
|
|
|
|
|
|
getList: book.list, |
|
|
|
|
|
|
|
gradeFilter: book.gradeFilter, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Products); |
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Products); |
|
|
|