fix: LectureInfo 호출에 따른 불필요 state 제거

This commit is contained in:
정기영 2024-08-13 17:42:27 +09:00
parent bd91d27c47
commit ca4dc1a839
2 changed files with 5 additions and 19 deletions

View File

@ -24,14 +24,6 @@ export default function LectureLayout() {
navigate('..');
});
};
const lectureData = {
title: lecture.title,
description: lecture.description,
plan: lecture.plan,
startDate: lecture.startDate,
endDate: lecture.endDate,
time: lecture.time,
};
useEffect(() => {
if (['NOT_ENROLLED', 'MANAGED_BY_OTHERS', 'PENDING'].includes(lecture.status)) {
@ -66,12 +58,7 @@ export default function LectureLayout() {
{userType === 'teacher' && (
<SideBar title={'강의 정보 관리'}>
<SideLink to={'teacherReportsets'}>퀴즈 성적 보기</SideLink>
<SideLink
to={'edit'}
state={lectureData}
>
강의 정보 수정
</SideLink>
<SideLink to={'edit'}>강의 정보 수정</SideLink>
<li>
<span
onClick={handleDelete}

View File

@ -1,13 +1,12 @@
import { LectureForm } from '../../components/LectureForm';
import { useLectureEdit } from '../../hooks/api/useLectureEdit';
import { useParams, useNavigate, useLocation } from 'react-router-dom';
import { useParams, useNavigate } from 'react-router-dom';
import { useLectureInfo } from '../../hooks/api/useLectureInfo';
export default function LecutreEditPage() {
const { lectureId } = useParams();
const location = useLocation();
const initialData = location.state.from;
const lectureInfo = useLectureInfo(lectureId);
const { data, refetch } = useLectureInfo(lectureId);
const initialData = data.data;
const navigate = useNavigate();
const { lectureEdit } = useLectureEdit();
@ -15,7 +14,7 @@ export default function LecutreEditPage() {
const handleSubmit = async (lectureObject) =>
await lectureEdit(lectureId, lectureObject)
.then(() => {
lectureInfo.refetch();
refetch();
navigate('..');
})
.catch(() => {});