|
|
@ -1,8 +1,9 @@ |
|
|
|
import React, { useEffect } from "react"; |
|
|
|
import React, { useEffect, useState } from "react"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { publicApi } from "../../../redux/actions"; |
|
|
|
import { publicApi } from "../../../redux/actions"; |
|
|
|
import { Link } from "react-router-dom"; |
|
|
|
import { Link } from "react-router-dom"; |
|
|
|
import _ from "lodash"; |
|
|
|
import _ from "lodash"; |
|
|
|
|
|
|
|
import Dialog from "../../../components/Dialog"; |
|
|
|
|
|
|
|
|
|
|
|
function LessonPlayList({ |
|
|
|
function LessonPlayList({ |
|
|
|
category, |
|
|
|
category, |
|
|
@ -14,6 +15,7 @@ function LessonPlayList({ |
|
|
|
theme, |
|
|
|
theme, |
|
|
|
}: any) { |
|
|
|
}: any) { |
|
|
|
const bookId = localStorage.getItem("bookId"); |
|
|
|
const bookId = localStorage.getItem("bookId"); |
|
|
|
|
|
|
|
const [open, setOpen] = useState(false); |
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
if (localStorage.getItem("scroll-list") && vods) { |
|
|
|
if (localStorage.getItem("scroll-list") && vods) { |
|
|
|
const list: HTMLElement = document.getElementById("list") as HTMLElement; |
|
|
|
const list: HTMLElement = document.getElementById("list") as HTMLElement; |
|
|
@ -25,8 +27,6 @@ function LessonPlayList({ |
|
|
|
const index = vods?.findIndex( |
|
|
|
const index = vods?.findIndex( |
|
|
|
(item: any) => item?.name === selectedVideo?.name |
|
|
|
(item: any) => item?.name === selectedVideo?.name |
|
|
|
); |
|
|
|
); |
|
|
|
console.log(index); |
|
|
|
|
|
|
|
console.log(listHeight, elementHeight * (Number(index) + 1)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (elementHeight * (Number(index) + 1) > listHeight) { |
|
|
|
if (elementHeight * (Number(index) + 1) > listHeight) { |
|
|
|
list.scrollTo(0, elementHeight * (Number(index) + 1) + elementHeight); |
|
|
|
list.scrollTo(0, elementHeight * (Number(index) + 1) + elementHeight); |
|
|
@ -37,99 +37,104 @@ function LessonPlayList({ |
|
|
|
|
|
|
|
|
|
|
|
const light = theme === "light"; |
|
|
|
const light = theme === "light"; |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<div |
|
|
|
{ |
|
|
|
className={_.join( |
|
|
|
<div |
|
|
|
[ |
|
|
|
className={_.join( |
|
|
|
"lesson-playlist d-flex flex-column", |
|
|
|
[ |
|
|
|
light ? "lesson-playlist-light" : "lesson-playlist-dark", |
|
|
|
"lesson-playlist d-flex flex-column", |
|
|
|
], |
|
|
|
light ? "lesson-playlist-light" : "lesson-playlist-dark", |
|
|
|
" " |
|
|
|
], |
|
|
|
)} |
|
|
|
" " |
|
|
|
> |
|
|
|
)} |
|
|
|
{bookId && ( |
|
|
|
> |
|
|
|
<header> |
|
|
|
{bookId && ( |
|
|
|
<h3> |
|
|
|
<header> |
|
|
|
{ |
|
|
|
<h3> |
|
|
|
realCategories.filter( |
|
|
|
{ |
|
|
|
(item: any) => item.id === category[0].categoryId |
|
|
|
realCategories.filter( |
|
|
|
)[0].name |
|
|
|
(item: any) => item.id === category[0].categoryId |
|
|
|
} |
|
|
|
)[0].name |
|
|
|
</h3> |
|
|
|
} |
|
|
|
<span></span> |
|
|
|
</h3> |
|
|
|
</header> |
|
|
|
<span></span> |
|
|
|
)} |
|
|
|
</header> |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{bookId ? ( |
|
|
|
{bookId ? ( |
|
|
|
category.map((video: any, i: any) => ( |
|
|
|
category.map((video: any, i: any) => ( |
|
|
|
<Link |
|
|
|
<Link |
|
|
|
to={"/video/" + video.id} |
|
|
|
to={video.isFreeVod ? "/video/" + video.id : "#"} |
|
|
|
className={ |
|
|
|
className={ |
|
|
|
"lesson-playlist__item d-flex align-items-center" + |
|
|
|
"lesson-playlist__item d-flex align-items-center" + |
|
|
|
" " + |
|
|
|
" " + |
|
|
|
(video?.id === selectedVideo?.id && |
|
|
|
(video?.id === selectedVideo?.id && |
|
|
|
"lesson-playlist__item--active") |
|
|
|
"lesson-playlist__item--active") |
|
|
|
} |
|
|
|
} |
|
|
|
key={i} |
|
|
|
key={i} |
|
|
|
id={"listItem" + video.id} |
|
|
|
id={"listItem" + video.id} |
|
|
|
onClick={() => video.isFreeVod ? setVideoActive(video) : {}} |
|
|
|
onClick={() => |
|
|
|
> |
|
|
|
video.isFreeVod ? setVideoActive(video) : setOpen(true) |
|
|
|
<span className="lesson-playlist__item--count"> |
|
|
|
} |
|
|
|
{Number(i) + 1} |
|
|
|
> |
|
|
|
</span> |
|
|
|
<span className="lesson-playlist__item--count"> |
|
|
|
<div className="lesson-playlist__item--video"> |
|
|
|
{Number(i) + 1} |
|
|
|
{/* <video> |
|
|
|
</span> |
|
|
|
|
|
|
|
<div className="lesson-playlist__item--video"> |
|
|
|
|
|
|
|
{/* <video> |
|
|
|
<source |
|
|
|
<source |
|
|
|
src={`https://dnvn.ir/api/v1/file/${video.fileIds}`} |
|
|
|
src={`https://dnvn.ir/api/v1/file/${video.fileIds}`} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</video> */} |
|
|
|
</video> */} |
|
|
|
<img |
|
|
|
<img |
|
|
|
src={`https://dnvn.ir/api/v1/file/${video.posterId}`} |
|
|
|
src={`https://dnvn.ir/api/v1/file/${video.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>{video.name}</h4> |
|
|
|
{/* <p>{file.text}</p> */} |
|
|
|
{/* <p>{file.text}</p> */} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</Link> |
|
|
|
</Link> |
|
|
|
)) |
|
|
|
)) |
|
|
|
) : ( |
|
|
|
) : ( |
|
|
|
<Link |
|
|
|
<Link |
|
|
|
to={"/video/" + category.id} |
|
|
|
to={category.isFreeVod ? "/video/" + category.id : "#"} |
|
|
|
className={ |
|
|
|
className={ |
|
|
|
"lesson-playlist__item d-flex align-items-center" + |
|
|
|
"lesson-playlist__item d-flex align-items-center" + |
|
|
|
" " + |
|
|
|
" " + |
|
|
|
(category?.id === selectedVideo?.id && |
|
|
|
(category?.id === selectedVideo?.id && |
|
|
|
"lesson-playlist__item--active") |
|
|
|
"lesson-playlist__item--active") |
|
|
|
} |
|
|
|
} |
|
|
|
onClick={() => category.isFreeVod ? setVideoActive(category) : ''} |
|
|
|
onClick={() => |
|
|
|
id={"listItem" + category.id} |
|
|
|
category.isFreeVod ? setVideoActive(category) : setOpen(true) |
|
|
|
> |
|
|
|
} |
|
|
|
<span className="lesson-playlist__item--count"></span> |
|
|
|
id={"listItem" + category.id} |
|
|
|
<div className="lesson-playlist__item--video"> |
|
|
|
> |
|
|
|
{/* <video> |
|
|
|
<span className="lesson-playlist__item--count"></span> |
|
|
|
|
|
|
|
<div className="lesson-playlist__item--video"> |
|
|
|
|
|
|
|
{/* <video> |
|
|
|
<source |
|
|
|
<source |
|
|
|
src={`https://dnvn.ir/api/v1/file/${video.fileIds}`} |
|
|
|
src={`https://dnvn.ir/api/v1/file/${video.fileIds}`} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</video> */} |
|
|
|
</video> */} |
|
|
|
<img |
|
|
|
<img |
|
|
|
src={`https://dnvn.ir/api/v1/file/${category.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>{category.name}</h4> |
|
|
|
<h4>{category.name}</h4> |
|
|
|
{/* <p>{file.text}</p> */} |
|
|
|
{/* <p>{file.text}</p> */} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</Link> |
|
|
|
</Link> |
|
|
|
)} |
|
|
|
)} |
|
|
|
</div> |
|
|
|
<Dialog |
|
|
|
} |
|
|
|
open={open} |
|
|
|
</> |
|
|
|
setOpen={setOpen} |
|
|
|
|
|
|
|
text="برای مشاهده این فیلم باید دوره را خریداری کنید." |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</div> |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|