Skip to content

Commit

Permalink
fix: Fixes the saving pop-up to appear
Browse files Browse the repository at this point in the history
Moves the array updation statement and introduces two ways of updating
the grading statement.

Signed-off-by: Farhaan Bukhsh <[email protected]>
  • Loading branch information
farhaanbukhsh committed Oct 21, 2024
1 parent 3b56fab commit 26872db
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions src/grading-settings/grading-scale/GradingScale.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,39 +56,42 @@ const GradingScale = ({

const addNewGradingSegment = () => {
setGradingSegments(prevSegments => {
let updatedGradingSegment = [];
if (prevSegments.length >= 5) {
const segSize = MAXIMUM_SCALE_LENGTH / (prevSegments.length + 1);
return Array.from({ length: prevSegments.length + 1 }).map((_, i) => (
updatedGradingSegment = Array.from({ length: prevSegments.length + 1 }).map((_, i) => (
{
current: 100 - i * segSize,
previous: 100 - (i + 1) * segSize,
}
));
}

Check failure on line 68 in src/grading-settings/grading-scale/GradingScale.jsx

View workflow job for this annotation

GitHub Actions / tests

Closing curly brace does not appear on the same line as the subsequent block
const firstSegment = prevSegments[prevSegments.length - 1];
const secondSegment = prevSegments[prevSegments.length - 2];
const newCurrentValue = Math.ceil((secondSegment.current - secondSegment.previous) / 2);

const newSegment = {
current: (firstSegment.current + newCurrentValue),
previous: firstSegment.current,
};
else {
const firstSegment = prevSegments[prevSegments.length - 1];
const secondSegment = prevSegments[prevSegments.length - 2];
const newCurrentValue = Math.ceil((secondSegment.current - secondSegment.previous) / 2);

const newSegment = {
current: (firstSegment.current + newCurrentValue),
previous: firstSegment.current,
};

const updatedSecondSegment = {
...secondSegment,
previous: (firstSegment.current + newCurrentValue),
};
const updatedSecondSegment = {
...secondSegment,
previous: (firstSegment.current + newCurrentValue),
};
updatedGradingSegment = [
...prevSegments.slice(0, prevSegments.length - 2),
updatedSecondSegment,
newSegment,
firstSegment,
];
}

showSavePrompt(true);
setShowSuccessAlert(false);
setOverrideInternetConnectionAlert(false);

return [
...prevSegments.slice(0, prevSegments.length - 2),
updatedSecondSegment,
newSegment,
firstSegment,
];
return updatedGradingSegment;
});

const nextIndex = (letters.length % defaultGradeDesignations.length);
Expand Down

0 comments on commit 26872db

Please sign in to comment.