From 2a05d7c0b32db0f9058cf877a4629348411755e4 Mon Sep 17 00:00:00 2001 From: minwucho Date: Thu, 8 Aug 2024 16:06:24 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B0=95=EC=82=AC=EC=9D=98=20=ED=80=B4?= =?UTF-8?q?=EC=A6=88=20=EC=A1=B0=ED=9A=8C=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/Router.jsx | 10 +++++++ .../src/components/Layout/LectureLayout.jsx | 3 +- frontend/src/hooks/api/useReportSetDetail.js | 10 +++++++ frontend/src/hooks/api/useReportSets.js | 10 +++++++ .../TeacherReportsetDetailPage.jsx | 28 +++++++++++++++++++ .../pages/TeacherReportsetDetailPage/index.js | 1 + .../TeacherReportsetPage.jsx | 28 +++++++++++++++++++ .../src/pages/TeacherReportsetPage/index.js | 1 + 8 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 frontend/src/hooks/api/useReportSetDetail.js create mode 100644 frontend/src/hooks/api/useReportSets.js create mode 100644 frontend/src/pages/TeacherReportsetDetailPage/TeacherReportsetDetailPage.jsx create mode 100644 frontend/src/pages/TeacherReportsetDetailPage/index.js create mode 100644 frontend/src/pages/TeacherReportsetPage/TeacherReportsetPage.jsx create mode 100644 frontend/src/pages/TeacherReportsetPage/index.js diff --git a/frontend/src/Router.jsx b/frontend/src/Router.jsx index 583d228..20db9d1 100644 --- a/frontend/src/Router.jsx +++ b/frontend/src/Router.jsx @@ -40,6 +40,8 @@ const PasswordResetAuthPage = lazy(async () => await import('./pages/PasswordRes const StudentReportPage = lazy(async () => await import('./pages/StudentReportPage')); const StudentReportDetailPage = lazy(async () => await import('./pages/StudentReportDetailPage')); const LivePage = lazy(async () => await import('./pages/LivePage')); +const TeacherReportsetPage = lazy(async () => await import('./pages/TeacherReportsetPage')); +const TeacherReportsetDetailPage = lazy(async () => await import('./pages/TeacherReportsetDetailPage')); const router = createBrowserRouter([ { @@ -87,6 +89,14 @@ const router = createBrowserRouter([ path: 'report/:reportId', element: , }, + { + path: 'teacherReportsets', + element: , + }, + { + path: 'teacherReportsets/:reportsetId', + element: , + }, { path: 'edit', element: , diff --git a/frontend/src/components/Layout/LectureLayout.jsx b/frontend/src/components/Layout/LectureLayout.jsx index 4202c14..979f0f7 100644 --- a/frontend/src/components/Layout/LectureLayout.jsx +++ b/frontend/src/components/Layout/LectureLayout.jsx @@ -61,7 +61,7 @@ export default function LectureLayout() { Q&A 자유게시판 {userType === 'student' && 퀴즈 성적} - {userType === 'teacher' && 퀴즈} + {userType === 'teacher' && 퀴즈 만들기} {userType === 'teacher' && 수강신청관리} {userType === 'teacher' && ( @@ -88,6 +88,7 @@ export default function LectureLayout() { 강의 삭제 + 퀴즈 목록 )} {userType === 'student' && ( diff --git a/frontend/src/hooks/api/useReportSetDetail.js b/frontend/src/hooks/api/useReportSetDetail.js new file mode 100644 index 0000000..60fe57d --- /dev/null +++ b/frontend/src/hooks/api/useReportSetDetail.js @@ -0,0 +1,10 @@ +import { useSuspenseQuery } from '@tanstack/react-query'; +import instance from '../../utils/axios/instance'; +import { API_URL } from '../../constants'; + +export function useReportSetDetail(reportSetId) { + return useSuspenseQuery({ + queryKey: ['reportsetDetail', reportSetId], + queryFn: () => instance.get(`${API_URL}/report/teacher/report/${reportSetId}`), + }); +} diff --git a/frontend/src/hooks/api/useReportSets.js b/frontend/src/hooks/api/useReportSets.js new file mode 100644 index 0000000..7be43f3 --- /dev/null +++ b/frontend/src/hooks/api/useReportSets.js @@ -0,0 +1,10 @@ +import { useSuspenseQuery } from '@tanstack/react-query'; +import instance from '../../utils/axios/instance'; +import { API_URL } from '../../constants'; + +export function useReportSets(lectureId) { + return useSuspenseQuery({ + queryKey: ['reportsetlists', lectureId], + queryFn: () => instance.get(`${API_URL}/report/teacher/reportSet/${lectureId}`), + }); +} diff --git a/frontend/src/pages/TeacherReportsetDetailPage/TeacherReportsetDetailPage.jsx b/frontend/src/pages/TeacherReportsetDetailPage/TeacherReportsetDetailPage.jsx new file mode 100644 index 0000000..e8f6038 --- /dev/null +++ b/frontend/src/pages/TeacherReportsetDetailPage/TeacherReportsetDetailPage.jsx @@ -0,0 +1,28 @@ +import { ArticleLink } from '../../components/ArticleLink'; +import ArticleBoard from '../../components/ArticleBoard/ArticleBoard'; +import { useReportSetDetail } from '../../hooks/api/useReportSetDetail'; +import { useParams } from 'react-router-dom'; + +export default function TeacherReportsetDetailPage() { + const { reportsetId } = useParams(); + const { data } = useReportSetDetail(reportsetId); + const reports = data?.data; + + console.log(reports); + return ( + + {reports.length && + reports.map?.((report) => ( + + ))} + + ); +} diff --git a/frontend/src/pages/TeacherReportsetDetailPage/index.js b/frontend/src/pages/TeacherReportsetDetailPage/index.js new file mode 100644 index 0000000..a388927 --- /dev/null +++ b/frontend/src/pages/TeacherReportsetDetailPage/index.js @@ -0,0 +1 @@ +export { default } from './TeacherReportsetDetailPage'; diff --git a/frontend/src/pages/TeacherReportsetPage/TeacherReportsetPage.jsx b/frontend/src/pages/TeacherReportsetPage/TeacherReportsetPage.jsx new file mode 100644 index 0000000..d0dc206 --- /dev/null +++ b/frontend/src/pages/TeacherReportsetPage/TeacherReportsetPage.jsx @@ -0,0 +1,28 @@ +import { ArticleLink } from '../../components/ArticleLink'; +import ArticleBoard from '../../components/ArticleBoard/ArticleBoard'; +import { useReportSets } from '../../hooks/api/useReportSets'; +import { useParams } from 'react-router-dom'; + +export default function TeacherReportsetPage() { + const { lectureId } = useParams(); + const { data } = useReportSets(lectureId); + const reports = data?.data; + + console.log(data); + return ( + + {reports.length && + reports.map?.((report) => ( + + ))} + + ); +} diff --git a/frontend/src/pages/TeacherReportsetPage/index.js b/frontend/src/pages/TeacherReportsetPage/index.js new file mode 100644 index 0000000..18e584f --- /dev/null +++ b/frontend/src/pages/TeacherReportsetPage/index.js @@ -0,0 +1 @@ +export { default } from './TeacherReportsetPage';