Skip to content

Commit

Permalink
Merge pull request #365 from MovieReviewComment/feature/issue-327/com…
Browse files Browse the repository at this point in the history
…ment-card-board
  • Loading branch information
2wheeh authored May 10, 2024
2 parents e2c50ed + 02390fc commit 74868fc
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 2 deletions.
37 changes: 35 additions & 2 deletions ui/src/app/(board)/comment/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
export default function Page() {
return <>comment board</>;
import { Suspense } from 'react';

import { CommentBoardHeader } from '@/components/comment/client/comment-board-header';
import { CommentCardsList } from '@/components/comment/server/comment-cards-list';

import { COMMENT_FILTERS } from '@/lib/constants/comment';
import type { ListCommentsQuery } from '@/lib/definitions/comment';

export default function Page({
searchParams,
}: {
searchParams?: Omit<ListCommentsQuery, 'pageOffset' | 'pageSize'> & {
page?: string;
};
}) {
const query: ListCommentsQuery = {
movieName: searchParams?.movieName,
nickname: searchParams?.nickname,
pageOffset: Number(searchParams?.page),
};

const SEARCH_OPEN_KEY = COMMENT_FILTERS.reduce((acc, filter) => acc + (query[filter] ?? ''), '');

return (
<main className="container mx-auto flex max-w-5xl flex-col items-center">
<CommentBoardHeader SEARCH_OPEN_KEY={SEARCH_OPEN_KEY} />

<section className="w-full py-4">
{/* todo skeleton */}
<Suspense key={JSON.stringify(query)}>
<CommentCardsList query={query} />
</Suspense>
</section>
</main>
);
}
23 changes: 23 additions & 0 deletions ui/src/components/comment/server/comment-cards-list.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { CommentCard } from '@/components/comment/client/comment-card';
import { NoComment } from '@/components/comment/server/no-comment';
import Pagination from '@/components/common/client/pagination';

import { listComments } from '@/lib/apis/comment/server';
import type { ListCommentsQuery } from '@/lib/definitions/comment';

export async function CommentCardsList({ query }: { query: ListCommentsQuery }) {
const { comments, pagination } = await listComments(query);

return (
<div className="flex w-full flex-col items-center space-y-6">
<div className="w-full">
{comments.length > 0 &&
comments.map((comment) => <CommentCard key={comment.id} comment={comment} />)}

{comments.length === 0 && <NoComment />}
</div>

<Pagination totalPages={pagination.totalPageCount} />
</div>
);
}
13 changes: 13 additions & 0 deletions ui/src/components/comment/server/no-comment.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { XCircleIcon } from '@heroicons/react/24/outline';

import Text from '@/components/common/server/text';

export function NoComment() {
return (
<div className="flex flex-col p-6 items-center gap-8">
<XCircleIcon className="w-6 h-6 text-gray-500" />

<Text>해당하는 코멘트가 없습니다.</Text>
</div>
);
}

0 comments on commit 74868fc

Please sign in to comment.