From be2401b918cbcd517d40ec04c909e6486dfd4670 Mon Sep 17 00:00:00 2001 From: RezaAshrafi77 Date: Thu, 7 Oct 2021 21:42:43 +0330 Subject: [PATCH] reza completed home page api --- src/components/GradeFilter/index.tsx | 60 +++++----- src/components/HomeSearchBox/index.scss | 6 +- src/components/HomeSearchBox/index.tsx | 63 ++++++++-- src/custom.scss | 16 ++- src/redux/actions-type/book.tsx | 53 ++++++--- src/redux/actions-type/faq.tsx | 28 +++++ src/redux/actions-type/index.tsx | 4 + src/redux/actions-type/product.tsx | 33 ++++++ src/redux/actions/book.tsx | 5 +- src/redux/actions/content.tsx | 14 +++ src/redux/actions/faq.tsx | 18 +++ src/redux/actions/index.tsx | 6 + src/redux/actions/product.tsx | 27 +++++ src/redux/actions/user.tsx | 2 +- src/redux/actions/userFactor.tsx | 14 +++ src/redux/actions/userProduct.tsx | 10 ++ src/redux/reducers/book.tsx | 102 ++++++++++------ src/redux/reducers/faq.tsx | 35 ++++++ src/redux/reducers/index.tsx | 4 +- src/redux/reducers/product.tsx | 29 +++++ src/views/Auth/SignUp/index.tsx | 18 +-- src/views/Faq/index.tsx | 17 +-- src/views/Home/Books/Book/index.scss | 8 +- src/views/Home/Books/index.scss | 10 ++ src/views/Home/Books/index.tsx | 16 +-- src/views/Home/Courses/Course/index.scss | 8 +- src/views/Home/Courses/Course/index.tsx | 12 +- src/views/Home/Courses/index.scss | 11 ++ src/views/Home/Courses/index.tsx | 5 +- src/views/Home/index.tsx | 111 ++++++++++-------- .../Subscription/SubscribeRadio/index.tsx | 32 ++--- src/views/Subscription/index.tsx | 30 ++--- 32 files changed, 588 insertions(+), 219 deletions(-) create mode 100644 src/redux/actions-type/faq.tsx create mode 100644 src/redux/actions-type/product.tsx create mode 100644 src/redux/actions/content.tsx create mode 100644 src/redux/actions/faq.tsx create mode 100644 src/redux/actions/product.tsx create mode 100644 src/redux/actions/userFactor.tsx create mode 100644 src/redux/actions/userProduct.tsx create mode 100644 src/redux/reducers/faq.tsx create mode 100644 src/redux/reducers/product.tsx diff --git a/src/components/GradeFilter/index.tsx b/src/components/GradeFilter/index.tsx index 336408b..aa4d721 100644 --- a/src/components/GradeFilter/index.tsx +++ b/src/components/GradeFilter/index.tsx @@ -1,28 +1,31 @@ import React, { useState, useEffect } from "react"; +import { connect } from "react-redux"; +import { book } from "../../redux/actions"; import "./index.scss"; import dropdown from "../../assets/icons/dropdown.png"; -export default function GradeFilter(props: any) { +function GradeFilter({selectedGrade, gradeFilter, grades}: any) { const [arrowTop, setArrowTop] = useState(false); - const { grades, grade, setGrade } = props; useEffect(() => { setArrowTop(false); - },[grade]) + }, [selectedGrade]); return (

پایه تحصیلی - {window.innerWidth > 1007 ? : null} +

setArrowTop(!arrowTop)} > - { - grade ?

{grade}

: پایه تحصیلی خود را انتخاب نمائید - } + {selectedGrade ? ( +

{grades[selectedGrade - 1].name}

+ ) : ( + پایه تحصیلی خود را انتخاب نمائید + )} {arrowTop ? (
    - {grades.map((item: String, i: any) => ( + {grades.map((item: any, i: any) => (
  • - grade !== item ? setGrade(item) : setGrade(null) + onClick={() => + gradeFilter(item.value) } - className={grade === item ? "grade-filter__list--active" : ""} + className={selectedGrade === item.value ? "grade-filter__list--active" : ""} > - {item} + {item.name}
  • ))}
) : null} - {window.innerWidth > 1007 ? ( -
    - {grades.map((item: String, i: any) => ( -
  • - grade !== item ? setGrade(item) : setGrade(null) - } - className={grade === item ? "grade-filter__active" : ""} - > - {item} -
  • - ))} -
- ) : null} +
    + {grades.map((item: any, i: any) => ( +
  • gradeFilter(item.value)} + className={selectedGrade === item.value ? "grade-filter__active" : ""} + > + {item.name} +
  • + ))} +
); } + +export default connect( + (state: any) => ({ + selectedGrade: state.book.selectedGrade, + }), + { gradeFilter: book.gradeFilter } +)(GradeFilter); diff --git a/src/components/HomeSearchBox/index.scss b/src/components/HomeSearchBox/index.scss index a1be7fa..36d0f7c 100644 --- a/src/components/HomeSearchBox/index.scss +++ b/src/components/HomeSearchBox/index.scss @@ -103,6 +103,9 @@ &__voice { display: none; } + &__searchIcon{ + display: none; + } form { width: 85%; input { @@ -147,7 +150,8 @@ &__searchIcon { position: absolute; left: 62px; - top: 9px; + top: 50%; + transform: translateY(-50%); width: 27px; } form { diff --git a/src/components/HomeSearchBox/index.tsx b/src/components/HomeSearchBox/index.tsx index bd35dce..bd37704 100644 --- a/src/components/HomeSearchBox/index.tsx +++ b/src/components/HomeSearchBox/index.tsx @@ -1,25 +1,48 @@ import React, { useState } from "react"; import "./index.scss"; +import { connect } from "react-redux"; +import { book } from "../../redux/actions"; import search from "../../assets/icons/search.png"; import voice from "../../assets/icons/voice.png"; -export default function HomeSearchBox(props: any) { - const { lastItems, setVocal, inputValue, setInputValue } = props; +function HomeSearchBox({ + lastItems, + setVocal, + inputValue, + setInputValue, + sortFilter, + selectedSort, +}: any) { + const submitInput = (value: any) => { + setInputValue(value); + sortFilter({ search: value, sort: selectedSort }); + }; + + const submitSort = (value: any) => { + sortFilter({ search: inputValue, sort: value }); + }; return (
e.preventDefault()}> setInputValue(e.target.value)} + onChange={(e) => submitInput(e.target.value)} value={inputValue} /> - - {window.innerWidth < 640 ? ( - - ) : null} + + sortFilter({ search: inputValue, sort: selectedSort })} + /> + @@ -36,7 +36,9 @@ function Subscription({subscribes, selectedSubscribe} : any) { ); } -export default connect((state : any) => ({ - subscribes : state.publicApi.mockSubscribes, - selectedSubscribe : state.publicApi.selectedSubscribe -}), {})(Subscription); +export default connect( + (state: any) => ({ + listVOD: state.product.listVOD, + }), + { getList: product.listVOD } +)(Subscription);