reza added some change

master
Reza_ashrafi 3 years ago
parent bd59ebc506
commit dbb6ad203a
  1. 5
      src/redux/reducers/public.tsx
  2. 20
      src/views/Course/Lesson/index.scss
  3. 45
      src/views/Course/Lesson/index.tsx
  4. 2
      src/views/Course/index.tsx
  5. 41
      src/views/VideoTube/LessonPlayList/index.tsx
  6. 22
      src/views/VideoTube/index.tsx

@ -33,7 +33,7 @@ const initialState = {
bookInfo: null, bookInfo: null,
activeCategory: null, activeCategory: null,
categories: null, categories: null,
bookSection : null, bookSection: null,
}; };
const grades = [ const grades = [
@ -69,12 +69,13 @@ export default function publicApi(state = initialState, action: PublicAction) {
error: null, error: null,
}; };
case "public/vod/bookSection": case "public/vod/bookSection":
const videoId: any = localStorage.getItem("category")?.split(",")[2];
return { return {
...state, ...state,
loading: false, loading: false,
bookSection: data, bookSection: data,
error: null, error: null,
selectedVideo : data?.vods[0] selectedVideo: data?.vods?.filter((item: any) => item.name === videoId)[0],
}; };
case "public/vod/bookCourse": case "public/vod/bookCourse":

@ -29,11 +29,27 @@
border-right: 1px solid #b3b3b3; border-right: 1px solid #b3b3b3;
transition: all 0.4s ease-in; transition: all 0.4s ease-in;
overflow: hidden; overflow: hidden;
p{
color: white;
padding: 10px 20px;
background-color: rgb(58, 58, 58);
margin: 0px !important;
}
& img{ & img{
width: 30px; width: 30px;
margin-right: 15px; margin-right: 15px;
} }
&--sample{ &--sample{
transition: all 0.5s;
cursor: pointer;
padding: 5px 0px;
&:hover{
background-color: rgb(58, 58, 58);
}
&___active{
transition: all 0.5s;
transform: scale(1.3);
}
color: white; color: white;
a{ a{
color: white; color: white;
@ -175,7 +191,7 @@
header { header {
border-top-right-radius: 10px; border-top-right-radius: 10px;
border-top-left-radius: 10px; border-top-left-radius: 10px;
padding: 15px 5px !important; padding: 10px 5px !important;
h4 { h4 {
font-size: calc(100vw / 30); font-size: calc(100vw / 30);
} }
@ -203,7 +219,7 @@
} }
h5{ h5{
font-size: calc(100vw/ 33); font-size: calc(100vw/ 33);
margin-right: 5px; margin-right: 15px;
} }
} }
&--active{ &--active{

@ -1,4 +1,4 @@
import React from "react"; import React, { useState } from "react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import whiteDropdown from "../../../assets/icons/white-dropdown.png"; import whiteDropdown from "../../../assets/icons/white-dropdown.png";
import whitePlay from "../../../assets/icons/white-play.png"; import whitePlay from "../../../assets/icons/white-play.png";
@ -6,13 +6,25 @@ import document from "../../../assets/icons/document.png";
import "./index.scss"; import "./index.scss";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { book, publicApi } from "../../../redux/actions"; import { book, publicApi } from "../../../redux/actions";
import location from "../../../util/location";
function Lesson({ toggle, lesson, activeCategory, realCategories, vodDuration }: any) { function Lesson({
toggle,
lesson,
activeCategory,
realCategories,
vodDuration,
}: any) {
const [selectedLesson, setSelectedLesson] = useState(null);
const duration = (value: number) => { const duration = (value: number) => {
const minute = value % 60; const minute = value % 60;
const hour = Math.round(value / 60); const hour = Math.round(value / 60);
return (hour > 0 ? hour + " " + "ساعت" : "") + " " + minute + " " + "دقیقه"; return (hour > 0 ? hour + " " + "ساعت" : "") + " " + minute + " " + "دقیقه";
}; };
const setCategory = (catId : any, videoId: any) => {
localStorage.removeItem("bookId");
localStorage.setItem("category", location.getId() + "," + catId + "," + videoId );
};
return ( return (
<div className="lesson d-flex flex-column"> <div className="lesson d-flex flex-column">
<header <header
@ -42,8 +54,14 @@ function Lesson({ toggle, lesson, activeCategory, realCategories, vodDuration }:
onClick={() => toggle(lesson[0].categoryId)} onClick={() => toggle(lesson[0].categoryId)}
> >
<div className="d-flex flex-column"> <div className="d-flex flex-column">
<h4>{lesson[0].categoryId}</h4> <h4>
<span> مدت زمان درس {lesson.duration}</span> {
realCategories.filter(
(item: any) => item.id === lesson[0].categoryId
)[0].name
}
</h4>
{/* <span> مدت زمان درس {lesson.duration}</span> */}
</div> </div>
<div className="lesson__duration d-flex"> <div className="lesson__duration d-flex">
<img src={whiteDropdown} alt="" /> <img src={whiteDropdown} alt="" />
@ -66,26 +84,41 @@ function Lesson({ toggle, lesson, activeCategory, realCategories, vodDuration }:
}} }}
> >
{lesson?.map((data: any, i: any) => ( {lesson?.map((data: any, i: any) => (
<div className="d-flex flex-column">
<li <li
className="lesson__files--sample justify-content-between align-items-center" className="lesson__files--sample justify-content-between align-items-center"
style={{ style={{
display: display:
lesson[0].categoryId === activeCategory ? "flex" : "none", lesson[0].categoryId === activeCategory ? "flex" : "none",
}} }}
onClick={() =>
setSelectedLesson(selectedLesson === data.id ? null : data.id)
}
> >
<div className="d-flex align-items-center"> <div className="d-flex align-items-center">
{data.type === "video" && <img src={whitePlay} alt="" />} {data.type === "video" && <img src={whitePlay} alt="" />}
{data.type === "pdf" && <img src={document} alt="" />} {data.type === "pdf" && <img src={document} alt="" />}
<img
className={
selectedLesson === data.id
? "lesson__files--sample___active"
: ""
}
src={`https://dnvn.ir/api/v1/file/${data.posterId}`}
alt=""
/>
<h5>{data.name}</h5> <h5>{data.name}</h5>
</div> </div>
<ul className="d-flex"> <ul className="d-flex">
<li>{data.type !== "pdf" && duration(data.duration)}</li> <li>{data.type !== "pdf" && duration(data.duration)}</li>
<Link to="/video-tube"> <Link to="/video-tube" onClick={() => setCategory(lesson[0].categoryId, data.name)}>
<li>{"مشاهده"}</li> <li>{"مشاهده"}</li>
</Link> </Link>
{/* <li>{data.download ? "دانلود" : <img src={lock} alt="" />}</li> */} {/* <li>{data.download ? "دانلود" : <img src={lock} alt="" />}</li> */}
</ul> </ul>
</li> </li>
{selectedLesson === data.id && <p>سلام</p>}
</div>
))} ))}
</ul> </ul>
</div> </div>
@ -96,7 +129,7 @@ export default connect(
(state: any) => ({ (state: any) => ({
activeCategory: state.publicApi.activeCategory, activeCategory: state.publicApi.activeCategory,
realCategories: state.publicApi.bookInfo?.categories, realCategories: state.publicApi.bookInfo?.categories,
vodDuration : state.publicApi.bookInfo?.vodDuration, vodDuration: state.publicApi.bookInfo?.vodDuration,
}), }),
{ {
toggle: publicApi.activeCategory, toggle: publicApi.activeCategory,

@ -33,7 +33,9 @@ function Course({ getInfo, info, categories, loading }: any) {
const checkFreeCat = () => { const checkFreeCat = () => {
// const freeCat = info?.vods.filter((item: any) => item?.isFreeVOD)[0]; // const freeCat = info?.vods.filter((item: any) => item?.isFreeVOD)[0];
// localStorage.setItem("free", location.getId() + "," + freeCat?.categoryId); // localStorage.setItem("free", location.getId() + "," + freeCat?.categoryId);
// local => bookId, category
localStorage.setItem("bookId", location.getId()); localStorage.setItem("bookId", location.getId());
localStorage.removeItem("category");
}; };
return ( return (
<div <div

@ -10,21 +10,25 @@ function LessonPlayList({
catergories, catergories,
realCategories, realCategories,
}: any) { }: any) {
const bookId = localStorage.getItem("bookId");
return ( return (
<> <>
{ {
<div className="lesson-playlist d-flex flex-column"> <div className="lesson-playlist d-flex flex-column">
{bookId && (
<header> <header>
<h3> <h3>
{ { realCategories.filter(
realCategories.filter(
(item: any) => item.id === category[0].categoryId (item: any) => item.id === category[0].categoryId
)[0].name )[0].name
} }
</h3> </h3>
<span></span> <span></span>
</header> </header>
{category.map((video: any, i: any) => ( )}
{bookId ? (
category.map((video: any, i: any) => (
<div <div
className={ className={
"lesson-playlist__item d-flex align-items-center" + "lesson-playlist__item d-flex align-items-center" +
@ -55,7 +59,36 @@ function LessonPlayList({
{/* <p>{file.text}</p> */} {/* <p>{file.text}</p> */}
</div> </div>
</div> </div>
))} ))
) : (
<div
className={
"lesson-playlist__item d-flex align-items-center" +
" " +
(category?.id === selectedVideo?.id &&
"lesson-playlist__item--active")
}
onClick={() => setVideoActive(category)}
>
<span className="lesson-playlist__item--count"></span>
<div className="lesson-playlist__item--video">
{/* <video>
<source
src={`https://dnvn.ir/api/v1/file/${video.fileIds}`}
/>
</video> */}
<img
src={`https://dnvn.ir/api/v1/file/${category.posterId}`}
alt=""
/>
<span>22:05</span>
</div>
<div className="lesson-playlist__item--text d-flex flex-column">
<h4>{category.name}</h4>
{/* <p>{file.text}</p> */}
</div>
</div>
)}
</div> </div>
} }
</> </>

@ -25,7 +25,6 @@ function VodTube({
setVideoActive, setVideoActive,
}: any) { }: any) {
useEffect(() => { useEffect(() => {
// const free: any = localStorage.getItem("free")?.split(",");
scroll.goToTop(); scroll.goToTop();
// getInfo({ // getInfo({
// bookId: 1, // bookId: 1,
@ -38,7 +37,14 @@ function VodTube({
}, []); }, []);
useEffect(() => { useEffect(() => {
if (localStorage.getItem("bookId")) {
setVideoActive(categories[0][0]); setVideoActive(categories[0][0]);
} else {
if (!info) {
const cat: any = localStorage.getItem("category")?.split(",");
bookSection({ bookId: cat[0], categoryId: cat[1] });
}
}
}, [info]); }, [info]);
return ( return (
<> <>
@ -53,7 +59,10 @@ function VodTube({
{/* <video controls> {/* <video controls>
<source src={selectedVideo.src} /> <source src={selectedVideo.src} />
</video> */} </video> */}
<Video fileIds={selectedVideo?.fileIds} posterId={selectedVideo?.posterId} /> <Video
fileIds={selectedVideo?.fileIds}
posterId={selectedVideo?.posterId}
/>
<span className="desktop">درس دوم / بیست و یکم</span> <span className="desktop">درس دوم / بیست و یکم</span>
<h1 className="desktop">{selectedVideo?.name}</h1> <h1 className="desktop">{selectedVideo?.name}</h1>
{/* <p className="desktop">{selectedVideo.text}</p> */} {/* <p className="desktop">{selectedVideo.text}</p> */}
@ -77,13 +86,18 @@ function VodTube({
<section className="video-tube__sidebar--playlist d-flex flex-column"> <section className="video-tube__sidebar--playlist d-flex flex-column">
<header className="d-flex justify-content-between align-items-center"> <header className="d-flex justify-content-between align-items-center">
<div className="d-flex flex-column"> <div className="d-flex flex-column">
<h2>لیست فیلمها</h2> <h2>{localStorage.getItem("category")?.split(',')[1] || 'لیست فیلمها' }</h2>
<p>در این قسمت توضیحی کوتاه قرار می گیرد</p> <p>در این قسمت توضیحی کوتاه قرار می گیرد</p>
</div> </div>
<img src={listIcon} alt="" /> <img src={listIcon} alt="" />
</header> </header>
<div className="video-tube__sidebar--playlist___list d-flex flex-column"> <div className="video-tube__sidebar--playlist___list d-flex flex-column">
{categories?.map((video: any, i: any) => ( { localStorage.getItem("bookId")
? categories?.map((video: any, i: any) => (
<LessonPlayList category={video} key={i} />
))
:
info?.vods?.map((video: any, i: any) => (
<LessonPlayList category={video} key={i} /> <LessonPlayList category={video} key={i} />
))} ))}
</div> </div>

Loading…
Cancel
Save