From 7f173bb5ffbcaa971506131ae53365d3bb60b884 Mon Sep 17 00:00:00 2001 From: Maria Grimaldi Date: Tue, 13 Feb 2024 09:07:14 -0400 Subject: [PATCH] refactor: address PR reviews --- .../sequence-navigation/SequenceNavigation.jsx | 7 ++++++- .../course/sequence/sequence-navigation/hooks.js | 12 +++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/courseware/course/sequence/sequence-navigation/SequenceNavigation.jsx b/src/courseware/course/sequence/sequence-navigation/SequenceNavigation.jsx index 73fb3ae29d..647b57943f 100644 --- a/src/courseware/course/sequence/sequence-navigation/SequenceNavigation.jsx +++ b/src/courseware/course/sequence/sequence-navigation/SequenceNavigation.jsx @@ -32,7 +32,12 @@ const SequenceNavigation = ({ }) => { const sequence = useModel('sequences', sequenceId); const { - isFirstUnit, isLastUnit, nextLink, previousLink, navigationDisabledPrevSequence, navigationDisabledNextSequence, + isFirstUnit, + isLastUnit, + nextLink, + previousLink, + navigationDisabledPrevSequence, + navigationDisabledNextSequence, } = useSequenceNavigationMetadata(sequenceId, unitId); const { courseId, diff --git a/src/courseware/course/sequence/sequence-navigation/hooks.js b/src/courseware/course/sequence/sequence-navigation/hooks.js index fda302465d..d049e194fb 100644 --- a/src/courseware/course/sequence/sequence-navigation/hooks.js +++ b/src/courseware/course/sequence/sequence-navigation/hooks.js @@ -30,8 +30,9 @@ export function useSequenceNavigationMetadata(currentSequenceId, currentUnitId) const isLastSequence = sequenceIndex === sequenceIds.length - 1; const isLastUnitInSequence = unitIndex === sequence.unitIds.length - 1; const isLastUnit = isLastSequence && isLastUnitInSequence; - const navigationDisabledPrevSequence = sequence && sequence.navigationDisabled && isFirstUnitInSequence; - const navigationDisabledNextSequence = sequence && sequence.navigationDisabled && isLastUnitInSequence; + const sequenceNavigationDisabled = sequence?.navigationDisabled; + const navigationDisabledPrevSequence = sequenceNavigationDisabled && isFirstUnitInSequence; + const navigationDisabledNextSequence = sequenceNavigationDisabled && isLastUnitInSequence; const nextSequenceId = sequenceIndex < sequenceIds.length - 1 ? sequenceIds[sequenceIndex + 1] : null; const previousSequenceId = sequenceIndex > 0 ? sequenceIds[sequenceIndex - 1] : null; @@ -59,6 +60,11 @@ export function useSequenceNavigationMetadata(currentSequenceId, currentUnitId) } return { - isFirstUnit, isLastUnit, nextLink, previousLink, navigationDisabledNextSequence, navigationDisabledPrevSequence, + isFirstUnit, + isLastUnit, + nextLink, + previousLink, + navigationDisabledNextSequence, + navigationDisabledPrevSequence, }; }