feat: Make the chapter icons clickable in the navigation bar

This commit is contained in:
swve 2025-06-18 19:36:49 +02:00
parent 35b96c4473
commit e239eb5a31

View file

@ -235,6 +235,12 @@ function ActivityIndicators(props: Props) {
{course.chapters.map((chapter: any, chapterIndex: number) => {
const completedActivities = getChapterProgress(chapter.activities);
const isChapterComplete = completedActivities === chapter.activities.length;
const firstActivity = chapter.activities[0];
const firstActivityId = firstActivity?.activity_uuid?.replace('activity_', '');
const chapterLinkHref =
firstActivityId
? getUriWithOrg(orgslug, '') + `/course/${courseid}/activity/${firstActivityId}`
: undefined;
return (
<React.Fragment key={chapter.id}>
@ -250,7 +256,18 @@ function ActivityIndicators(props: Props) {
/>
}
>
<div className="mx-2 h-[20px] flex items-center cursor-help">
{chapterLinkHref ? (
<Link href={chapterLinkHref} prefetch={false} className="mx-2 h-[20px] flex items-center cursor-pointer focus:outline-none">
<div className={`w-[20px] h-[20px] rounded-full flex items-center justify-center text-xs font-medium transition-colors ${
isChapterComplete
? 'bg-teal-600 text-white'
: 'bg-gray-100 text-gray-600'
}`}>
{chapterIndex + 1}
</div>
</Link>
) : (
<div className="mx-2 h-[20px] flex items-center cursor-not-allowed">
<div className={`w-[20px] h-[20px] rounded-full flex items-center justify-center text-xs font-medium transition-colors ${
isChapterComplete
? 'bg-teal-600 text-white'
@ -259,6 +276,7 @@ function ActivityIndicators(props: Props) {
{chapterIndex + 1}
</div>
</div>
)}
</ToolTip>
<div className="flex-1 flex items-center">
{chapter.activities.map((activity: any) => {