Skip to content
Open
117 changes: 54 additions & 63 deletions components/learn/courseDetails/ActivityDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,23 @@ const ActivityDetails = ({
.then((res) => res.json());
}
};

const nextElementKey = moduleInfo.elementKey + 1;
// if this is the last lesson in this level, advance to next level
const modLength = specificModules.length;
const nextElementKey = moduleInfo.elementKey + 1 >= modLength ? moduleInfo.elementKey : moduleInfo.elementKey + 1; // if it is last lesson skip.
const nextModuleDetails = specificModules?.find(
(module) => module.elementKey === nextElementKey,
);

const forwardInfo = () => {
const nextModuleId = nextModuleDetails._id;
const nextModuleInfo = `/courses/${courseId}/modules/${moduleLevel}/module-details/${nextModuleId}`;
let modLevel = '';
let nextModuleInfo = '';
if (moduleInfo.elementKey + 1 === modLength) {
modLevel = moduleLevel === 'beginner' ? 'intermediate' : 'advanced';
nextModuleInfo = `/courses/${courseId}/modules/${modLevel}/`;
} else {
nextModuleInfo = `/courses/${courseId}/modules/${moduleLevel}/module-details/${nextModuleId}`;
}

if (userModulesId.includes(nextModuleId)) {
router.push(nextModuleInfo);
Expand Down Expand Up @@ -130,20 +138,15 @@ const ActivityDetails = ({
const lastAdvancedModules = advancedModules[advancedModules.length - 1];

return (
<div className="banner-bg activity-pad">
<div
className={watched
? 'banner-bg activity-pad blur-background'
: 'banner-bg activity-pad'}
>
<div
className="activity-styles d-flex flex-column justify-content-start align-items-center w-100"
style={{ backgroundColor: '#1C1D37' }}
>
{/* <div className="col-12 col-md-3 pr-0 scroll-sidebar">
<CourseSidebar
course={course}
courseId={courseId}
modules={modules}
userModules={userModules}
/>
</div> */}

<div className="d-flex flex-column justify-content-center align-items-center mb-4 mt-4" style={{ width: '80%' }}>
<div className="d-flex flew-row mb-2 align-items-center justify-content-start" style={{ height: '48px', textAlign: 'center', width: '100%' }}>
<button className="ml-3 mr-3" type="button" onClick={() => router.back()}>
Expand All @@ -156,35 +159,37 @@ const ActivityDetails = ({

</div>
{/* youtube player */}
<div className="banner-bg d-flex justify-content-center" style={{ borderRadius: '30px', width: '100%' }}>
<div className="player-wrapper" style={{ width: '95%' }}>
<ReactPlayer
url={moduleInfo.url}
controls
width="100%"
height="700px"
style={{ height: '100%', maxWidth: '100%', overflowX: 'hidden' }}
onStart={onStart}
onEnded={handleWatch}
/>
<div
className="banner-bg d-flex justify-content-center"
style={{ borderRadius: '30px', width: '100%', height: '100%' }}>
<div className="player-wrapper" style={{ width: '95%', height: '100%' }}>
<div style={{ pointerEvents: (watched && isOpen) && 'none' }}>
<ReactPlayer
url={moduleInfo.url}
controls
width="100%"
height="700px"
style={{ height: '100%', maxWidth: '100%', overflowX: 'hidden' }}
onStart={onStart}
onEnded={handleWatch}
/>
</div>
{watched && isOpen && (
<>
{completed !== true && (
<QuizContext.Provider
value={{
isOpen,
setIsOpen,
setWatched,
singleUserModuleInfo,
forwardInfo,
course,
lastAdvancedModules,
}}
>
<QuizModal />
</QuizContext.Provider>
)}
</>
<div>
<QuizContext.Provider
value={{
isOpen,
setIsOpen,
setWatched,
singleUserModuleInfo,
forwardInfo,
course,
lastAdvancedModules,
}}
>
<QuizModal />
</QuizContext.Provider>
</div>
)}
</div>
</div>
Expand Down Expand Up @@ -242,7 +247,7 @@ const ActivityDetails = ({
}
}
>
<span>{completionStatus}</span>
<span>{completionStatus.toUpperCase()}</span>
</p>
</div>
<div className="text-white activity-details">
Expand All @@ -254,16 +259,13 @@ const ActivityDetails = ({
</div>
{/* Buttons */}
<div className="d-flex flex-row justify-content-between mb-4">
{/* <button className="lesson-button d-flex flex-row justify-content-center align-items-center p-3" style={{ lineHeight: '20px', border: '1px solid #6938EF', borderRadius: '20px' }}>
<FontAwesomeIcon icon={faArrowLeft} style={{ fontSize: '17px', color: 'white' }} className="icon mr-2" />
<p style={{ fontSize: '17px', color: 'white' }}>
Previous Lesson
</p>
</button> */}
<div className="d-flex flex-row">
<div className="d-flex flex-row justify-content-center align-items-center">
<button
type="button"
onClick={() => { (setWatched(true), setIsOpen(true)); }}
onClick={() => {
setWatched(!watched);
setIsOpen(true);
}}
className="quiz-button p-3"
style={{
lineHeight: '20px', border: '1px solid #6938EF', borderRadius: '20px', background: '#6938EF',
Expand All @@ -273,21 +275,10 @@ const ActivityDetails = ({
Take Quiz
</p>
</button>
{/* <button
type="button"
onClick={forwardInfo}
data-dismiss="modal"
aria-label="Close"
className="lesson-button d-flex flex-row justify-content-center p-3 ml-5 align-items-center" style={{ lineHeight: '20px', border: '1px solid #6938EF', borderRadius: '20px' }}>
<p className="mr-2" style={{ fontSize: '17px', color: 'white' }}>
Next Lesson
</p>
<FontAwesomeIcon icon={faArrowRight} style={{ fontSize: '17px', color: 'white' }} className="icon" />
</button> */}
</div>
</div>
<div className="w-100 mb-3 d-flex flex-column mb-3">
<p style={{ fontSize: '28px', color: 'white' }}>Addtional Resources</p>
<div className="w-100 mb-3 d-flex flex-column">
{/* <p style={{ fontSize: '28px', color: 'white' }}>Addtional Resources</p> */}
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions components/learn/courseDetails/CourseSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ const CourseSidebar = ({ course, modules, courseId, userModules }) => {
return (
<div className="course-sidebar pt-5">
<div className="ml-md-4 back-course mb-3">
<div onClick={() => router.push("/learn")}>
<button type="button" onClick={() => router.push("/learn")}>
<FontAwesomeIcon icon={faChevronLeft} />
<span className="ml-2">Courses</span>
</div>
</button>
</div>

<div className="weeks-info px-md-5">
Expand Down
6 changes: 3 additions & 3 deletions components/learn/courseDetails/coursesDetails.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
background: white;
color: #6938EF;
}

.blur-background{
filter: blur(5px);
}
/* User Banner */
.user-bannerBG {
background-color: #3e385d;
Expand Down Expand Up @@ -417,8 +419,6 @@
}
.course-weeks {
margin-top: 2rem;
margin-left: 1.5rem !important;
margin-right: 1.5rem !important;
}
.course-weeks .course-status {
margin-bottom: 1rem;
Expand Down
Loading