fix: AA-1194: Update the breadcrumb link (#829)

Before, for sections, it would link you to the chapter which would
cause a JS error since the sequence endpoint expects sequentials.
This updates to now link to the first subsection within a section when
you hit the section breadcrumb
This commit is contained in:
Dillon Dumesnil
2022-02-17 12:45:13 -08:00
committed by GitHub
parent 74484b7847
commit 8285d42b7e

View File

@@ -15,8 +15,7 @@ import JumpNavMenuItem from './JumpNavMenuItem';
function CourseBreadcrumb({
content, withSeparator, courseId, sequenceId, unitId, isStaff,
}) {
const defaultContent = content.filter(destination => destination.default)[0] || { id: courseId, label: '' };
const defaultContent = content.filter(destination => destination.default)[0] || { id: courseId, label: '', sequences: [] };
return (
<>
{withSeparator && (
@@ -33,7 +32,9 @@ function CourseBreadcrumb({
? (
<Link
className="text-primary-500"
to={`/course/${courseId}/${defaultContent.id}`}
to={defaultContent.sequences.length
? `/course/${courseId}/${defaultContent.sequences[0].id}`
: `/course/${courseId}/${defaultContent.id}`}
>
{defaultContent.label}
</Link>