From 28cc8b4f176b03d3abf403cc5688cbe07c07408a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9A=B0=EC=A7=80=EC=84=9D?= Date: Wed, 17 Jul 2024 14:20:06 +0900 Subject: [PATCH] =?UTF-8?q?FE-42=E2=99=BB=EF=B8=8F=20=20useEpigramCommentH?= =?UTF-8?q?ook=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/epigram/Comment/CommentList.tsx | 2 +- src/hooks/useEpigramComment.ts | 0 src/hooks/useEpigramCommentHook.ts | 7 +++++++ src/hooks/useEpigramQueryHook.ts | 5 ++--- src/pages/epigram/[id].tsx | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) delete mode 100644 src/hooks/useEpigramComment.ts create mode 100644 src/hooks/useEpigramCommentHook.ts diff --git a/src/components/epigram/Comment/CommentList.tsx b/src/components/epigram/Comment/CommentList.tsx index e2a4fff4..5a605fe9 100644 --- a/src/components/epigram/Comment/CommentList.tsx +++ b/src/components/epigram/Comment/CommentList.tsx @@ -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'; diff --git a/src/hooks/useEpigramComment.ts b/src/hooks/useEpigramComment.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/src/hooks/useEpigramCommentHook.ts b/src/hooks/useEpigramCommentHook.ts new file mode 100644 index 00000000..126695f5 --- /dev/null +++ b/src/hooks/useEpigramCommentHook.ts @@ -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; diff --git a/src/hooks/useEpigramQueryHook.ts b/src/hooks/useEpigramQueryHook.ts index 8c199a00..5bd0067c 100644 --- a/src/hooks/useEpigramQueryHook.ts +++ b/src/hooks/useEpigramQueryHook.ts @@ -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; diff --git a/src/pages/epigram/[id].tsx b/src/pages/epigram/[id].tsx index 61034cbe..4fa9d1fc 100644 --- a/src/pages/epigram/[id].tsx +++ b/src/pages/epigram/[id].tsx @@ -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';