Skip to content

Commit 7d35166

Browse files
committed
feat: open collections page on save
1 parent 8cfe07a commit 7d35166

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/library-authoring/create-collection/CreateCollectionModal.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
Form,
66
ModalDialog,
77
} from '@openedx/paragon';
8-
import { useParams } from 'react-router-dom';
8+
import { useNavigate, useParams } from 'react-router-dom';
99
import { useIntl } from '@edx/frontend-platform/i18n';
1010
import { Formik } from 'formik';
1111
import * as Yup from 'yup';
@@ -17,6 +17,7 @@ import { ToastContext } from '../../generic/toast-context';
1717

1818
const CreateCollectionModal = () => {
1919
const intl = useIntl();
20+
const navigate = useNavigate();
2021
const { libraryId } = useParams();
2122
if (!libraryId) {
2223
throw new Error('Rendered without libraryId URL parameter');
@@ -29,8 +30,9 @@ const CreateCollectionModal = () => {
2930
const { showToast } = React.useContext(ToastContext);
3031

3132
const handleCreate = React.useCallback((values) => {
32-
create.mutateAsync(values).then(() => {
33+
create.mutateAsync(values).then((data) => {
3334
closeCreateCollectionModal();
35+
navigate(`/library/${libraryId}/collections/${data.key}`);
3436
showToast(intl.formatMessage(messages.createCollectionSuccess));
3537
}).catch(() => {
3638
showToast(intl.formatMessage(messages.createCollectionError));

0 commit comments

Comments
 (0)