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. 83
      src/views/Course/Lesson/index.tsx
  4. 2
      src/views/Course/index.tsx
  5. 73
      src/views/VideoTube/LessonPlayList/index.tsx
  6. 28
      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) => (
<li <div className="d-flex flex-column">
className="lesson__files--sample justify-content-between align-items-center" <li
style={{ className="lesson__files--sample justify-content-between align-items-center"
display: style={{
lesson[0].categoryId === activeCategory ? "flex" : "none", display:
}} lesson[0].categoryId === activeCategory ? "flex" : "none",
> }}
<div className="d-flex align-items-center"> onClick={() =>
{data.type === "video" && <img src={whitePlay} alt="" />} setSelectedLesson(selectedLesson === data.id ? null : data.id)
{data.type === "pdf" && <img src={document} alt="" />} }
<h5>{data.name}</h5> >
</div> <div className="d-flex align-items-center">
<ul className="d-flex"> {data.type === "video" && <img src={whitePlay} alt="" />}
<li>{data.type !== "pdf" && duration(data.duration)}</li> {data.type === "pdf" && <img src={document} alt="" />}
<Link to="/video-tube"> <img
<li>{"مشاهده"}</li> className={
</Link> selectedLesson === data.id
{/* <li>{data.download ? "دانلود" : <img src={lock} alt="" />}</li> */} ? "lesson__files--sample___active"
</ul> : ""
</li> }
src={`https://dnvn.ir/api/v1/file/${data.posterId}`}
alt=""
/>
<h5>{data.name}</h5>
</div>
<ul className="d-flex">
<li>{data.type !== "pdf" && duration(data.duration)}</li>
<Link to="/video-tube" onClick={() => setCategory(lesson[0].categoryId, data.name)}>
<li>{"مشاهده"}</li>
</Link>
{/* <li>{data.download ? "دانلود" : <img src={lock} alt="" />}</li> */}
</ul>
</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,34 +10,67 @@ 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">
<header> {bookId && (
<h3> <header>
{ <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
className={
"lesson-playlist__item d-flex align-items-center" +
" " +
(video?.id === selectedVideo?.id &&
"lesson-playlist__item--active")
}
key={i}
onClick={() => setVideoActive(video)}
>
<span className="lesson-playlist__item--count">
{Number(i) + 1}
</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/${video.posterId}`}
alt=""
/>
<span>22:05</span>
</div>
<div className="lesson-playlist__item--text d-flex flex-column">
<h4>{video.name}</h4>
{/* <p>{file.text}</p> */}
</div>
</div>
))
) : (
<div <div
className={ className={
"lesson-playlist__item d-flex align-items-center" + "lesson-playlist__item d-flex align-items-center" +
" " + " " +
(video?.id === selectedVideo?.id && (category?.id === selectedVideo?.id &&
"lesson-playlist__item--active") "lesson-playlist__item--active")
} }
key={i} onClick={() => setVideoActive(category)}
onClick={() => setVideoActive(video)}
> >
<span className="lesson-playlist__item--count"> <span className="lesson-playlist__item--count"></span>
{Number(i) + 1}
</span>
<div className="lesson-playlist__item--video"> <div className="lesson-playlist__item--video">
{/* <video> {/* <video>
<source <source
@ -45,17 +78,17 @@ function LessonPlayList({
/> />
</video> */} </video> */}
<img <img
src={`https://dnvn.ir/api/v1/file/${video.posterId}`} src={`https://dnvn.ir/api/v1/file/${category.posterId}`}
alt="" alt=""
/> />
<span>22:05</span> <span>22:05</span>
</div> </div>
<div className="lesson-playlist__item--text d-flex flex-column"> <div className="lesson-playlist__item--text d-flex flex-column">
<h4>{video.name}</h4> <h4>{category.name}</h4>
{/* <p>{file.text}</p> */} {/* <p>{file.text}</p> */}
</div> </div>
</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(() => {
setVideoActive(categories[0][0]); if (localStorage.getItem("bookId")) {
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,15 +86,20 @@ 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")
<LessonPlayList category={video} key={i} /> ? categories?.map((video: any, i: any) => (
))} <LessonPlayList category={video} key={i} />
))
:
info?.vods?.map((video: any, i: any) => (
<LessonPlayList category={video} key={i} />
))}
</div> </div>
</section> </section>
{info?.attachments.length > 0 && ( {info?.attachments.length > 0 && (

Loading…
Cancel
Save