Skip to content

Commit

Permalink
MER-3138
Browse files Browse the repository at this point in the history
  • Loading branch information
dtiwarATS committed Apr 17, 2024
1 parent 77631b3 commit a21227a
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { Fragment, useCallback, useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import { ActionFailure, ActionResult, finalizePageAttempt } from 'data/persistence/page_lifecycle';
import {
selectIsGraded,
selectPageSlug,
selectPreviewMode,
selectResourceAttemptGuid,
Expand All @@ -24,7 +23,6 @@ const LessonFinishedDialog: React.FC<LessonFinishedDialogProps> = ({
const [redirectURL, setRedirectURL] = useState('');
const [finalizeError, setFinalizeError] = useState<string | null>(null);
const isPreviewMode = useSelector(selectPreviewMode);
const graded = useSelector(selectIsGraded);
const revisionSlug = useSelector(selectPageSlug);
const sectionSlug = useSelector(selectSectionSlug);
const resourceAttemptGuid = useSelector(selectResourceAttemptGuid);
Expand All @@ -39,7 +37,7 @@ const LessonFinishedDialog: React.FC<LessonFinishedDialogProps> = ({
return;
}
setIsOpen(false);
if (!graded || isPreviewMode) {
if (isPreviewMode) {
window.location.reload();
} else {
window.location.href = redirectURL;
Expand All @@ -48,7 +46,7 @@ const LessonFinishedDialog: React.FC<LessonFinishedDialogProps> = ({

const handleFinalization = useCallback(async () => {
setFinalizationCalled(true);
if (!isPreviewMode && graded) {
if (!isPreviewMode) {
// only graded pages are finalized
try {
const finalizeResult = await finalizePageAttempt(
Expand Down Expand Up @@ -86,7 +84,7 @@ const LessonFinishedDialog: React.FC<LessonFinishedDialogProps> = ({
}
}
setIsFinalized(true);
}, [sectionSlug, revisionSlug, resourceAttemptGuid, graded, isPreviewMode]);
}, [sectionSlug, revisionSlug, resourceAttemptGuid, isPreviewMode]);

useEffect(() => {
// TODO: maybe we should call finalization elsewhere than in this modal
Expand Down

0 comments on commit a21227a

Please sign in to comment.