|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
import React from "react"; |
|
|
|
|
import { Link } from "react-router-dom"; |
|
|
|
|
import whiteDropdown from "../../../assets/icons/white-dropdown.png"; |
|
|
|
|
import whitePlay from "../../../assets/icons/white-play.png"; |
|
|
|
|
import document from "../../../assets/icons/document.png"; |
|
|
|
@ -6,12 +7,12 @@ import "./index.scss"; |
|
|
|
|
import { connect } from "react-redux"; |
|
|
|
|
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 minute = value % 60; |
|
|
|
|
const hour = Math.round(value / 60); |
|
|
|
|
return (hour > 0 ? (hour + ' ' + 'ساعت') : '') + ' ' + minute + ' ' + 'دقیقه'; |
|
|
|
|
} |
|
|
|
|
return (hour > 0 ? hour + " " + "ساعت" : "") + " " + minute + " " + "دقیقه"; |
|
|
|
|
}; |
|
|
|
|
return ( |
|
|
|
|
<div className="lesson d-flex flex-column"> |
|
|
|
|
<header |
|
|
|
@ -20,10 +21,16 @@ function Lesson({toggle, lesson, activeCategory} : any) { |
|
|
|
|
> |
|
|
|
|
<div className="d-flex align-items-center"> |
|
|
|
|
<img src={whiteDropdown} alt="" /> |
|
|
|
|
<h4>{lesson[0].categoryId}</h4> |
|
|
|
|
<h4> |
|
|
|
|
{ |
|
|
|
|
realCategories.filter( |
|
|
|
|
(item: any) => item.id === lesson[0].categoryId |
|
|
|
|
)[0].name |
|
|
|
|
} |
|
|
|
|
</h4> |
|
|
|
|
</div> |
|
|
|
|
<div className="lesson__duration d-flex"> |
|
|
|
|
مدت زمان درس {lesson.duration} |
|
|
|
|
{/* {duration(vodDuration)} */} |
|
|
|
|
</div> |
|
|
|
|
</header> |
|
|
|
|
<header |
|
|
|
@ -46,10 +53,11 @@ function Lesson({toggle, lesson, activeCategory} : any) { |
|
|
|
|
className={ |
|
|
|
|
"lesson__files d-flex flex-column justify-content-around" + |
|
|
|
|
" " + |
|
|
|
|
((lesson[0].categoryId === activeCategory) && "lesson__files--active") |
|
|
|
|
(lesson[0].categoryId === activeCategory && "lesson__files--active") |
|
|
|
|
} |
|
|
|
|
style={{ |
|
|
|
|
height: lesson[0].categoryId === activeCategory |
|
|
|
|
height: |
|
|
|
|
lesson[0].categoryId === activeCategory |
|
|
|
|
? lesson.length * |
|
|
|
|
(window.innerWidth > 1007 |
|
|
|
|
? window.innerWidth / 33 + 20 |
|
|
|
@ -61,7 +69,8 @@ function Lesson({toggle, lesson, activeCategory} : any) { |
|
|
|
|
<li |
|
|
|
|
className="lesson__files--sample justify-content-between align-items-center" |
|
|
|
|
style={{ |
|
|
|
|
display: lesson[0].categoryId === activeCategory ? "flex" : "none", |
|
|
|
|
display: |
|
|
|
|
lesson[0].categoryId === activeCategory ? "flex" : "none", |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
<div className="d-flex align-items-center"> |
|
|
|
@ -71,7 +80,9 @@ function Lesson({toggle, lesson, activeCategory} : any) { |
|
|
|
|
</div> |
|
|
|
|
<ul className="d-flex"> |
|
|
|
|
<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> */} |
|
|
|
|
</ul> |
|
|
|
|
</li> |
|
|
|
@ -81,8 +92,13 @@ function Lesson({toggle, lesson, activeCategory} : any) { |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export default connect((state: any) => ({ |
|
|
|
|
activeCategory : state.publicApi.activeCategory |
|
|
|
|
}), { |
|
|
|
|
export default connect( |
|
|
|
|
(state: any) => ({ |
|
|
|
|
activeCategory: state.publicApi.activeCategory, |
|
|
|
|
realCategories: state.publicApi.bookInfo?.categories, |
|
|
|
|
vodDuration : state.publicApi.bookInfo?.vodDuration, |
|
|
|
|
}), |
|
|
|
|
{ |
|
|
|
|
toggle: publicApi.activeCategory, |
|
|
|
|
})(Lesson); |
|
|
|
|
} |
|
|
|
|
)(Lesson); |
|
|
|
|