1
1
import React , { useEffect , useContext , useState } from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
- import {
4
- Routes , Route , useLocation , useNavigate ,
5
- } from 'react-router-dom' ;
3
+ import { Routes , Route , useNavigate } from 'react-router-dom' ;
6
4
import { useDispatch , useSelector } from 'react-redux' ;
7
5
import { AppContext , PageWrap } from '@edx/frontend-platform/react' ;
8
6
import { injectIntl , FormattedMessage , intlShape } from '@edx/frontend-platform/i18n' ;
@@ -53,13 +51,11 @@ const CustomPages = ({
53
51
const [ orderedPages , setOrderedPages ] = useState ( [ ] ) ;
54
52
const [ currentPage , setCurrentPage ] = useState ( ) ;
55
53
const [ isOpen , open , close ] = useToggle ( false ) ;
56
- const [ isEditModalOpen , openEditModal , closeEditModal ] = useToggle ( false ) ;
57
54
58
55
const courseDetails = useModel ( 'courseDetails' , courseId ) ;
59
56
document . title = getPageHeadTitle ( courseDetails ?. name , intl . formatMessage ( messages . heading ) ) ;
60
57
61
58
const { config } = useContext ( AppContext ) ;
62
- const location = useLocation ( ) ;
63
59
const learningCourseURL = `${ config . LEARNING_BASE_URL } /course/${ courseId } ` ;
64
60
65
61
useEffect ( ( ) => {
@@ -79,15 +75,14 @@ const CustomPages = ({
79
75
dispatch ( updatePageOrder ( courseId , newPageOrder ) ) ;
80
76
} ;
81
77
const handleEditClose = ( ) => ( content ) => {
82
- navigate ( location . pathname ) ;
78
+ navigate ( `/course/ ${ courseId } /custom-pages` ) ;
83
79
if ( ! content ?. metadata ) {
84
- closeEditModal ( ) ;
80
+ setCurrentPage ( null ) ;
85
81
return ;
86
82
}
87
83
dispatch ( updateSingleCustomPage ( {
88
84
blockId : currentPage ,
89
85
metadata : { displayName : content . metadata . display_name } ,
90
- onClose : closeEditModal ,
91
86
setCurrentPage,
92
87
} ) ) ;
93
88
} ;
@@ -192,7 +187,6 @@ const CustomPages = ({
192
187
deletePageStatus,
193
188
courseId,
194
189
setCurrentPage,
195
- openEditModal,
196
190
} }
197
191
/>
198
192
</ SortableItem >
@@ -262,7 +256,6 @@ const CustomPages = ({
262
256
< PageWrap >
263
257
< EditModal
264
258
courseId = { courseId }
265
- isOpen = { isEditModalOpen }
266
259
pageId = { currentPage }
267
260
onClose = { handleEditClose }
268
261
/>
0 commit comments