Skip to content

Commit

Permalink
fix: modal exit redirect (openedx#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinAoki authored and Ian2012 committed Nov 15, 2023
1 parent e897f4d commit c92d777
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/custom-pages/CustomPages.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { useEffect, useContext, useState } from 'react';
import PropTypes from 'prop-types';
import {
Routes, Route, useLocation, useNavigate,
} from 'react-router-dom';
import { Routes, Route, useNavigate } from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';
import { AppContext, PageWrap } from '@edx/frontend-platform/react';
import { injectIntl, FormattedMessage, intlShape } from '@edx/frontend-platform/i18n';
Expand Down Expand Up @@ -53,13 +51,11 @@ const CustomPages = ({
const [orderedPages, setOrderedPages] = useState([]);
const [currentPage, setCurrentPage] = useState();
const [isOpen, open, close] = useToggle(false);
const [isEditModalOpen, openEditModal, closeEditModal] = useToggle(false);

const courseDetails = useModel('courseDetails', courseId);
document.title = getPageHeadTitle(courseDetails?.name, intl.formatMessage(messages.heading));

const { config } = useContext(AppContext);
const location = useLocation();
const learningCourseURL = `${config.LEARNING_BASE_URL}/course/${courseId}`;

useEffect(() => {
Expand All @@ -79,15 +75,14 @@ const CustomPages = ({
dispatch(updatePageOrder(courseId, newPageOrder));
};
const handleEditClose = () => (content) => {
navigate(location.pathname);
navigate(`/course/${courseId}/custom-pages`);
if (!content?.metadata) {
closeEditModal();
setCurrentPage(null);
return;
}
dispatch(updateSingleCustomPage({
blockId: currentPage,
metadata: { displayName: content.metadata.display_name },
onClose: closeEditModal,
setCurrentPage,
}));
};
Expand Down Expand Up @@ -192,7 +187,6 @@ const CustomPages = ({
deletePageStatus,
courseId,
setCurrentPage,
openEditModal,
}}
/>
</SortableItem>
Expand Down Expand Up @@ -262,7 +256,6 @@ const CustomPages = ({
<PageWrap>
<EditModal
courseId={courseId}
isOpen={isEditModalOpen}
pageId={currentPage}
onClose={handleEditClose}
/>
Expand Down

0 comments on commit c92d777

Please sign in to comment.