From 082f661ccbe1402ce1c57efda98dfa3eef8a67f5 Mon Sep 17 00:00:00 2001 From: swve Date: Fri, 27 Jun 2025 15:50:09 +0200 Subject: [PATCH] feat: enhance course chapter display with expanded first chapter and activity count badge --- .../(withmenu)/course/[courseuuid]/course.tsx | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) 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 672101ea..69a1ddef 100644 --- a/apps/web/app/orgs/[orgslug]/(withmenu)/course/[courseuuid]/course.tsx +++ b/apps/web/app/orgs/[orgslug]/(withmenu)/course/[courseuuid]/course.tsx @@ -10,7 +10,7 @@ import GeneralWrapperStyled from '@components/Objects/StyledElements/Wrappers/Ge import { getCourseThumbnailMediaDirectory, } from '@services/media/media' -import { ArrowRight, Backpack, Check, File, Sparkles, StickyNote, Video, Square, Image as ImageIcon } from 'lucide-react' +import { ArrowRight, Backpack, Check, File, Sparkles, StickyNote, Video, Square, Image as ImageIcon, Layers } from 'lucide-react' import { useOrg } from '@components/Contexts/OrgContext' import { CourseProvider } from '@components/Contexts/CourseContext' import { useMediaQuery } from 'usehooks-ts' @@ -77,8 +77,9 @@ const CourseClient = (props: any) => { if (course?.chapters) { const totalActivities = course.chapters.reduce((sum: number, chapter: any) => sum + (chapter.activities?.length || 0), 0) const defaultExpanded: {[key: string]: boolean} = {} - course.chapters.forEach((chapter: any) => { - defaultExpanded[chapter.chapter_uuid] = totalActivities <= 5 + course.chapters.forEach((chapter: any, idx: number) => { + // Always expand the first chapter + defaultExpanded[chapter.chapter_uuid] = idx === 0 ? true : totalActivities <= 5 }) setExpandedChapters(defaultExpanded) } @@ -342,24 +343,21 @@ const CourseClient = (props: any) => {

Course Lessons

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

{chapter.name}

-
-

- {chapter.activities.length} Activities -

+ {/* Chevron on the far left, vertically centered with the title */} +
{
+ {/* Title and badge column */} +
+
+ {/* Numbered badge */} + + {idx + 1} + +

{chapter.name}

+
+
+ + {chapter.activities.length} Activities +
+