{info?.name}
{info?.text}
+ {info?.vodTeacher}diff --git a/src/redux/actions-type/book.tsx b/src/redux/actions-type/book.tsx index 8b66b67..a3afab2 100644 --- a/src/redux/actions-type/book.tsx +++ b/src/redux/actions-type/book.tsx @@ -8,11 +8,6 @@ interface setLessonActive { data: any; } -interface setVideoActive { - type: "book/video/active"; - data: any; -} - interface gradeFilter { type: "book/gradeFilter"; data: any; @@ -35,7 +30,6 @@ interface loading { type BookAction = | list - | setVideoActive | setLessonActive | gradeFilter | sortFilter diff --git a/src/redux/actions-type/public.tsx b/src/redux/actions-type/public.tsx index 2a51ab6..a3a99bf 100644 --- a/src/redux/actions-type/public.tsx +++ b/src/redux/actions-type/public.tsx @@ -8,9 +8,24 @@ interface getBlogList { data: any; } +interface setVideoActive { + type: "active/video"; + data: any; +} + +interface activeCategory { + type: "active/category"; + data: any; +} + interface bookInfo { - type: "public/vod/bookCourse" - data: any + type: "public/vod/bookCourse"; + data: any; +} + +interface bookSection { + type: "public/vod/bookSection"; + data: any; } interface getBlogInfo { @@ -48,7 +63,7 @@ interface selectMenu { data: any; } -interface getHeader{ +interface getHeader { type: "public/VOD/homePage"; data: any; } @@ -68,9 +83,12 @@ interface loading { // } type PublicAction = + | activeCategory + | setVideoActive | getBlogList | getBlogInfo | bookInfo + | bookSection | setSubscribe | getHomeData | setFaqActive diff --git a/src/redux/actions/book.tsx b/src/redux/actions/book.tsx index ce43ee0..24577db 100644 --- a/src/redux/actions/book.tsx +++ b/src/redux/actions/book.tsx @@ -7,8 +7,6 @@ const book = { await proxy.get("book/list", data, { dispatch }), setLessonActive: (data: undefined) => async (dispatch: Dispatch) => await dispatch({ type: "book/lesson/active", data: data }), - setVideoActive: (data: undefined) => async (dispatch: Dispatch) => - await dispatch({ type: "book/video/active", data: data }), gradeFilter: (data: undefined) => async (dispatch: Dispatch) => await dispatch({ type: "book/gradeFilter", data: data }), sortFilter: (data: undefined) => async (dispatch: Dispatch) => diff --git a/src/redux/actions/public.tsx b/src/redux/actions/public.tsx index 051bca6..4ec545a 100644 --- a/src/redux/actions/public.tsx +++ b/src/redux/actions/public.tsx @@ -10,6 +10,10 @@ const publicApi = { (data = {}) => async (dispatch: Dispatch) => await proxy.get("public/vod/bookCourse", data, { dispatch }), + bookSection: + (data = {}) => + async (dispatch: Dispatch) => + await proxy.get("public/vod/bookSection", data, { dispatch }), getContactData: (data = {}) => async (dispatch: Dispatch) => @@ -36,6 +40,10 @@ const publicApi = { (data = {}) => async (dispatch: Dispatch) => await proxy.get("public/VOD/homePage", data, { dispatch }), + activeCategory: (data: Object) => async (dispatch: Dispatch) => + await dispatch({ type: "active/category", data: data }), + setVideoActive: (data: undefined) => async (dispatch: Dispatch) => + await dispatch({ type: "active/video", data: data }), }; export default publicApi; diff --git a/src/redux/reducers/book.tsx b/src/redux/reducers/book.tsx index b5ef59a..d3d82c1 100644 --- a/src/redux/reducers/book.tsx +++ b/src/redux/reducers/book.tsx @@ -347,13 +347,6 @@ export default function book(state = initialState, action: BookAction) { : { ...item, active: false } ), }; - case "book/video/active": - return { - ...state, - loading: false, - error: null, - selectedVideo: data, - }; case "book/gradeFilter": if (data === state.selectedGrade) { return { ...state, gradeFilterBooks: null, selectedGrade: null }; diff --git a/src/redux/reducers/public.tsx b/src/redux/reducers/public.tsx index 1f3c84a..c6b677b 100644 --- a/src/redux/reducers/public.tsx +++ b/src/redux/reducers/public.tsx @@ -1,5 +1,5 @@ import { PublicAction } from "../actions-type"; -import proxy from '../proxy'; +import proxy from "../proxy"; const initialState = { homeData: [], newProducts: [], @@ -10,8 +10,8 @@ const initialState = { arList: [], blogList: [], blog: null, - province : null, - city : null, + province: null, + city: null, departmans: [ { id: 0, @@ -26,11 +26,14 @@ const initialState = { name: "برنامه نویسی", }, ], - header : [], - selectedMenu : null, + header: [], + selectedMenu: null, contactData: null, selectedVideo: null, - bookInfo : null, + bookInfo: null, + activeCategory: null, + categories: null, + bookSection : null, }; const grades = [ @@ -51,13 +54,49 @@ const grades = [ export default function publicApi(state = initialState, action: PublicAction) { let { type, data } = action; switch (type) { + case "active/video": + return { + ...state, + loading: false, + error: null, + selectedVideo: data, + }; + case "active/category": + return { + ...state, + loading: false, + activeCategory: state.activeCategory === data ? null : data, + error: null, + }; + case "public/vod/bookSection": + return { + ...state, + loading: false, + bookSection: data, + error: null, + selectedVideo : data?.vods[0] + }; + case "public/vod/bookCourse": + let allCats; + allCats = Array.from( + new Set( + data.vods.map((item: any) => item.categoryId && item.categoryId) + ) + ); return { ...state, loading: false, - bookInfo: data, - selectedVideo: data.vods[0], + bookInfo: { + ...data, + vods: data.vods.map((item: any) => { + return { ...item, active: false }; + }), + }, error: null, + categories: allCats.map((item: any) => + data.vods.filter((item1: any) => item1.categoryId === item) + ), }; case "public/homePage": let itemsLevel; @@ -179,15 +218,15 @@ export default function publicApi(state = initialState, action: PublicAction) { case "public/blogInfo": return { ...state, loading: false, error: null, blog: data }; case "public/setSubscribe": - return { ...state, loading: false, error: null, selectedSubscribe : data }; + return { ...state, loading: false, error: null, selectedSubscribe: data }; case "public/province": return { ...state, loading: false, error: null, province: data }; case "public/city": return { ...state, loading: false, error: null, city: data }; case "public/selectMenu": - return { ...state, loading: false, error: null, selectedMenu : data }; + return { ...state, loading: false, error: null, selectedMenu: data }; case "public/VOD/homePage": - return { ...state, loading: false, error: null, header : data }; + return { ...state, loading: false, error: null, header: data }; case "loading": return { ...state, loading: true }; case "error": diff --git a/src/views/Course/Lesson/index.tsx b/src/views/Course/Lesson/index.tsx index eba3d26..9cd354a 100644 --- a/src/views/Course/Lesson/index.tsx +++ b/src/views/Course/Lesson/index.tsx @@ -2,23 +2,25 @@ import React from "react"; import whiteDropdown from "../../../assets/icons/white-dropdown.png"; import whitePlay from "../../../assets/icons/white-play.png"; import document from "../../../assets/icons/document.png"; -import lock from "../../../assets/icons/lock.png"; import "./index.scss"; import { connect } from "react-redux"; -import { book } from "../../../redux/actions"; -import LessonPlayList from "../../VideoTube/LessonPlayList"; +import { book, publicApi } from "../../../redux/actions"; -function Lesson(props: any) { - const { lesson } = props; +function Lesson({toggle, lesson, activeCategory} : any) { + const duration = (value : number) => { + const minute = value % 60; + const hour = Math.round(value / 60); + return (hour > 0 ? (hour + ' ' + 'ساعت') : '') + ' ' + minute + ' ' + 'دقیقه'; + } return (
{info?.text}
+ {info?.vodTeacher}در این قسمت توضیحی
در این قسمت شاید یک متن جهت زیباسازی قرار بگیرد
- {cats?.map((lesson: any, i: any) => ( + {categories?.map((lesson: any, i: any) => (لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از طراحان گرافیک است چاپگرها و متون بلکه روزنامه و مجله در ستون و
-{'لورم ایپسوم و اینجور چیزا'}
-{file.text}
*/}