From 1f0b57d26bb9bdfd75221e73f977319980a6d58d Mon Sep 17 00:00:00 2001 From: Chung-il Date: Sun, 1 Sep 2024 01:30:40 +0900 Subject: [PATCH] =?UTF-8?q?=08fix:=20=ED=83=80=EC=9E=85=20=EC=95=A0?= =?UTF-8?q?=EB=9F=AC=20=ED=95=B4=EA=B2=B0=20=EB=B0=8F=20=EB=AA=A8=EB=8B=AC?= =?UTF-8?q?=20emotion=20=EC=85=80=EB=A0=89=ED=84=B0=20=EB=B6=88=EC=9D=BC?= =?UTF-8?q?=EC=B9=98=20=ED=95=B4=EA=B2=B0=20(#96)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eslint.config.mjs | 2 - src/api/ApiController.ts | 5 +- src/api/Lecture.ts | 18 +++--- src/api/etc.ts | 10 ++-- src/components/ErrorFrame.tsx | 13 ++--- src/components/Lecture/IsTestInfo.tsx | 12 ++-- src/components/Lecture/LectureDetail.tsx | 4 +- src/components/List/EvaluationList.tsx | 14 ++--- src/components/List/LectureList.tsx | 8 +-- src/components/List/SearchEvaluationList.tsx | 14 ++--- src/components/List/TestInfoList.tsx | 8 +-- src/components/Write/WriteEvaluation.tsx | 58 ++++++++------------ src/components/Write/WriteTestInfo.tsx | 5 +- src/hooks/useFavoriteMajor.ts | 15 ++--- src/hooks/useLectureQuery.ts | 14 ++--- src/hooks/useUserQuery.ts | 10 ++-- src/hooks/useWriteEvaluation.ts | 6 +- src/main.tsx | 5 +- src/pages/LectureInfo.tsx | 4 +- src/pages/Notice.tsx | 10 ++-- src/pages/NoticeDetail.tsx | 4 +- src/pages/Search.tsx | 4 +- src/types/evaluate.ts | 5 ++ src/types/exam.ts | 2 +- 24 files changed, 117 insertions(+), 133 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 160515c..5753b89 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -70,8 +70,6 @@ export default [ }, rules: { ...commonRules, - //TODO: 추후 제거 예정 (변경 시 현재 동작에 영향이 가는 것을 고려해야함) - '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/consistent-type-imports': [ 'error', { diff --git a/src/api/ApiController.ts b/src/api/ApiController.ts index e536b3f..709a1bd 100644 --- a/src/api/ApiController.ts +++ b/src/api/ApiController.ts @@ -6,14 +6,11 @@ import { isLoginStorage } from 'utils/loginStorage'; import { logout, refresh } from './etc'; -export const PROXY_URL = window.location.hostname === 'localhost' ? '/api' : '/proxy'; axios.defaults.withCredentials = true; const JwtInterceptors = () => { const [token, setToken] = useRecoilState(tokenState); - const instance = axios.create({ - baseURL: `${PROXY_URL}`, - }); + const instance = axios.create(); //액세스토큰 유효성 검사 const isAccessTokenValid = async () => { diff --git a/src/api/Lecture.ts b/src/api/Lecture.ts index f5216fd..80b648b 100644 --- a/src/api/Lecture.ts +++ b/src/api/Lecture.ts @@ -1,5 +1,5 @@ import type { AxiosError } from 'axios'; -import type { Review } from 'types/evaluate'; +import type { ReviewResponse } from 'types/evaluate'; import type { ExamPostsResponse } from 'types/exam'; import type { LectureDetailItem, MainLecture } from 'types/lecture'; @@ -12,7 +12,7 @@ const Lecture = () => { const main = async (lecture = 'modifiedDate', page = 1, majorType = '') => { try { const data: MainLecture = await instance.get( - `/lecture/all/?option=${lecture}&page=${page}&majorType=${majorType}` + `/lecture/all/?option=${lecture}&page=${page}&majorType=${majorType}`, ); return data; @@ -28,11 +28,11 @@ const Lecture = () => { searchValue = '{교수이름or과목이름}', pageParam = 1, option = 'modifiedDate', - major: string + major: string, ) => { try { const data: MainLecture = await instance.get( - `/lecture/search/?searchValue=${searchValue}&option=${option}&page=${pageParam}&majorType=${major}` + `/lecture/search/?searchValue=${searchValue}&option=${option}&page=${pageParam}&majorType=${major}`, ); return { @@ -59,12 +59,13 @@ const Lecture = () => { // 검색 결과 자세히보기 (Evaluation) const evaluation = async (selectId: string, pageParam = 1) => { try { - const { data } = await instance.get( - `/evaluate-posts/?lectureId=${selectId}&page=${pageParam}` + const { data, written }: ReviewResponse = await instance.get( + `/evaluate-posts/?lectureId=${selectId}&page=${pageParam}`, ); return { - data, + data: data, + written: written, isLast: data.length < 10, nextPage: pageParam + 1, }; @@ -78,11 +79,12 @@ const Lecture = () => { const examInfo = async (selectId: string, pageParam = 1) => { try { const data: ExamPostsResponse = await instance.get( - `/exam-posts/?lectureId=${selectId}&page=${pageParam}` + `/exam-posts/?lectureId=${selectId}&page=${pageParam}`, ); return { data, + written: data.written, isLast: data.data.length < 10, nextPage: pageParam + 1, }; diff --git a/src/api/etc.ts b/src/api/etc.ts index 946db59..035bbb1 100644 --- a/src/api/etc.ts +++ b/src/api/etc.ts @@ -3,12 +3,10 @@ import axios from 'axios'; import type { ClientRefresh } from 'types/user'; import { removeStorage } from 'utils/loginStorage'; -import { PROXY_URL } from './ApiController'; - // 전공 선택 의존성때문에 따로 빼놓은 것 export const type = async (Authorization: string) => { try { - const { data } = await axios.get(`${PROXY_URL}/suwiki/majorType`, { + const { data } = await axios.get(`suwiki/majorType`, { headers: { Authorization }, }); @@ -21,7 +19,7 @@ export const type = async (Authorization: string) => { export const searchFavorite = async (Authorization: string) => { try { - const { data } = await axios.get(`${PROXY_URL}/user/favorite-major`, { + const { data } = await axios.get(`user/favorite-major`, { headers: { Authorization }, }); @@ -35,7 +33,7 @@ export const searchFavorite = async (Authorization: string) => { // 로그아웃 export const logout = async () => { try { - const { data } = await axios.post(`${PROXY_URL}/user/client-logout`); + const { data } = await axios.post(`user/client-logout`); if (data.Success) { removeStorage('login'); window.location.href = '/'; @@ -49,7 +47,7 @@ export const logout = async () => { // 리프레시 export const refresh = () => { try { - const res = axios.post(`${PROXY_URL}/user/client-refresh`); + const res = axios.post(`user/client-refresh`); return res; } catch (error) { diff --git a/src/components/ErrorFrame.tsx b/src/components/ErrorFrame.tsx index f4b1217..e83cfc9 100644 --- a/src/components/ErrorFrame.tsx +++ b/src/components/ErrorFrame.tsx @@ -1,6 +1,5 @@ import styled from '@emotion/styled'; -import { useNavigate } from 'react-router-dom'; -import { AuthWrapper, Button, Container, Img } from 'styles/common'; +import { AuthWrapper, Container, Img } from 'styles/common'; interface ErrorFrameProps { status?: string; @@ -9,17 +8,13 @@ interface ErrorFrameProps { } const ErrorFrame = ({ mainMsg, subMsg }: ErrorFrameProps) => { - const navigate = useNavigate(); - return ( {mainMsg} {subMsg} - + 홈으로 돌아가기 ); @@ -37,3 +32,7 @@ const StyledText = styled.div` padding-top: 2rem; } `; + +const StyleLink = styled.a` + text-align: center; +`; diff --git a/src/components/Lecture/IsTestInfo.tsx b/src/components/Lecture/IsTestInfo.tsx index 8db11eb..241ab7f 100644 --- a/src/components/Lecture/IsTestInfo.tsx +++ b/src/components/Lecture/IsTestInfo.tsx @@ -1,19 +1,19 @@ import styled from '@emotion/styled'; import { User } from 'api'; -import { Button, SearchTestInfoList,Spinner } from 'components'; +import { Button, SearchTestInfoList, Spinner } from 'components'; import { fakeEvaluationList } from 'constants/placeholderData'; import useLectureQuery from 'hooks/useLectureQuery'; import { isLoginStorage } from 'utils/loginStorage'; interface IsTestInfoProps { selectId: string; - setWritten: (value: boolean) => void; + setWritten: React.Dispatch>; } const IsTestInfo = ({ selectId, setWritten }: IsTestInfoProps) => { - const { TestInfo } = useLectureQuery(); + const { testInfo } = useLectureQuery(); const isLogin = isLoginStorage(); - const { data, isLoading, isFetchingNextPage, ref } = TestInfo(selectId, setWritten); + const { data, isLoading, isFetchingNextPage, ref } = testInfo(selectId, setWritten); if (!isLogin) { return ; @@ -22,10 +22,10 @@ const IsTestInfo = ({ selectId, setWritten }: IsTestInfoProps) => { if (isLoading || !data || !data.pages[0]) return ; const listLength = data.pages[0].data.data.length; - const isExamDataExists = data?.pages[0].data.isExamDataExists; + const written = data?.pages[0].data.written; if (listLength === 0) { - return isExamDataExists ? : ; + return written ? : ; } return ( diff --git a/src/components/Lecture/LectureDetail.tsx b/src/components/Lecture/LectureDetail.tsx index d33a92f..aa73ab0 100644 --- a/src/components/Lecture/LectureDetail.tsx +++ b/src/components/Lecture/LectureDetail.tsx @@ -3,8 +3,8 @@ import { fakeLectureInfo } from 'constants/placeholderData'; import useLectureQuery from 'hooks/useLectureQuery'; const LectureDetail = () => { - const { Detail } = useLectureQuery(); - const { data, isLogin } = Detail(); + const { detail } = useLectureQuery(); + const { data, isLogin } = detail(); return ; }; diff --git a/src/components/List/EvaluationList.tsx b/src/components/List/EvaluationList.tsx index 0318d39..6d931e0 100644 --- a/src/components/List/EvaluationList.tsx +++ b/src/components/List/EvaluationList.tsx @@ -1,6 +1,6 @@ import styled from '@emotion/styled'; import { User } from 'api'; -import { EvaluationDetail, Modal,Spinner, WriteEvaluation } from 'components'; +import { EvaluationDetail, Modal, Spinner, WriteEvaluation } from 'components'; import useUserQuery from 'hooks/useUserQuery'; import { useState } from 'react'; import StarRatings from 'react-star-ratings'; @@ -9,8 +9,8 @@ import { floatFix } from 'utils/floatFix'; import { subStr } from 'utils/subString'; const EvaluationList = () => { - const { EvaluationList } = useUserQuery(); - const { data, isLoading, isFetchingNextPage, ref } = EvaluationList(); + const { evaluationList } = useUserQuery(); + const { data, isLoading, isFetchingNextPage, ref } = evaluationList(); if (isLoading) return ; const isExistData = data?.pages[0]?.data.length === 0; @@ -19,12 +19,10 @@ const EvaluationList = () => { {isExistData ? ( 아직 평가한 강의가 없어요. ) : ( - data?.pages.map((page) => { + data?.pages.map((page, index) => { return ( - - {page?.data.map((row) => ( - - ))} + + {page?.data.map((row) => )} ); }) diff --git a/src/components/List/LectureList.tsx b/src/components/List/LectureList.tsx index 87f0085..28d7d27 100644 --- a/src/components/List/LectureList.tsx +++ b/src/components/List/LectureList.tsx @@ -19,14 +19,12 @@ interface LectureListProps { } const LectureList = ({ count, pages }: LectureListProps) => { - const { Search } = useLectureQuery(); - const { nextLoading, value, ref } = Search(); + const { search } = useLectureQuery(); + const { nextLoading, value, ref } = search(); return count ? ( <> - {pages?.map((page) => ( - - ))} + {pages?.map((page, index) => )}
{nextLoading ? : null}
diff --git a/src/components/List/SearchEvaluationList.tsx b/src/components/List/SearchEvaluationList.tsx index ecb6026..f34f59c 100644 --- a/src/components/List/SearchEvaluationList.tsx +++ b/src/components/List/SearchEvaluationList.tsx @@ -3,7 +3,7 @@ import { User } from 'api'; import { EvaluationDetail, Spinner } from 'components'; import { fakeEvaluationList } from 'constants/placeholderData'; import useLectureQuery from 'hooks/useLectureQuery'; -import { Fragment,useState } from 'react'; +import { Fragment, useState } from 'react'; import StarRatings from 'react-star-ratings'; import type { Review } from 'types/evaluate'; import { floatFix } from 'utils/floatFix'; @@ -27,8 +27,8 @@ interface SearchEvaluationListProps { } const SearchEvaluationList = ({ selectId, setWritten, isLogin }: SearchEvaluationListProps) => { - const { Evaluation } = useLectureQuery(); - const { data, isLoading, isFetchingNextPage, ref } = Evaluation(selectId, setWritten); + const { evaluation } = useLectureQuery(); + const { data, isLoading, isFetchingNextPage, ref } = evaluation(selectId, setWritten); if (isLoading) return ; @@ -49,11 +49,9 @@ const SearchEvaluationList = ({ selectId, setWritten, isLogin }: SearchEvaluatio return (
- {data?.pages?.map((page) => ( - - {page?.data.map((lecture) => ( - - ))} + {data?.pages?.map((page, index) => ( + + {page?.data.map((lecture) => )} ))}
diff --git a/src/components/List/TestInfoList.tsx b/src/components/List/TestInfoList.tsx index 895e492..7df1e75 100644 --- a/src/components/List/TestInfoList.tsx +++ b/src/components/List/TestInfoList.tsx @@ -9,8 +9,8 @@ import { subStr } from 'utils/subString'; import type { ExamDiff } from './SearchTestInfoList'; const TestInfoList = () => { - const { TestInfoList } = useUserQuery(); - const { data, isLoading, isFetchingNextPage, ref } = TestInfoList(); + const { testInfoList } = useUserQuery(); + const { data, isLoading, isFetchingNextPage, ref } = testInfoList(); const isExistData = data?.pages[0]?.data.length === 0; if (isLoading || !data) return ; @@ -20,9 +20,9 @@ const TestInfoList = () => { {isExistData ? ( 아직 평가한 강의가 없어요. ) : ( - data.pages.map((page) => { + data.pages.map((page, index) => { return ( - + {page?.data.map((row) => )} ); diff --git a/src/components/Write/WriteEvaluation.tsx b/src/components/Write/WriteEvaluation.tsx index c137d34..b18f56f 100644 --- a/src/components/Write/WriteEvaluation.tsx +++ b/src/components/Write/WriteEvaluation.tsx @@ -81,20 +81,27 @@ const WriteEvaluation = ({ setModalIsOpen, row, type }: WriteEvaluationProps) => ); })} {EvaluationSelectOptions.map(({ id, title, options }) => ( - + {title} - {options.map(({ id: level, name, value }) => ( - - ))} + {options.map(({ id: level, name, value }) => { + console.log(name, lectureOptions, level, value); + + return ( + + ); + })} ))} @@ -256,18 +263,19 @@ const EditButton = styled.button` } `; -const FormCheckText = styled.span` +const FormCheckText = styled.span<{ checked: boolean }>` font-size: 1vw; padding: 8px 15px; - background: #eee; + background-color: #eee; border-radius: 10px; border: none; display: flex; justify-content: center; align-items: center; cursor: pointer; - color: #777; + color: ${(state) => (state.checked ? '#336af8' : '#777')}; margin-right: 8px; + @media only screen and (max-width: 550px) { font-size: 12px; padding: 6px 9px; @@ -275,23 +283,5 @@ const FormCheckText = styled.span` `; const FormCheckLeft = styled.input` - &#difficult { - &:checked + ${FormCheckText} { - color: #7800ff; - font-weight: 600; - } - } - &#normal { - &:checked + ${FormCheckText} { - color: #222222; - font-weight: 600; - } - } - &#easy { - &:checked + ${FormCheckText} { - color: #336af8; - font-weight: 600; - } - } display: none; `; diff --git a/src/components/Write/WriteTestInfo.tsx b/src/components/Write/WriteTestInfo.tsx index 1250bc9..5b176ef 100644 --- a/src/components/Write/WriteTestInfo.tsx +++ b/src/components/Write/WriteTestInfo.tsx @@ -23,8 +23,9 @@ const WriteTestInfo = ({ setModalIsOpen, row, type }: WriteTestInfoProps) => { examInfo: row.examInfo.split(', '), examDifficulty: row.examDifficulty, }); //시험내용 옵션 - const handleChange = (e: any) => { - const { name, value, checked } = e.target; + + const handleChange = (e: React.FormEvent) => { + const { name, value, checked } = e.currentTarget; const { examInfo } = examOptions; const change = { examDifficulty: () => setExamOptions({ ...examOptions, examDifficulty: value }), diff --git a/src/hooks/useFavoriteMajor.ts b/src/hooks/useFavoriteMajor.ts index 6bc6980..9a5f4d0 100644 --- a/src/hooks/useFavoriteMajor.ts +++ b/src/hooks/useFavoriteMajor.ts @@ -22,21 +22,21 @@ const useFavoriteMajor = (setModalIsOpen: React.Dispatch { + const onFavoriteMajor = (e: React.MouseEvent) => { if (!isLoginStorage()) { alert('로그인 후 이용해주세요'); navigate('/login'); return; } - if (!favoriteDb.includes(e.target.alt)) { - setFavoriteDb(favoriteDb.concat([e.target.alt])); - favoriting(e.target.alt); + if (!favoriteDb.includes(e.currentTarget.alt)) { + setFavoriteDb(favoriteDb.concat([e.currentTarget.alt])); + favoriting(e.currentTarget.alt); } else { - setFavoriteDb(favoriteDb.filter((v) => v !== e.target.alt)); - unfavoriting(e.target.alt); + setFavoriteDb(favoriteDb.filter((v) => v !== e.currentTarget.alt)); + unfavoriting(e.currentTarget.alt); } - setSelectedMajor(e.target.alt); + setSelectedMajor(e.currentTarget.alt); }; // 확인 버튼 클릭 이벤트 @@ -50,6 +50,7 @@ const useFavoriteMajor = (setModalIsOpen: React.Dispatch setSelectedMajor(e.target.value); // 즐겨찾기 리스트 불러오기 diff --git a/src/hooks/useLectureQuery.ts b/src/hooks/useLectureQuery.ts index b666690..e064780 100644 --- a/src/hooks/useLectureQuery.ts +++ b/src/hooks/useLectureQuery.ts @@ -30,7 +30,7 @@ const useLectureQuery = () => { ); // 검색 쿼리(key: 검색어,정렬,전공) - const Search = () => { + const search = () => { const { ref, inView } = useInView(); const { data, @@ -59,7 +59,7 @@ const useLectureQuery = () => { }; // 강의 상세 쿼리(key: 강의id) - const Detail = () => { + const detail = () => { const { data, isLoading } = useQuery( ['lecture', 'detail', selectId], () => lecture.detail(selectId), @@ -95,7 +95,7 @@ const useLectureQuery = () => { }; // 강의평가 쿼리(key: 강의id) - const Evaluation = (id: string, setWritten: any) => { + const evaluation = (id: string, setWritten: React.Dispatch>) => { const { ref, inView } = useInView(); const { data, isFetchingNextPage, isLoading, fetchNextPage } = useInfiniteQuery( ['lecture', 'evaluationList', id], @@ -106,7 +106,7 @@ const useLectureQuery = () => { return undefined; }, - onSuccess: (data) => setWritten(data.pages[0]!.data), + onSuccess: (data) => setWritten(!!data.pages[0]?.written), cacheTime: CACHE_TIME.MINUTE_0, staleTime: CACHE_TIME.MINUTE_0, enabled: isLogin, @@ -122,7 +122,7 @@ const useLectureQuery = () => { }; // 시험정보 쿼리(key: 강의id) - const TestInfo = (id: string, setWritten: any) => { + const testInfo = (id: string, setWritten: React.Dispatch>) => { const { ref, inView } = useInView(); const { data, isFetchingNextPage, isLoading, fetchNextPage } = useInfiniteQuery( ['lecture', 'examList', id], @@ -133,7 +133,7 @@ const useLectureQuery = () => { return undefined; }, - onSuccess: (data) => setWritten(data.pages[0]!.data), + onSuccess: (data) => setWritten(!!data.pages[0]?.data.written), cacheTime: CACHE_TIME.MINUTE_0, staleTime: CACHE_TIME.MINUTE_0, enabled: isLogin, @@ -148,7 +148,7 @@ const useLectureQuery = () => { return { data, isFetchingNextPage, isLoading, ref }; }; - return { getMainLecture, Search, Detail, Evaluation, TestInfo }; + return { getMainLecture, search, detail, evaluation, testInfo }; }; export default useLectureQuery; diff --git a/src/hooks/useUserQuery.ts b/src/hooks/useUserQuery.ts index 88fe8bd..0698c16 100644 --- a/src/hooks/useUserQuery.ts +++ b/src/hooks/useUserQuery.ts @@ -8,7 +8,7 @@ import { isLoginStorage } from 'utils/loginStorage'; const useUserQuery = () => { const user = User(); // 내가 작성한 평가 - const EvaluationList = () => { + const evaluationList = () => { const { ref, inView } = useInView(); const { data, isLoading, fetchNextPage, isFetchingNextPage } = useInfiniteQuery( ['myInfo', 'myEvaluation'], @@ -22,7 +22,7 @@ const useUserQuery = () => { enabled: isLoginStorage(), cacheTime: CACHE_TIME.MINUTE_30, staleTime: CACHE_TIME.MINUTE_30, - } + }, ); useEffect(() => { if (inView) { @@ -34,7 +34,7 @@ const useUserQuery = () => { }; // 내가 작성한 시험정보 - const TestInfoList = () => { + const testInfoList = () => { const { ref, inView } = useInView(); const { data, isLoading, fetchNextPage, isFetchingNextPage } = useInfiniteQuery( ['myInfo', 'myExamInfo'], @@ -48,7 +48,7 @@ const useUserQuery = () => { enabled: isLoginStorage(), cacheTime: CACHE_TIME.MINUTE_30, staleTime: CACHE_TIME.MINUTE_30, - } + }, ); useEffect(() => { if (inView) { @@ -59,6 +59,6 @@ const useUserQuery = () => { return { data, isLoading, isFetchingNextPage, ref }; }; - return { EvaluationList, TestInfoList }; + return { evaluationList, testInfoList }; }; export default useUserQuery; diff --git a/src/hooks/useWriteEvaluation.ts b/src/hooks/useWriteEvaluation.ts index 8cc5351..df0fdf2 100644 --- a/src/hooks/useWriteEvaluation.ts +++ b/src/hooks/useWriteEvaluation.ts @@ -31,10 +31,10 @@ const useWriteEvaluation = ({ setModalIsOpen, row, type }: WriteEvaluationProps) content, }; - const onChangeContent = (e: any) => setContent(e.target.value); + const onChangeContent = (e: React.ChangeEvent) => setContent(e.target.value); - const onChangeLectureOptions = (e: any) => - setLectureOptions({ ...lectureOptions, [e.target.name]: e.target.value }); + const onChangeLectureOptions = (e: React.ChangeEvent) => + setLectureOptions({ ...lectureOptions, [e.target.name]: Number(e.target.value) }); const onEvaluate = () => { if (selectedSemester === '' || selectedSemester === '선택') return alert('학기를 선택해주세요'); diff --git a/src/main.tsx b/src/main.tsx index db9f93b..0970e7c 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -12,6 +12,7 @@ import { ReactQueryDevtools } from 'react-query/devtools'; import { RecoilRoot } from 'recoil'; import App from './App'; + initialize('G-KG7KQ8K3GP'); export const queryClient = new QueryClient({ @@ -23,7 +24,7 @@ export const queryClient = new QueryClient({ }, }, }); -const PROXY_URL = window.location.hostname === 'localhost' ? '' : '/proxy'; +const PROXY_URL = window.location.hostname === 'localhost' ? '/api' : '/proxy'; axios.defaults.baseURL = PROXY_URL; axios.defaults.withCredentials = true; @@ -38,5 +39,5 @@ ReactDOM.createRoot(document.getElementById('root')!).render( - + , ); diff --git a/src/pages/LectureInfo.tsx b/src/pages/LectureInfo.tsx index 4bd7488..fe0ce1e 100644 --- a/src/pages/LectureInfo.tsx +++ b/src/pages/LectureInfo.tsx @@ -42,9 +42,9 @@ const LectureInfo = () => { )); - const clickFunc = (e: any, index: number) => { + const clickFunc = (e: React.MouseEvent, index: number) => { setMenuCheck(index); - setCheck(e.target.id); + setCheck(e.currentTarget.id); }; return ( diff --git a/src/pages/Notice.tsx b/src/pages/Notice.tsx index cdee3b5..04fcf5d 100644 --- a/src/pages/Notice.tsx +++ b/src/pages/Notice.tsx @@ -29,7 +29,7 @@ export const NoticeContainer = () => { getNextPageParam: (lastPage) => { if (lastPage && !lastPage.isLast) return lastPage.nextPage; }, - } + }, ); useEffect(() => { if (inView) { @@ -41,11 +41,9 @@ export const NoticeContainer = () => { return ( <> - {data.pages.map((page) => ( - - {page?.data.data.map((notice) => ( - - ))} + {data.pages.map((page, index) => ( + + {page?.data.data.map((notice) => )} ))}
diff --git a/src/pages/NoticeDetail.tsx b/src/pages/NoticeDetail.tsx index 50e69ec..652780b 100644 --- a/src/pages/NoticeDetail.tsx +++ b/src/pages/NoticeDetail.tsx @@ -19,8 +19,8 @@ export const NoticeBox = () => { return ( {data?.data.title} - {contents?.map((content) => ( -
+ {contents?.map((content, index) => ( +
{content}
diff --git a/src/pages/Search.tsx b/src/pages/Search.tsx index f30c047..304dc4a 100644 --- a/src/pages/Search.tsx +++ b/src/pages/Search.tsx @@ -4,8 +4,8 @@ import { sortOptions } from 'constants/placeholderData'; import useLectureQuery from 'hooks/useLectureQuery'; const Search = () => { - const { Search } = useLectureQuery(); - const { data } = Search(); + const { search } = useLectureQuery(); + const { data } = search(); const count = data?.pages[0]?.data.count ?? 0; diff --git a/src/types/evaluate.ts b/src/types/evaluate.ts index 6709a1b..a60e796 100644 --- a/src/types/evaluate.ts +++ b/src/types/evaluate.ts @@ -22,6 +22,11 @@ export interface ReviewOptions { export interface Review extends ExamPost, ReviewBase, ReviewOptions {} +export interface ReviewResponse { + data: Review[]; + written: boolean; +} + export interface PostReviewRequest extends ReviewBase { lectureName: string; professor: string; diff --git a/src/types/exam.ts b/src/types/exam.ts index d80898e..bfccb5a 100644 --- a/src/types/exam.ts +++ b/src/types/exam.ts @@ -13,5 +13,5 @@ export interface MyExam extends ExamPost, ReviewOptions {} export interface ExamPostsResponse { data: ExamPost[]; - isExamDataExists: boolean; + written: boolean; }