diff --git a/src/components/Forms/LessonForm/EditLessonForm.tsx b/src/components/Forms/LessonForm/EditLessonForm.tsx index ac843ef..537d4fe 100644 --- a/src/components/Forms/LessonForm/EditLessonForm.tsx +++ b/src/components/Forms/LessonForm/EditLessonForm.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { yupResolver } from '@hookform/resolvers/yup'; import { SubmitHandler, useForm } from 'react-hook-form'; import type { InputFields } from './LessonForm'; +import { ILesson } from '@educt/interfaces'; import { LessonForm } from '.'; /** @@ -12,8 +13,7 @@ import { EditLessonFormSchema } from './LessonForm.validator'; /** * Hooks */ -import { useParams } from 'react-router-dom'; -import { ILesson } from '@educt/interfaces'; +import { useHistory, useParams } from 'react-router-dom'; import { useUpdateLesson } from '@educt/hooks/queries'; type EditLessonFormPropsType = { @@ -33,6 +33,7 @@ const EditLessonForm: React.FC = ({ lesson }) => { }); const { updateLesson, isLoading } = useUpdateLesson(); const { id } = useParams<{ id: string }>(); + const history = useHistory(); const onSubmit: SubmitHandler = async data => { await updateLesson(id, { @@ -42,6 +43,8 @@ const EditLessonForm: React.FC = ({ lesson }) => { duration: data.duration, materials: data.materials?.length !== 0 ? Array.from(data.materials || []) : null, }); + + history.push(`/lesson/${id}`); }; return (