Skip to content

Commit

Permalink
refactor: address PR reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
mariajgrimaldi committed Feb 13, 2024
1 parent 429fc1e commit 7f173bb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 9 additions & 3 deletions src/courseware/course/sequence/sequence-navigation/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,6 +60,11 @@ export function useSequenceNavigationMetadata(currentSequenceId, currentUnitId)
}

return {
isFirstUnit, isLastUnit, nextLink, previousLink, navigationDisabledNextSequence, navigationDisabledPrevSequence,
isFirstUnit,
isLastUnit,
nextLink,
previousLink,
navigationDisabledNextSequence,
navigationDisabledPrevSequence,
};
}

0 comments on commit 7f173bb

Please sign in to comment.