diff --git a/src/Redux/reducers/book.js b/src/Redux/reducers/book.js index f97bccf..ccb2049 100644 --- a/src/Redux/reducers/book.js +++ b/src/Redux/reducers/book.js @@ -5,14 +5,47 @@ const initialState = { info: null, searchResult: [], filterResult: [], + subjects: [], + levels: [], + sortFilters: ["مرتب سازی", "محبوب ترین", "جدیدترین"], }; + +const grades = [ + "اول", + "دوم", + "سوم", + "چهارم", + "پنجم", + "ششم", + "هفتم", + "هشتم", + "نهم", + "دهم", + "یازدهم", + "دوازدهم", +]; export default function book(state = initialState, action) { let { type, data } = action; switch (type) { case "book/list": - return { ...state, loading: false, list: data, error: null }; + let itemsSubject = data.map((item, index) => item.name); + if (window.innerWidth < 1000) { + itemsSubject.unshift("نام کتاب"); + } + let itemsLevel = data.map((item) => grades[item.gradeId]); + if (window.innerWidth < 1000) { + itemsLevel.unshift("پایه تحصیلی"); + } + return { + ...state, + loading: false, + list: data, + subjects: [...new Set(itemsSubject)], + levels: [...new Set(itemsLevel)], + error: null, + }; case "book/info": - return { ...state, loading: false, list: null, info: data, error: null }; + return { ...state, loading: false, info: data, error: null }; case "book/update": return { ...state, loading: false, error: null }; case "book/add": @@ -22,8 +55,7 @@ export default function book(state = initialState, action) { case "book/search": return { ...state }; case "book/filter": - const realList = - state.searchResult.length > 0 ? state.searchResult : state.list; + const realList = state.list; const level = data.level; const subject = data.subject; const sort = data.sort; @@ -32,21 +64,38 @@ export default function book(state = initialState, action) { localStorage.setItem("filter", "ON"); } let finalSort; - const byLevelFilter = - level.length > 0 - ? realList.filter( - (item) => item.name.indexOf(level.map((item) => item)) !== -1 - ) - : realList; - const bySubjectFilter = - subject.length > 0 - ? byLevelFilter.filter( - (item) => item.name.indexOf(subject.map((item) => item)) !== -1 - ) - : byLevelFilter; + let byLevelFilter = []; + if (level.length > 0) { + level.map((item1) => { + for (let i = 0; i < realList.length; i++) { + if (grades[realList[i].gradeId] === item1) { + byLevelFilter.push(realList[i]); + } + } + }); + } else { + byLevelFilter = realList; + } + + let bySubjectFilter = []; + if (subject.length > 0) { + subject.map((item1) => { + for (let i = 0; i < byLevelFilter.length; i++) { + if (byLevelFilter[i].name === item1) { + bySubjectFilter.push(byLevelFilter[i]); + } + } + }); + } else { + bySubjectFilter = byLevelFilter; + } + const bySearchFilter = search - ? bySubjectFilter.filter((item) => item.name.indexOf(search) !== -1) + ? bySubjectFilter.filter((item1) => item1.name.indexOf(search) !== -1) : bySubjectFilter; + + console.log(bySearchFilter); + if (sort === "گران ترین") { finalSort = bySearchFilter.sort((item1, item2) => { return item1.product[0].price - item2.product[0].price; diff --git a/src/views/Home/SingleBlog/index.js b/src/views/Home/SingleBlog/index.js index 7370f1c..d47ac2b 100644 --- a/src/views/Home/SingleBlog/index.js +++ b/src/views/Home/SingleBlog/index.js @@ -1,5 +1,7 @@ import React, { Component } from "react"; import { Link } from "react-router-dom"; +import VideoBox from "../../QR/VideoBox/index.js"; +import VoiceBox from "../../QR/VoiceBox/index.js"; import "./index.scss"; @@ -10,6 +12,11 @@ const fontSize = { h1: window.innerWidth > maxDesktopSize ? 28 : window.innerWidth / 45, p: window.innerWidth > maxDesktopSize ? 14 : window.innerWidth / 85, a: window.innerWidth > maxDesktopSize ? 16 : window.innerWidth / 70, + content: { + h1: window.innerWidth > maxDesktopSize ? 18 : window.innerWidth / 75, + p: window.innerWidth > maxDesktopSize ? 14 : window.innerWidth / 90, + h2: window.innerWidth > maxDesktopSize ? 14 : window.innerWidth / 90, + }, }, }; @@ -23,21 +30,37 @@ export default class SingleBlog extends Component {

{data.text}

بیشتر -
- {data.id ? ( - {data.title} - ) : null} +
+ {data.id ? : null} {data.video ?
); } } + +const Identifier = (props) => { + const { data } = props; + console.log(data); + return ( + <> + {data.type === "audio" ? ( + + ) : null} + {data.type === "video" ? ( + + ) : null} + {data.type === "image" ? ( + {data.fileIds} + ) : null} + + ); +}; diff --git a/src/views/Products/Product/index.js b/src/views/Products/Product/index.js index 030cec5..c08e9c2 100644 --- a/src/views/Products/Product/index.js +++ b/src/views/Products/Product/index.js @@ -40,22 +40,22 @@ export default class Product extends Component { - کتاب - {/* {!product.status.digital ? ( - افزودن به سبد خرید - ) : null} */} +

کتاب

+ + {product.product[1].price} تومان + - نسخه دیجیتال - {/* {!product.status.digital ? ( - افزودن به سبد خرید - ) : null} */} +

دیجیتال

+ + {product.product[0].price} تومان + diff --git a/src/views/Products/Product/index.scss b/src/views/Products/Product/index.scss index 76d9f3f..73e2ee6 100644 --- a/src/views/Products/Product/index.scss +++ b/src/views/Products/Product/index.scss @@ -57,6 +57,9 @@ } @media screen and (max-width: 350px) { .mobile-products-product { + h2 { + margin: 0px; + } width: 100%; background-color: #fafafa; margin: 20px; @@ -116,6 +119,9 @@ @media screen and (min-width: 350px) { .mobile-products-product { + h2 { + margin: 0px; + } width: calc(50% - 20px); background-color: #fafafa; margin: 10px; @@ -177,6 +183,9 @@ @media screen and (min-width: 550px) { .mobile-products-product { + h2 { + margin: 0px; + } width: calc(33% - 20px); background-color: #fafafa; margin: 10px; diff --git a/src/views/Products/Select/index.js b/src/views/Products/Select/index.js index 83edf16..49947b2 100644 --- a/src/views/Products/Select/index.js +++ b/src/views/Products/Select/index.js @@ -69,9 +69,9 @@ export default function CustomizedSelects(props) { } input={} > - {props.options.map((item) => ( - ))} diff --git a/src/views/Products/index.js b/src/views/Products/index.js index f12a305..a038586 100644 --- a/src/views/Products/index.js +++ b/src/views/Products/index.js @@ -32,27 +32,6 @@ class Products extends Component { subject: [], sort: null, }, - sortFilters: [ - { id: 0, value: "مرتب سازی" }, - { id: 1, value: "محبوب ترین" }, - { id: 2, value: "جدیدترین" }, - { id: 3, value: "ارزان ترین" }, - ], - subjectFilters: [ - { id: 0, value: "نام کتاب" }, - { id: 1, value: "ریاضی" }, - { id: 2, value: "شیمی" }, - { id: 3, value: "علوم" }, - ], - levelFilters: [ - { id: 0, value: "پایه تحصیلی" }, - { id: 1, value: "اول" }, - { id: 2, value: "دوم" }, - { id: 3, value: "سوم" }, - { id: 4, value: "چهارم" }, - { id: 5, value: "دهم" }, - { id: 6, value: "هفتم" }, - ], }; handleProductSearch = (val) => { @@ -79,7 +58,7 @@ class Products extends Component { } render() { - const { levelFilters, subjectFilters, sortFilters } = this.state; + const { sortFilters, levels, subjects } = this.props; return ( <> {window.innerWidth > 1000 ? ( @@ -88,7 +67,9 @@ class Products extends Component {
- + {this.props.subjects.length > 0 ? ( + + ) : null}
- +