From 73cc7d5e99b8561421ff7fcc364c2dfcbd4d04cc Mon Sep 17 00:00:00 2001 From: jhynsoo Date: Thu, 8 Aug 2024 14:49:26 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=A0=91=EA=B7=BC=ED=95=A0=20=EC=88=98?= =?UTF-8?q?=20=EC=97=86=EB=8A=94=20=EA=B0=95=EC=9D=98=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EC=A0=91=EA=B7=BC=20=EB=AA=BB=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/Router.jsx | 4 +- .../Article/ArticleDetail/ArticleDetail.jsx | 45 ++++++++++++------- .../src/components/ClassInfo/ClassInfo.jsx | 20 +++++---- .../src/components/Layout/LectureLayout.jsx | 8 +++- .../src/components/Layout/MyPageLayout.jsx | 6 ++- frontend/src/hooks/api/useAnswerDelete.js | 2 +- .../pages/DefaultHomePage/DefaultHomePage.jsx | 2 +- .../LearningLecturesPage.jsx | 7 ++- .../pages/LectureInfoPage/LectureInfoPage.jsx | 2 +- .../NoticeDetailPage/NoticeDetailPage.jsx | 1 + .../pages/StudentHomePage/StudentHomePage.jsx | 4 +- .../pages/TeacherHomePage/TeacherHomePage.jsx | 2 +- .../TeacherHomePage.module.css | 4 +- 13 files changed, 69 insertions(+), 38 deletions(-) diff --git a/frontend/src/Router.jsx b/frontend/src/Router.jsx index 0e47bde..583d228 100644 --- a/frontend/src/Router.jsx +++ b/frontend/src/Router.jsx @@ -68,11 +68,11 @@ const router = createBrowserRouter([ element: , }, { - path: 'lecture/:lectureId/info', + path: 'lecture/:lectureId', element: , }, { - path: 'lecture/:lectureId', + path: 'lecture/:lectureId/class', element: , children: [ { diff --git a/frontend/src/components/Article/ArticleDetail/ArticleDetail.jsx b/frontend/src/components/Article/ArticleDetail/ArticleDetail.jsx index 139d35c..0d6150e 100644 --- a/frontend/src/components/Article/ArticleDetail/ArticleDetail.jsx +++ b/frontend/src/components/Article/ArticleDetail/ArticleDetail.jsx @@ -4,10 +4,21 @@ import styles from './ArticleDetail.module.css'; import ArticleDetailAnswer from './ArticleDetailAnswer/ArticleDetailAnswer'; import ArticleDetailAnswerInput from './ArticleDetailAnswer/ArticleDetailAnswerInput'; import { useState, useEffect } from 'react'; +import useBoundStore from '../../../store'; -export default function ArticleDetail({ topic, title, author = null, content, answer = null, onDelete, isQna = true }) { +export default function ArticleDetail({ + topic, + title, + author = null, + content, + answer = null, + onDelete, + isMine = false, + isQna = true, +}) { const [submittedAnswer, setSubmittedAnswer] = useState(answer); const [isEditing, setIsEditing] = useState(false); + const userType = useBoundStore((state) => state.userType); useEffect(() => { setSubmittedAnswer(answer); @@ -44,20 +55,24 @@ export default function ArticleDetail({ topic, title, author = null, content, an
- - 수정 - - + {(isMine || userType === 'teacher') && ( + <> + + 수정 + + + + )}
diff --git a/frontend/src/components/ClassInfo/ClassInfo.jsx b/frontend/src/components/ClassInfo/ClassInfo.jsx index cf7d207..68e6cc1 100644 --- a/frontend/src/components/ClassInfo/ClassInfo.jsx +++ b/frontend/src/components/ClassInfo/ClassInfo.jsx @@ -15,15 +15,17 @@ export default function ClassInfo({ classTerm, classTime, status = 'NOT_ENROLLED
{classTime}
- + {status !== 'MANAGED_BY_OTHERS' && ( + + )} ); } diff --git a/frontend/src/components/Layout/LectureLayout.jsx b/frontend/src/components/Layout/LectureLayout.jsx index db8874e..4202c14 100644 --- a/frontend/src/components/Layout/LectureLayout.jsx +++ b/frontend/src/components/Layout/LectureLayout.jsx @@ -3,7 +3,7 @@ import { Outlet, useParams } from 'react-router-dom'; import LectureHeader from '../LectureHeader/LectureHeader'; import { SideBar, SideLink, SideItem } from '../SideBar'; import MaxWidthLayout from './MaxWidthLayout'; -import { Suspense } from 'react'; +import { Suspense, useEffect } from 'react'; import useBoundStore from '../../store'; import { useLectureInfo } from '../../hooks/api/useLectureInfo'; import LoadingIndicator from '../LoadingIndicator.jsx/LoadingIndicator'; @@ -34,6 +34,12 @@ export default function LectureLayout() { time: lecture.time, }; + useEffect(() => { + if (['NOT_ENROLLED', 'MANAGED_BY_OTHERS', 'PENDING'].includes(lecture.status)) { + navigate('..'); + } + }, [lecture.status, navigate]); + return ( <> state.userType); + const myLectureTitle = userType === 'student' ? '수강중인 강의' : '내 강의'; + return ( <> @@ -15,7 +19,7 @@ export default function MyPageLayout() { to={''} end > - 수강중인 강의 + {myLectureTitle} 개인정보 변경 비밀번호 변경 diff --git a/frontend/src/hooks/api/useAnswerDelete.js b/frontend/src/hooks/api/useAnswerDelete.js index 39c303e..30c06c0 100644 --- a/frontend/src/hooks/api/useAnswerDelete.js +++ b/frontend/src/hooks/api/useAnswerDelete.js @@ -6,7 +6,7 @@ export function useAnswerDelete() { const newAnswer = { answer: null, }; - return instance.post(`${API_URL}/qna/answer/create/${questionId}`, newAnswer); + return instance.post(`${API_URL}/qna/answer/delete/${questionId}`, newAnswer); }; return { answerDelete }; diff --git a/frontend/src/pages/DefaultHomePage/DefaultHomePage.jsx b/frontend/src/pages/DefaultHomePage/DefaultHomePage.jsx index db1a1e5..bc86d1f 100644 --- a/frontend/src/pages/DefaultHomePage/DefaultHomePage.jsx +++ b/frontend/src/pages/DefaultHomePage/DefaultHomePage.jsx @@ -14,7 +14,7 @@ export default function StudentHomePage() { {allClasses.map?.((lecture) => ( {lecture.title} diff --git a/frontend/src/pages/LearningLecturesPage/LearningLecturesPage.jsx b/frontend/src/pages/LearningLecturesPage/LearningLecturesPage.jsx index 2b6be71..d3ab6ed 100644 --- a/frontend/src/pages/LearningLecturesPage/LearningLecturesPage.jsx +++ b/frontend/src/pages/LearningLecturesPage/LearningLecturesPage.jsx @@ -3,21 +3,24 @@ import { Link } from 'react-router-dom'; import { useMyLectures } from '../../hooks/api/useMyLectures'; import CompassIcon from '/src/assets/icons/compass.svg?react'; import { STATIC_URL } from '../../constants'; +import useBoundStore from '../../store'; export default function LearningLecturesPage() { const { data } = useMyLectures(); const onGoingClasses = data?.data ?? []; const hasOnGoingClasses = onGoingClasses.length > 0; + const userType = useBoundStore((state) => state.userType); + const myLectureTitle = userType === 'student' ? '수강중인 강의' : '내 강의'; return (
-

수강중인 강의

+

{myLectureTitle}

{hasOnGoingClasses ? ( onGoingClasses.map?.((lecture) => ( {lecture.image ? ( diff --git a/frontend/src/pages/LectureInfoPage/LectureInfoPage.jsx b/frontend/src/pages/LectureInfoPage/LectureInfoPage.jsx index 5b674e4..838cc1f 100644 --- a/frontend/src/pages/LectureInfoPage/LectureInfoPage.jsx +++ b/frontend/src/pages/LectureInfoPage/LectureInfoPage.jsx @@ -24,7 +24,7 @@ export default function LectureInfoPage() { } if (status === 'ENROLLED') { - navigate(`/lecture/${lectureId}`); + navigate(`/lecture/${lectureId}/class`); } if (status === 'NOT_ENROLLED') { diff --git a/frontend/src/pages/NoticeDetailPage/NoticeDetailPage.jsx b/frontend/src/pages/NoticeDetailPage/NoticeDetailPage.jsx index 727845f..6d91d0d 100644 --- a/frontend/src/pages/NoticeDetailPage/NoticeDetailPage.jsx +++ b/frontend/src/pages/NoticeDetailPage/NoticeDetailPage.jsx @@ -23,6 +23,7 @@ export default function NoticeDetailPage() { content={notice.content} onDelete={handleDelete} isQna={false} + isMine={notice.mine} /> ); } diff --git a/frontend/src/pages/StudentHomePage/StudentHomePage.jsx b/frontend/src/pages/StudentHomePage/StudentHomePage.jsx index 4d75deb..43be65d 100644 --- a/frontend/src/pages/StudentHomePage/StudentHomePage.jsx +++ b/frontend/src/pages/StudentHomePage/StudentHomePage.jsx @@ -20,7 +20,7 @@ export default function StudentHomePage() { onGoingClasses.map?.((lecture) => ( {lecture.title} @@ -34,7 +34,7 @@ export default function StudentHomePage() { {allClasses.map?.((lecture) => ( {lecture.title} diff --git a/frontend/src/pages/TeacherHomePage/TeacherHomePage.jsx b/frontend/src/pages/TeacherHomePage/TeacherHomePage.jsx index cc730ec..650aaf1 100644 --- a/frontend/src/pages/TeacherHomePage/TeacherHomePage.jsx +++ b/frontend/src/pages/TeacherHomePage/TeacherHomePage.jsx @@ -16,7 +16,7 @@ export default function TeacherHomePage() { {onGoingClasses.map((lecture) => ( {lecture.title} diff --git a/frontend/src/pages/TeacherHomePage/TeacherHomePage.module.css b/frontend/src/pages/TeacherHomePage/TeacherHomePage.module.css index fa3c693..2e5837d 100644 --- a/frontend/src/pages/TeacherHomePage/TeacherHomePage.module.css +++ b/frontend/src/pages/TeacherHomePage/TeacherHomePage.module.css @@ -5,8 +5,8 @@ align-items: center; gap: 20px; margin-bottom: 32px; - width: 295px; - height: 220px; + width: 100%; + aspect-ratio: 4/3; background-color: var(--background); color: var(--text-color); stroke: var(--text-color);