Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

design: admin 페이지 레이아웃 변경 #131

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/app/admin/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
]
Expand All @@ -13,8 +13,8 @@ export default function AdminLayout({
children: React.ReactNode
}) {
return (
<div className="w-full h-full bg-gray-100 text-background">
<nav className="flex gap-8 max-lg:gap-2 justify-around py-4 bg-white shadow-sm items-center shrink-0">
<div className="w-full bg-gray-100 text-background">
<nav className="fixed top-0 w-full flex gap-8 max-lg:gap-2 justify-around py-4 bg-white shadow-sm items-center shrink-0">
<div className="flex gap-2 items-center max-lg:hidden">
<Image
alt="logo.svg"
Expand All @@ -38,7 +38,7 @@ export default function AdminLayout({
서비스 메인으로
</Link>
</nav>
{children}
<div className="h-full py-12"> {children}</div>
</div>
)
}
11 changes: 8 additions & 3 deletions src/app/admin/page.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className="px-40 mt-8 overflow-y-auto">
<p className="text-h2 mb-2">전체 용어</p>
<AdminWordList />
</div>
)
}
12 changes: 0 additions & 12 deletions src/app/admin/words/page.tsx

This file was deleted.

15 changes: 10 additions & 5 deletions src/components/domain/admin/WordList/index.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<div>
{words.map((word, idx) => (
<WordListItem key={word.id} word={word} />
))}
{words &&
words.map((word: AdminWordType, idx) => (
<WordListItem key={word.id} word={word} />
))}
</div>
</>
)
Expand Down
10 changes: 10 additions & 0 deletions src/hooks/admin/useGetAllWords.tsx
Original file line number Diff line number Diff line change
@@ -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 }
}