diff --git a/ui/src/components/comment/client/comment-board-header.tsx b/ui/src/components/comment/client/comment-board-header.tsx new file mode 100644 index 00000000..0d84ebea --- /dev/null +++ b/ui/src/components/comment/client/comment-board-header.tsx @@ -0,0 +1,71 @@ +'use client'; + +import { useEffect, useState } from 'react'; + +import { CommentCardHeader } from '@/components/comment/client/comment-card-header'; +import { CommentEditable } from '@/components/comment/client/comment-editable'; +import { CreateCommentButton } from '@/components/comment/client/create-comment-button'; +import SearchForm from '@/components/common/client/search-form'; +import { BoardHeader } from '@/components/common/server/board-header'; +import Text from '@/components/common/server/text'; + +import { useAuth } from '@/context/auth/auth-context'; +import { CommentProvider } from '@/context/comment/comment-context'; + +import { COMMENT_FILTERS } from '@/lib/constants/comment'; + +export function CommentBoardHeader({ SEARCH_OPEN_KEY }: { SEARCH_OPEN_KEY: string }) { + const [open, setOpen] = useState(null); + + useEffect(() => { + if (SEARCH_OPEN_KEY) { + setOpen('search'); + } + }, [SEARCH_OPEN_KEY]); + + const { user, signIn } = useAuth(); + + const handleClickNewComment = () => { + if (!user) { + signIn(); + return; + } + + setOpen((prev) => (prev === 'write' ? null : 'write')); + }; + + return ( + +
+
+ + + +
+ + {open !== null && ( +
+ {open === 'search' && } + + {open === 'write' && ( + + + } /> + + )} +
+ )} +
+
+ ); +} diff --git a/ui/src/lib/constants/comment.ts b/ui/src/lib/constants/comment.ts index d7f14e2e..d4fa4979 100644 --- a/ui/src/lib/constants/comment.ts +++ b/ui/src/lib/constants/comment.ts @@ -1 +1,5 @@ +import type { CommentFilter } from '@/lib/definitions/comment'; + export const MAX_COMMENT_LENGTH = 500; + +export const COMMENT_FILTERS: (keyof CommentFilter)[] = ['movieName', 'nickname'];