From d737a04fe01fa575e896f9b6d36cd95240e9f050 Mon Sep 17 00:00:00 2001 From: lsy20140 Date: Sun, 20 Oct 2024 16:33:20 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20admin=20useGetAllWords=20hook=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 --- src/hooks/admin/useGetAllWords.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/hooks/admin/useGetAllWords.tsx diff --git a/src/hooks/admin/useGetAllWords.tsx b/src/hooks/admin/useGetAllWords.tsx new file mode 100644 index 00000000..0f5c32ea --- /dev/null +++ b/src/hooks/admin/useGetAllWords.tsx @@ -0,0 +1,10 @@ +import { getAllWords } from '@/api/admin/words' +import { useQuery } from '@tanstack/react-query' + +export default function useGetAllWords() { + const { data: words } = useQuery({ + queryKey: ['admin', 'words'], + queryFn: getAllWords, + }) + return { words } +} From a9da32b173aee29a582848b92e9276b558cea620 Mon Sep 17 00:00:00 2001 From: lsy20140 Date: Sun, 20 Oct 2024 16:34:50 +0900 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20=EC=9A=A9=EC=96=B4=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20admin=20default=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/admin/page.tsx | 11 ++++++++--- src/app/admin/words/page.tsx | 12 ------------ src/components/domain/admin/WordList/index.tsx | 15 ++++++++++----- 3 files changed, 18 insertions(+), 20 deletions(-) delete mode 100644 src/app/admin/words/page.tsx diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index b617e439..8f9938b0 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -1,5 +1,10 @@ -import Link from 'next/link' +import AdminWordList from '@/components/domain/admin/WordList' -export default function AdminMagePage() { - return <> +export default async function WordsListPage() { + return ( +
+

전체 용어

+ +
+ ) } diff --git a/src/app/admin/words/page.tsx b/src/app/admin/words/page.tsx deleted file mode 100644 index eb8f44c6..00000000 --- a/src/app/admin/words/page.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { getAllWords } from '@/api/admin/words' -import AdminWordList from '@/components/domain/admin/WordList' - -export default async function WordsListPage() { - const res = await getAllWords() - return ( -
-

전체 용어

- -
- ) -} diff --git a/src/components/domain/admin/WordList/index.tsx b/src/components/domain/admin/WordList/index.tsx index 2412c68c..6475df84 100644 --- a/src/components/domain/admin/WordList/index.tsx +++ b/src/components/domain/admin/WordList/index.tsx @@ -1,13 +1,18 @@ -import { AdminWordType } from '@/types/word' +'use client' import WordListItem from './WordListItem' +import useGetAllWords from '@/hooks/admin/useGetAllWords' +import { AdminWordType } from '@/types/word' + +export default function AdminWordList() { + const { words } = useGetAllWords() -export default function AdminWordList({ words }: { words: AdminWordType[] }) { return ( <>
- {words.map((word, idx) => ( - - ))} + {words && + words.map((word: AdminWordType, idx) => ( + + ))}
) From 84785422b4978598fd3ad006a4de599b960589f2 Mon Sep 17 00:00:00 2001 From: lsy20140 Date: Mon, 21 Oct 2024 17:09:00 +0900 Subject: [PATCH 3/3] =?UTF-8?q?design:=20admin=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=ED=97=A4=EB=8D=94=20fixed=20=EC=A0=81=EC=9A=A9=20?= =?UTF-8?q?=EB=B0=8F=20=EC=9A=A9=EC=96=B4=20=EB=AA=A9=EB=A1=9D=20=EB=A9=94?= =?UTF-8?q?=EB=89=B4=20path=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/admin/layout.tsx | 8 ++++---- src/app/admin/page.tsx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/admin/layout.tsx b/src/app/admin/layout.tsx index c1a495f9..84ca7743 100644 --- a/src/app/admin/layout.tsx +++ b/src/app/admin/layout.tsx @@ -2,7 +2,7 @@ import Image from 'next/image' import Link from 'next/link' const MENUS = [ - { name: '용어 목록', path: '/admin/words' }, + { name: '용어 목록', path: '/admin' }, { name: '용어 등록', path: '/admin/words/add' }, { name: '신고 댓글', path: '/admin/reports' }, ] @@ -13,8 +13,8 @@ export default function AdminLayout({ children: React.ReactNode }) { return ( -
-