-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
invalidate 로직 리팩토링 & 삭제 확인 모달 기능 추가 (#147)
- Loading branch information
Showing
33 changed files
with
515 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
app/(route)/boards/[boardType]/list/[category]/[page]/_components/BoardBody/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
'use client'; | ||
|
||
import Link from 'next/link'; | ||
import { useParams } from 'next/navigation'; | ||
|
||
import { | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableHeader, | ||
TableRow, | ||
} from '@app/_shadcn/components/ui/table'; | ||
import { BoardListParams } from '@app/_types/boardTypes'; | ||
import formateDate from '@app/_utils/formatDate'; | ||
import { BookOpen, MessageCircle, File } from 'lucide-react'; | ||
import { Tooltip, TooltipContent } from '@app/_shadcn/components/ui/tooltip'; | ||
import { TooltipTrigger } from '@app/_shadcn/components/plate-ui/tooltip'; | ||
import { Badge } from '@app/_shadcn/components/ui/badge'; | ||
import useArticleListQuery from '@app/_hooks/apis/boards/useArticleListQuery'; | ||
|
||
function BoardBody() { | ||
const params = useParams<BoardListParams>(); | ||
const { data } = useArticleListQuery({ | ||
boardType: params.boardType, | ||
page: Number(params.page), | ||
category: params.category, | ||
}); | ||
|
||
if (!data || data.articleList.length === 0) | ||
return <div className="flex-center h-40">게시글이 없어요. 😭</div>; | ||
|
||
const { articleList } = data; | ||
return ( | ||
<Table aria-label="article table"> | ||
<TableHeader> | ||
<TableRow> | ||
<TableHead className="text-center">번호</TableHead> | ||
<TableHead>제목</TableHead> | ||
<TableHead className="text-center">작성자</TableHead> | ||
<TableHead className="hidden text-center lg:table-cell"> | ||
날짜 | ||
</TableHead> | ||
<TableHead className="hidden text-center lg:table-cell"> | ||
조회수 | ||
</TableHead> | ||
</TableRow> | ||
</TableHeader> | ||
|
||
<TableBody> | ||
{articleList?.map( | ||
({ | ||
articleId, | ||
title, | ||
view, | ||
nickname, | ||
createdAt, | ||
hide, | ||
numOfComments, | ||
file, | ||
category, | ||
}) => { | ||
const formattedDate = formateDate(createdAt); | ||
return ( | ||
<Link | ||
key={articleId} | ||
href={`/boards/${params.boardType}/detail/${articleId}`} | ||
legacyBehavior | ||
> | ||
<TableRow key={articleId} className="cursor-pointer"> | ||
<TableCell className="text-center">{articleId}</TableCell> | ||
<TableCell className="flex items-center"> | ||
{category !== 'all' && ( | ||
<Badge variant="secondary" className="mr-2 shrink-0"> | ||
{category} | ||
</Badge> | ||
)} | ||
|
||
<span className="flex-center"> | ||
{hide && ( | ||
<Tooltip> | ||
<TooltipTrigger> | ||
<BookOpen | ||
className="mr-2 stroke-muted-foreground" | ||
size={15} | ||
/> | ||
</TooltipTrigger> | ||
<TooltipContent> | ||
해당 글은 정회원만 열람 가능해요. | ||
</TooltipContent> | ||
</Tooltip> | ||
)} | ||
</span> | ||
<span className="truncate hover:text-clip">{title}</span> | ||
<div className="ml-auto flex items-center gap-4 text-xs text-muted-foreground"> | ||
{numOfComments > 0 && ( | ||
<span className="flex items-center gap-1"> | ||
<MessageCircle size={14} /> | ||
{numOfComments} | ||
</span> | ||
)} | ||
{file && ( | ||
<span> | ||
<File size={14} /> | ||
</span> | ||
)} | ||
</div> | ||
</TableCell> | ||
<TableCell className="truncate text-center"> | ||
{nickname} | ||
</TableCell> | ||
<TableCell className="hidden text-center lg:table-cell"> | ||
{formattedDate} | ||
</TableCell> | ||
<TableCell className="hidden text-center lg:table-cell"> | ||
{view} | ||
</TableCell> | ||
</TableRow> | ||
</Link> | ||
); | ||
}, | ||
)} | ||
</TableBody> | ||
</Table> | ||
); | ||
} | ||
|
||
export default BoardBody; |
14 changes: 12 additions & 2 deletions
14
...components/BoardHeader/CategorySelect.tsx → ...components/BoardHeader/CategorySelect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.