Merge branch 'FE/LecutreEditPage' into 'frontend'

[Front-End] fix: LectureInfo 호출에 따른 불필요 state 제거

See merge request s11-webmobile1-sub2/S11P12A701!196
This commit is contained in:
조민우 2024-08-13 17:56:31 +09:00
commit 5555121f61
2 changed files with 5 additions and 19 deletions

View File

@ -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)) {
@ -67,12 +59,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}

View File

@ -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(() => {});