Skip to content

Commit

Permalink
fix: 컴포넌트 네이밍 규칙
Browse files Browse the repository at this point in the history
  • Loading branch information
tooooo1 committed Aug 31, 2024
1 parent 7e5b28c commit c82d3f3
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/components/Lecture/IsTestInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ interface IsTestInfoProps {
}

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 <SearchTestInfoList page={fakeEvaluationList} isLogin={false} />;
Expand Down
4 changes: 2 additions & 2 deletions src/components/Lecture/LectureDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <LectureInfoBox isLogin={isLogin} current={data?.data ? data.data : fakeLectureInfo} />;
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/List/EvaluationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Spinner id="myInfo" />;
const isExistData = data?.pages[0]?.data.length === 0;

Expand Down
4 changes: 2 additions & 2 deletions src/components/List/LectureList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ 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 ? (
<>
Expand Down
4 changes: 2 additions & 2 deletions src/components/List/SearchEvaluationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Spinner id="nextPage" />;

Expand Down
4 changes: 2 additions & 2 deletions src/components/List/TestInfoList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Spinner id="myInfo" />;
Expand Down
1 change: 1 addition & 0 deletions src/components/Write/WriteTestInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const WriteTestInfo = ({ setModalIsOpen, row, type }: WriteTestInfoProps) => {
examInfo: row.examInfo.split(', '),
examDifficulty: row.examDifficulty,
}); //시험내용 옵션

const handleChange = (e: React.FormEvent<HTMLFormElement>) => {
const { name, value, checked } = e.currentTarget;
const { examInfo } = examOptions;
Expand Down
15 changes: 8 additions & 7 deletions src/hooks/useFavoriteMajor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ const useFavoriteMajor = (setModalIsOpen: React.Dispatch<React.SetStateAction<bo
const token = useRecoilValue(tokenState);

// 즐겨찾기 추가/삭제
const onFavoriteMajor = (e: any) => {
const onFavoriteMajor = (e: React.MouseEvent<HTMLImageElement>) => {
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);
};

// 확인 버튼 클릭 이벤트
Expand All @@ -50,6 +50,7 @@ const useFavoriteMajor = (setModalIsOpen: React.Dispatch<React.SetStateAction<bo
};

// 전공 선택 변경
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const majorChange = (e: any) => setSelectedMajor(e.target.value);

// 즐겨찾기 리스트 불러오기
Expand Down
10 changes: 5 additions & 5 deletions src/hooks/useLectureQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const useLectureQuery = () => {
);

// 검색 쿼리(key: 검색어,정렬,전공)
const Search = () => {
const search = () => {
const { ref, inView } = useInView();
const {
data,
Expand Down Expand Up @@ -59,7 +59,7 @@ const useLectureQuery = () => {
};

// 강의 상세 쿼리(key: 강의id)
const Detail = () => {
const detail = () => {
const { data, isLoading } = useQuery(
['lecture', 'detail', selectId],
() => lecture.detail(selectId),
Expand Down Expand Up @@ -95,7 +95,7 @@ const useLectureQuery = () => {
};

// 강의평가 쿼리(key: 강의id)
const Evaluation = (id: string, setWritten: React.Dispatch<React.SetStateAction<boolean>>) => {
const evaluation = (id: string, setWritten: React.Dispatch<React.SetStateAction<boolean>>) => {
const { ref, inView } = useInView();
const { data, isFetchingNextPage, isLoading, fetchNextPage } = useInfiniteQuery(
['lecture', 'evaluationList', id],
Expand All @@ -122,7 +122,7 @@ const useLectureQuery = () => {
};

// 시험정보 쿼리(key: 강의id)
const TestInfo = (id: string, setWritten: React.Dispatch<React.SetStateAction<boolean>>) => {
const testInfo = (id: string, setWritten: React.Dispatch<React.SetStateAction<boolean>>) => {
const { ref, inView } = useInView();
const { data, isFetchingNextPage, isLoading, fetchNextPage } = useInfiniteQuery(
['lecture', 'examList', id],
Expand All @@ -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;
10 changes: 5 additions & 5 deletions src/hooks/useUserQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -22,7 +22,7 @@ const useUserQuery = () => {
enabled: isLoginStorage(),
cacheTime: CACHE_TIME.MINUTE_30,
staleTime: CACHE_TIME.MINUTE_30,
}
},
);
useEffect(() => {
if (inView) {
Expand All @@ -34,7 +34,7 @@ const useUserQuery = () => {
};

// 내가 작성한 시험정보
const TestInfoList = () => {
const testInfoList = () => {
const { ref, inView } = useInView();
const { data, isLoading, fetchNextPage, isFetchingNextPage } = useInfiniteQuery(
['myInfo', 'myExamInfo'],
Expand All @@ -48,7 +48,7 @@ const useUserQuery = () => {
enabled: isLoginStorage(),
cacheTime: CACHE_TIME.MINUTE_30,
staleTime: CACHE_TIME.MINUTE_30,
}
},
);
useEffect(() => {
if (inView) {
Expand All @@ -59,6 +59,6 @@ const useUserQuery = () => {
return { data, isLoading, isFetchingNextPage, ref };
};

return { EvaluationList, TestInfoList };
return { evaluationList, testInfoList };
};
export default useUserQuery;
4 changes: 2 additions & 2 deletions src/pages/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit c82d3f3

Please sign in to comment.