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