Skip to content

Commit

Permalink
FE-42♻️ useEpigramCommentHook 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
우지석 committed Jul 17, 2024
1 parent 218a7a4 commit 28cc8b4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/epigram/Comment/CommentList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEpigramCommentsQuery } from '@/hooks/useEpigramQueryHook';
import useEpigramCommentsQuery from '@/hooks/useEpigramCommentHook';
import { EpigramCommentProps } from '@/types/epigram.types';
import CommentItem from './CommentItem';
import NoComment from './NoComment';
Expand Down
Empty file removed src/hooks/useEpigramComment.ts
Empty file.
7 changes: 7 additions & 0 deletions src/hooks/useEpigramCommentHook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import queries from '@/apis/queries';
import { CommentRequestType } from '@/schema/comment';
import { useQuery } from '@tanstack/react-query';

const useEpigramCommentsQuery = (request: CommentRequestType) => useQuery(queries.epigramComment.getComments(request));

export default useEpigramCommentsQuery;
5 changes: 2 additions & 3 deletions src/hooks/useEpigramQueryHook.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { useQuery } from '@tanstack/react-query';
import queries from '@/apis/queries';
import { GetEpigramRequestType } from '@/schema/epigram';
import { CommentRequestType } from '@/schema/comment';

export const useEpigramQuery = (request: GetEpigramRequestType | undefined, enabled = true) =>
const useEpigramQuery = (request: GetEpigramRequestType | undefined, enabled = true) =>
useQuery({
...queries.epigram.getEpigram(request ?? { id: undefined }),
enabled: enabled && request?.id !== undefined,
});

export const useEpigramCommentsQuery = (request: CommentRequestType) => useQuery(queries.epigramComment.getComments(request));
export default useEpigramQuery;
2 changes: 1 addition & 1 deletion src/pages/epigram/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GetEpigramRequestSchema } from '@/schema/epigram';
import { useEpigramQuery } from '@/hooks/useEpigramQueryHook';
import useEpigramQuery from '@/hooks/useEpigramQueryHook';
import EpigramComment from '@/pageLayout/Epigram/EpigramComment';
import EpigramFigure from '@/pageLayout/Epigram/EpigramFigure';
import Image from 'next/image';
Expand Down

0 comments on commit 28cc8b4

Please sign in to comment.