From c6a7b91097c06cef6067f0d5198a85c19a2fceb5 Mon Sep 17 00:00:00 2001 From: Reza_ashrafi Date: Thu, 17 Mar 2022 11:33:17 +0330 Subject: [PATCH] reza fixed mobile products bug --- src/components/Select/index.js | 2 +- src/redux/reducers/book.js | 18 ++++--- src/redux/reducers/public.js | 47 +++++++++++++------ .../layouts/Mobile/ProfileAddress/index.js | 6 ++- src/views/Products/layouts/Mobile/Header.js | 17 +++++-- src/views/Products/layouts/Mobile/Main.js | 8 ++-- 6 files changed, 65 insertions(+), 33 deletions(-) diff --git a/src/components/Select/index.js b/src/components/Select/index.js index 55a2d31..a251b81 100644 --- a/src/components/Select/index.js +++ b/src/components/Select/index.js @@ -22,7 +22,7 @@ function Select({ defaultValue={defaultValue} > {options.map((option, index) => ( - ))} diff --git a/src/redux/reducers/book.js b/src/redux/reducers/book.js index edaa0f5..5e072f6 100644 --- a/src/redux/reducers/book.js +++ b/src/redux/reducers/book.js @@ -16,19 +16,23 @@ const initialState = { sortFilterCourse: null, selectedGrade: null, selectedSort: "پربازدید ترین ها", - productTypes: [ - "کتاب فیزیکی", - "کتاب دیجیتال", - "دوره ویدئویی", - "بسته های آموزشی", - ], + productTypes: + window.innerWidth >= 1024 + ? ["کتاب فیزیکی", "کتاب دیجیتال", "دوره ویدئویی", "بسته های آموزشی"] + : [ + "نوع محصول", + "کتاب فیزیکی", + "کتاب دیجیتال", + "دوره ویدئویی", + "بسته های آموزشی", + ], filterOptions: { grade: "", subject: "", productType: null, available: false, sort: null, - search : "", + search: "", }, }; diff --git a/src/redux/reducers/public.js b/src/redux/reducers/public.js index 67dd372..1a4f644 100644 --- a/src/redux/reducers/public.js +++ b/src/redux/reducers/public.js @@ -41,21 +41,38 @@ const initialState = { activeCategory: null, categories: null, bookSection: null, - grades: { - 0: "پیش دبستان", - 1: "اول", - 2: "دوم", - 3: "سوم", - 4: "چهارم", - 5: "پنجم", - 6: "ششم", - 7: "هفتم", - 8: "هشتم", - 9: "نهم", - 10: "دهم", - 11: "یازدهم", - 12: "دوازدهم", - }, + grades: + window.innerWidth >= 1024 + ? { + 0: "پیش دبستان", + 1: "اول", + 2: "دوم", + 3: "سوم", + 4: "چهارم", + 5: "پنجم", + 6: "ششم", + 7: "هفتم", + 8: "هشتم", + 9: "نهم", + 10: "دهم", + 11: "یازدهم", + 12: "دوازدهم", + } + : { + 0: "پایه تحصیلی", + 1: "اول", + 2: "دوم", + 3: "سوم", + 4: "چهارم", + 5: "پنجم", + 6: "ششم", + 7: "هفتم", + 8: "هشتم", + 9: "نهم", + 10: "دهم", + 11: "یازدهم", + 12: "دوازدهم", + }, headerOptions: { shown: false, logo: false, diff --git a/src/views/Dashboard/layouts/Mobile/ProfileAddress/index.js b/src/views/Dashboard/layouts/Mobile/ProfileAddress/index.js index 981e16c..79a5cda 100644 --- a/src/views/Dashboard/layouts/Mobile/ProfileAddress/index.js +++ b/src/views/Dashboard/layouts/Mobile/ProfileAddress/index.js @@ -1,6 +1,6 @@ import React from "react"; import { connect } from "react-redux"; -import { userAddress, userFactor } from "../../../../../redux/actions"; +import { userAddress, userFactor, publicApi } from "../../../../../redux/actions"; import { Link, useNavigate } from "react-router-dom"; //components @@ -19,6 +19,8 @@ const ProfileAddress = ({ closeBottomSheet, mobile, isDark, + headerOptions, + setHeaderOptions }) => { const navigation = useNavigate(); const Location = ({ address, active }) => { @@ -97,6 +99,7 @@ const ProfileAddress = ({ }; React.useEffect(() => { + setHeaderOptions(headerOptions); getFactorInfo({ userId }); getList(); }, []); @@ -140,6 +143,7 @@ const mapDispatchToProps = { getFactorInfo: userFactor.info, update: userFactor.update, getList: userAddress.list, + setHeaderOptions: publicApi.setHeaderOptions, }; export default connect(mapStateToProps, mapDispatchToProps)(ProfileAddress); diff --git a/src/views/Products/layouts/Mobile/Header.js b/src/views/Products/layouts/Mobile/Header.js index 95e71aa..84bfb38 100644 --- a/src/views/Products/layouts/Mobile/Header.js +++ b/src/views/Products/layouts/Mobile/Header.js @@ -13,10 +13,13 @@ export const Header = ({ filterOptions, levels, productTypes, - isDark + isDark, }) => { return ( -
+
- setFilterOptions({ ...filterOptions, [name]: value }) + value === "نوع محصول" + ? setFilterOptions({ ...filterOptions, [name]: null }) + : setFilterOptions({ ...filterOptions, [name]: value }) } name="productType" options={productTypes} @@ -45,7 +50,9 @@ export const Header = ({ borderColor="border-grayDB dark:border-gray45" backgroundColor="bg-gray-100" onChange={(name, value) => - setFilterOptions({ ...filterOptions, [name]: value }) + value === "پایه تحصیلی" + ? setFilterOptions({ ...filterOptions, [name]: null }) + : setFilterOptions({ ...filterOptions, [name]: value }) } name="grade" options={Object.values(levels)} @@ -59,7 +66,7 @@ const mapStateToProps = (state) => ({ levels: state.publicApi.grades, productTypes: state.book.productTypes, filterOptions: state.book.filterOptions, - isDark: state.publicApi.isDark + isDark: state.publicApi.isDark, }); const mapDispatchToProps = { diff --git a/src/views/Products/layouts/Mobile/Main.js b/src/views/Products/layouts/Mobile/Main.js index 2470aa2..4186fe1 100644 --- a/src/views/Products/layouts/Mobile/Main.js +++ b/src/views/Products/layouts/Mobile/Main.js @@ -88,17 +88,17 @@ export const Main = ({ books, filterOptions, grades }) => { )) - : bySearchFilter?.map((product, index) => ( + : bySearchFilter?.map((product) => ( <> {(productType ? productType === "کتاب دیجیتال" : true) && ( {"کتاب دیجیتال" + " " + product?.name} @@ -113,7 +113,7 @@ export const Main = ({ books, filterOptions, grades }) => { )} {(productType ? productType === "کتاب فیزیکی" : true) && (