|
|
@ -1,7 +1,7 @@ |
|
|
|
import location from '../../utils/location'; |
|
|
|
import location from "../../utils/location"; |
|
|
|
|
|
|
|
|
|
|
|
const initialState = { |
|
|
|
const initialState = { |
|
|
|
theme : localStorage.getItem('theme') || 'light', |
|
|
|
theme: localStorage.getItem("theme") || "light", |
|
|
|
homeData: [], |
|
|
|
homeData: [], |
|
|
|
newProducts: [], |
|
|
|
newProducts: [], |
|
|
|
levels: [], |
|
|
|
levels: [], |
|
|
@ -35,6 +35,21 @@ const initialState = { |
|
|
|
activeCategory: null, |
|
|
|
activeCategory: null, |
|
|
|
categories: null, |
|
|
|
categories: null, |
|
|
|
bookSection: null, |
|
|
|
bookSection: null, |
|
|
|
|
|
|
|
grades: { |
|
|
|
|
|
|
|
0: "پیش دبستان", |
|
|
|
|
|
|
|
1: "اول", |
|
|
|
|
|
|
|
2: "دوم", |
|
|
|
|
|
|
|
3: "سوم", |
|
|
|
|
|
|
|
4: "چهارم", |
|
|
|
|
|
|
|
5: "پنجم", |
|
|
|
|
|
|
|
6: "ششم", |
|
|
|
|
|
|
|
7: "هفتم", |
|
|
|
|
|
|
|
8: "هشتم", |
|
|
|
|
|
|
|
9: "نهم", |
|
|
|
|
|
|
|
10: "دهم", |
|
|
|
|
|
|
|
11: "یازدهم", |
|
|
|
|
|
|
|
12: "دوازدهم", |
|
|
|
|
|
|
|
}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const grades = [ |
|
|
|
const grades = [ |
|
|
@ -57,7 +72,7 @@ export default function publicApi(state = initialState, action) { |
|
|
|
switch (type) { |
|
|
|
switch (type) { |
|
|
|
case "public/setTheme": |
|
|
|
case "public/setTheme": |
|
|
|
localStorage.setItem("theme", data); |
|
|
|
localStorage.setItem("theme", data); |
|
|
|
return { ...state, location: false, error : null, theme: data }; |
|
|
|
return { ...state, location: false, error: null, theme: data }; |
|
|
|
case "active/video": |
|
|
|
case "active/video": |
|
|
|
return { |
|
|
|
return { |
|
|
|
...state, |
|
|
|
...state, |
|
|
@ -79,15 +94,13 @@ export default function publicApi(state = initialState, action) { |
|
|
|
loading: false, |
|
|
|
loading: false, |
|
|
|
bookSection: data, |
|
|
|
bookSection: data, |
|
|
|
error: null, |
|
|
|
error: null, |
|
|
|
selectedVideo: data.vods?.filter((item) => item.id !== videoId)[0] |
|
|
|
selectedVideo: data.vods?.filter((item) => item.id !== videoId)[0], |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
case "public/vod/bookCourse": |
|
|
|
case "public/vod/bookCourse": |
|
|
|
let allCats; |
|
|
|
let allCats; |
|
|
|
allCats = Array.from( |
|
|
|
allCats = Array.from( |
|
|
|
new Set( |
|
|
|
new Set(data.vods.map((item) => item.categoryId && item.categoryId)) |
|
|
|
data.vods.map((item) => item.categoryId && item.categoryId) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
return { |
|
|
|
return { |
|
|
|
...state, |
|
|
|
...state, |
|
|
@ -102,7 +115,9 @@ export default function publicApi(state = initialState, action) { |
|
|
|
categories: allCats.map((item) => |
|
|
|
categories: allCats.map((item) => |
|
|
|
data.vods.filter((item1) => item1.categoryId === item) |
|
|
|
data.vods.filter((item1) => item1.categoryId === item) |
|
|
|
), |
|
|
|
), |
|
|
|
selectedVideo: data.vods.filter((item ) => item.id !== location.getId())[0], |
|
|
|
selectedVideo: data.vods.filter( |
|
|
|
|
|
|
|
(item) => item.id !== location.getId() |
|
|
|
|
|
|
|
)[0], |
|
|
|
}; |
|
|
|
}; |
|
|
|
case "public/homePage": |
|
|
|
case "public/homePage": |
|
|
|
let itemsLevel; |
|
|
|
let itemsLevel; |
|
|
@ -124,101 +139,9 @@ export default function publicApi(state = initialState, action) { |
|
|
|
error: null, |
|
|
|
error: null, |
|
|
|
homeData: data, |
|
|
|
homeData: data, |
|
|
|
}; |
|
|
|
}; |
|
|
|
// case "public/filter":
|
|
|
|
|
|
|
|
// const realList =
|
|
|
|
|
|
|
|
// state.newProducts.length === 0
|
|
|
|
|
|
|
|
// ? state.homeData.filter(
|
|
|
|
|
|
|
|
// (item) => item.title === "جدیدترین کتابهای دانوین"
|
|
|
|
|
|
|
|
// )[0].data
|
|
|
|
|
|
|
|
// : state.newProducts;
|
|
|
|
|
|
|
|
// if (state.newProducts.length === 0) {
|
|
|
|
|
|
|
|
// state = {
|
|
|
|
|
|
|
|
// ...state,
|
|
|
|
|
|
|
|
// newProducts: realList,
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
// console.log("here1");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// const level = data.levels;
|
|
|
|
|
|
|
|
// const search = data.search;
|
|
|
|
|
|
|
|
// if (level.length > 0 || search) {
|
|
|
|
|
|
|
|
// localStorage.setItem("filter", "ON");
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// return {
|
|
|
|
|
|
|
|
// ...state,
|
|
|
|
|
|
|
|
// loading: false,
|
|
|
|
|
|
|
|
// error: null,
|
|
|
|
|
|
|
|
// homeData: state.homeData.map((item) =>
|
|
|
|
|
|
|
|
// item.title === "جدیدترین کتابهای دانوین"
|
|
|
|
|
|
|
|
// ? { ...item, data: state.newProducts }
|
|
|
|
|
|
|
|
// : { ...item }
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// newProducts: [],
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// let byLevelFilter = [];
|
|
|
|
|
|
|
|
// if (level.length > 0) {
|
|
|
|
|
|
|
|
// level.map((item1) => {
|
|
|
|
|
|
|
|
// for (let i = 0; i < realList.length; i++) {
|
|
|
|
|
|
|
|
// if (grades[realList[i].book.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
|
|
|
|
|
|
|
|
// ? byLevelFilter.filter((item1) => item1.name.indexOf(search) !== -1)
|
|
|
|
|
|
|
|
// : byLevelFilter;
|
|
|
|
|
|
|
|
// // if (sort === "گران ترین") {
|
|
|
|
|
|
|
|
// // finalSort = bySearchFilter.sort((item1, item2) => {
|
|
|
|
|
|
|
|
// // return item1.product[0].price - item2.product[0].price;
|
|
|
|
|
|
|
|
// // });
|
|
|
|
|
|
|
|
// // } else {
|
|
|
|
|
|
|
|
// // finalSort = bySearchFilter;
|
|
|
|
|
|
|
|
// // }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return {
|
|
|
|
|
|
|
|
// ...state,
|
|
|
|
|
|
|
|
// loading: false,
|
|
|
|
|
|
|
|
// error: null,
|
|
|
|
|
|
|
|
// homeData: state.homeData.map((item) =>
|
|
|
|
|
|
|
|
// item.title === "جدیدترین کتابهای دانوین"
|
|
|
|
|
|
|
|
// ? { ...item, data: bySearchFilter }
|
|
|
|
|
|
|
|
// : { ...item }
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
// case "faq/list":
|
|
|
|
|
|
|
|
// return { ...state, loading: false, error: null, faqList: data };
|
|
|
|
|
|
|
|
// case "public/faq/search":
|
|
|
|
|
|
|
|
// return {
|
|
|
|
|
|
|
|
// ...state,
|
|
|
|
|
|
|
|
// loading: false,
|
|
|
|
|
|
|
|
// error: null,
|
|
|
|
|
|
|
|
// searchResult: state.faqList.filter(
|
|
|
|
|
|
|
|
// (item) =>
|
|
|
|
|
|
|
|
// item.title.indexOf(data) !== -1 ||
|
|
|
|
|
|
|
|
// item.description.indexOf(data) !== -1
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
case "public/contact": |
|
|
|
case "public/contact": |
|
|
|
return { ...state, loading: false, error: null, contactData: data }; |
|
|
|
return { ...state, loading: false, error: null, contactData: data }; |
|
|
|
// case "public/ar":
|
|
|
|
|
|
|
|
// return { ...state, loading: false, error: null, arList: data };
|
|
|
|
|
|
|
|
case "public/blogList": |
|
|
|
case "public/blogList": |
|
|
|
return { ...state, loading: false, error: null, blogList: data }; |
|
|
|
return { ...state, loading: false, error: null, blogList: data }; |
|
|
|
case "public/blogInfo": |
|
|
|
case "public/blogInfo": |
|
|
|