|
|
@ -1,4 +1,5 @@ |
|
|
|
import React from "react"; |
|
|
|
import React from "react"; |
|
|
|
|
|
|
|
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"; |
|
|
|
import document from "../../../assets/icons/document.png"; |
|
|
|
import document from "../../../assets/icons/document.png"; |
|
|
@ -6,12 +7,12 @@ 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"; |
|
|
|
|
|
|
|
|
|
|
|
function Lesson({toggle, lesson, activeCategory} : any) { |
|
|
|
function Lesson({ toggle, lesson, activeCategory, realCategories, vodDuration }: any) { |
|
|
|
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 + " " + "دقیقه"; |
|
|
|
} |
|
|
|
}; |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className="lesson d-flex flex-column"> |
|
|
|
<div className="lesson d-flex flex-column"> |
|
|
|
<header |
|
|
|
<header |
|
|
@ -20,10 +21,16 @@ function Lesson({toggle, lesson, activeCategory} : any) { |
|
|
|
> |
|
|
|
> |
|
|
|
<div className="d-flex align-items-center"> |
|
|
|
<div className="d-flex align-items-center"> |
|
|
|
<img src={whiteDropdown} alt="" /> |
|
|
|
<img src={whiteDropdown} alt="" /> |
|
|
|
<h4>{lesson[0].categoryId}</h4> |
|
|
|
<h4> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
realCategories.filter( |
|
|
|
|
|
|
|
(item: any) => item.id === lesson[0].categoryId |
|
|
|
|
|
|
|
)[0].name |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
</h4> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className="lesson__duration d-flex"> |
|
|
|
<div className="lesson__duration d-flex"> |
|
|
|
مدت زمان درس {lesson.duration} |
|
|
|
{/* {duration(vodDuration)} */} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</header> |
|
|
|
</header> |
|
|
|
<header |
|
|
|
<header |
|
|
@ -46,22 +53,24 @@ function Lesson({toggle, lesson, activeCategory} : any) { |
|
|
|
className={ |
|
|
|
className={ |
|
|
|
"lesson__files d-flex flex-column justify-content-around" + |
|
|
|
"lesson__files d-flex flex-column justify-content-around" + |
|
|
|
" " + |
|
|
|
" " + |
|
|
|
((lesson[0].categoryId === activeCategory) && "lesson__files--active") |
|
|
|
(lesson[0].categoryId === activeCategory && "lesson__files--active") |
|
|
|
} |
|
|
|
} |
|
|
|
style={{ |
|
|
|
style={{ |
|
|
|
height: lesson[0].categoryId === activeCategory |
|
|
|
height: |
|
|
|
? lesson.length * |
|
|
|
lesson[0].categoryId === activeCategory |
|
|
|
(window.innerWidth > 1007 |
|
|
|
? lesson.length * |
|
|
|
? window.innerWidth / 33 + 20 |
|
|
|
(window.innerWidth > 1007 |
|
|
|
: window.innerWidth / 33 + 45) |
|
|
|
? window.innerWidth / 33 + 20 |
|
|
|
: "0px", |
|
|
|
: window.innerWidth / 33 + 45) |
|
|
|
|
|
|
|
: "0px", |
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
|
{lesson?.map((data: any, i: any) => ( |
|
|
|
{lesson?.map((data: any, i: any) => ( |
|
|
|
<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: lesson[0].categoryId === activeCategory ? "flex" : "none", |
|
|
|
display: |
|
|
|
|
|
|
|
lesson[0].categoryId === activeCategory ? "flex" : "none", |
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
|
<div className="d-flex align-items-center"> |
|
|
|
<div className="d-flex align-items-center"> |
|
|
@ -71,7 +80,9 @@ function Lesson({toggle, lesson, activeCategory} : any) { |
|
|
|
</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> |
|
|
|
<li>{data.isFree && "مشاهده"}</li> |
|
|
|
<Link to="/video-tube"> |
|
|
|
|
|
|
|
<li>{"مشاهده"}</li> |
|
|
|
|
|
|
|
</Link> |
|
|
|
{/* <li>{data.download ? "دانلود" : <img src={lock} alt="" />}</li> */} |
|
|
|
{/* <li>{data.download ? "دانلود" : <img src={lock} alt="" />}</li> */} |
|
|
|
</ul> |
|
|
|
</ul> |
|
|
|
</li> |
|
|
|
</li> |
|
|
@ -81,8 +92,13 @@ function Lesson({toggle, lesson, activeCategory} : any) { |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export default connect((state: any) => ({ |
|
|
|
export default connect( |
|
|
|
activeCategory : state.publicApi.activeCategory |
|
|
|
(state: any) => ({ |
|
|
|
}), { |
|
|
|
activeCategory: state.publicApi.activeCategory, |
|
|
|
toggle : publicApi.activeCategory, |
|
|
|
realCategories: state.publicApi.bookInfo?.categories, |
|
|
|
})(Lesson); |
|
|
|
vodDuration : state.publicApi.bookInfo?.vodDuration, |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
toggle: publicApi.activeCategory, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
)(Lesson); |
|
|
|