diff --git a/apps/web/app/orgs/[orgslug]/(withmenu)/course/[courseuuid]/course.tsx b/apps/web/app/orgs/[orgslug]/(withmenu)/course/[courseuuid]/course.tsx index c8f2ea19..716a5e1a 100644 --- a/apps/web/app/orgs/[orgslug]/(withmenu)/course/[courseuuid]/course.tsx +++ b/apps/web/app/orgs/[orgslug]/(withmenu)/course/[courseuuid]/course.tsx @@ -22,6 +22,7 @@ import CourseActionsMobile from '@components/Objects/Courses/CourseActions/Cours const CourseClient = (props: any) => { const [learnings, setLearnings] = useState([]) + const [expandedChapters, setExpandedChapters] = useState<{[key: string]: boolean}>({}) const courseuuid = props.courseuuid const orgslug = props.orgslug const course = props.course @@ -112,8 +113,8 @@ const CourseClient = (props: any) => {

About

-
-

{course.about}

+
+

{course.about}

{learnings.length > 0 && learnings[0]?.text !== 'null' && ( @@ -164,117 +165,113 @@ const CourseClient = (props: any) => {

Course Lessons

{course.chapters.map((chapter: any) => { + const isExpanded = expandedChapters[chapter.chapter_uuid] ?? true; // Default to expanded return (
-
+
setExpandedChapters(prev => ({ + ...prev, + [chapter.chapter_uuid]: !isExpanded + }))} + >

{chapter.name}

-

- {chapter.activities.length} Activities -

+
+

+ {chapter.activities.length} Activities +

+ + + +
-
- {chapter.activities.map((activity: any) => { - return ( -
-

-
-
- {activity.activity_type === - 'TYPE_DYNAMIC' && ( -
- -
- )} - {activity.activity_type === 'TYPE_VIDEO' && ( -
-
- )} - {activity.activity_type === - 'TYPE_DOCUMENT' && ( -
- -
- )} - {activity.activity_type === - 'TYPE_ASSIGNMENT' && ( -
- -
- )} -
- -

{activity.name}

- -
- {activity.activity_type === - 'TYPE_DYNAMIC' && ( -
- -
-

Page

- -
- -
- )} - {activity.activity_type === 'TYPE_VIDEO' && ( -
- -
-

Video

- +
+
+ {chapter.activities.map((activity: any) => { + return ( +
+

+
+
+ {activity.activity_type === + 'TYPE_DYNAMIC' && ( +
+
- -
- )} - {activity.activity_type === - 'TYPE_DOCUMENT' && ( + )} + {activity.activity_type === 'TYPE_VIDEO' && ( +
+
+ )} + {activity.activity_type === + 'TYPE_DOCUMENT' && ( +
+ +
+ )} + {activity.activity_type === + 'TYPE_ASSIGNMENT' && ( +
+ +
+ )} +
+ +

{activity.name}

+ +
+ {activity.activity_type === + 'TYPE_DYNAMIC' && ( +
+ +
+

Page

+ +
+ +
+ )} + {activity.activity_type === 'TYPE_VIDEO' && (
{ prefetch={false} >
-

Document

- -
- -
- )} - {activity.activity_type === - 'TYPE_ASSIGNMENT' && ( -
- -
-

Assignment

+

Video

)} + {activity.activity_type === + 'TYPE_DOCUMENT' && ( +
+ +
+

Document

+ +
+ +
+ )} + {activity.activity_type === + 'TYPE_ASSIGNMENT' && ( +
+ +
+

Assignment

+ +
+ +
+ )} +
-
- ) - })} + ) + })} +
)