fix: LectureInfo 호출에 따른 불필요 state 제거
This commit is contained in:
parent
bd91d27c47
commit
ca4dc1a839
@ -24,14 +24,6 @@ export default function LectureLayout() {
|
|||||||
navigate('..');
|
navigate('..');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const lectureData = {
|
|
||||||
title: lecture.title,
|
|
||||||
description: lecture.description,
|
|
||||||
plan: lecture.plan,
|
|
||||||
startDate: lecture.startDate,
|
|
||||||
endDate: lecture.endDate,
|
|
||||||
time: lecture.time,
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (['NOT_ENROLLED', 'MANAGED_BY_OTHERS', 'PENDING'].includes(lecture.status)) {
|
if (['NOT_ENROLLED', 'MANAGED_BY_OTHERS', 'PENDING'].includes(lecture.status)) {
|
||||||
@ -66,12 +58,7 @@ export default function LectureLayout() {
|
|||||||
{userType === 'teacher' && (
|
{userType === 'teacher' && (
|
||||||
<SideBar title={'강의 정보 관리'}>
|
<SideBar title={'강의 정보 관리'}>
|
||||||
<SideLink to={'teacherReportsets'}>퀴즈 성적 보기</SideLink>
|
<SideLink to={'teacherReportsets'}>퀴즈 성적 보기</SideLink>
|
||||||
<SideLink
|
<SideLink to={'edit'}>강의 정보 수정</SideLink>
|
||||||
to={'edit'}
|
|
||||||
state={lectureData}
|
|
||||||
>
|
|
||||||
강의 정보 수정
|
|
||||||
</SideLink>
|
|
||||||
<li>
|
<li>
|
||||||
<span
|
<span
|
||||||
onClick={handleDelete}
|
onClick={handleDelete}
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
import { LectureForm } from '../../components/LectureForm';
|
import { LectureForm } from '../../components/LectureForm';
|
||||||
import { useLectureEdit } from '../../hooks/api/useLectureEdit';
|
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';
|
import { useLectureInfo } from '../../hooks/api/useLectureInfo';
|
||||||
|
|
||||||
export default function LecutreEditPage() {
|
export default function LecutreEditPage() {
|
||||||
const { lectureId } = useParams();
|
const { lectureId } = useParams();
|
||||||
const location = useLocation();
|
const { data, refetch } = useLectureInfo(lectureId);
|
||||||
const initialData = location.state.from;
|
const initialData = data.data;
|
||||||
const lectureInfo = useLectureInfo(lectureId);
|
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { lectureEdit } = useLectureEdit();
|
const { lectureEdit } = useLectureEdit();
|
||||||
@ -15,7 +14,7 @@ export default function LecutreEditPage() {
|
|||||||
const handleSubmit = async (lectureObject) =>
|
const handleSubmit = async (lectureObject) =>
|
||||||
await lectureEdit(lectureId, lectureObject)
|
await lectureEdit(lectureId, lectureObject)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
lectureInfo.refetch();
|
refetch();
|
||||||
navigate('..');
|
navigate('..');
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
Loading…
Reference in New Issue
Block a user