Skip to content

Commit

Permalink
refactor: 변수, prop 이름 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
gxxrxn committed Feb 19, 2024
1 parent d187118 commit 59aef4d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/v1/comment/BookGroupCommentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ const BookGroupCommentList = ({ groupId }: { groupId: number }) => {
const { data: myId } = useMyProfileId({ enabled: isAuthed() });
const { isPublic, isMember } = bookGroupInfo;

const hidden = !isPublic && !isMember;
const isHidden = !isPublic && !isMember;

return (
<CommentList
name={'게시글'}
comments={comments}
isEditableComment={({ writer }) => writer.id === myId}
hidden={hidden}
isHidden={isHidden}
hiddenText={`멤버만 볼 수 있어요 🥲`}
emptyText={`아직 게시글이 없어요.
가장 먼저 게시글을 남겨보세요!`}
Expand Down
44 changes: 22 additions & 22 deletions src/v1/comment/CommentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,30 @@ type Comment = {
interface CommentListProps {
comments: Comment[];
name?: string;
hidden?: boolean;
isHidden?: boolean;
hiddenText?: string;
emptyText?: string;
isEditableComment?: (comment: Comment) => boolean;
onChangeConfirm?: (commentId: Comment['id']) => void;
onEditConfirm?: (commentId: Comment['id']) => void;
onDeleteConfirm?: (commentId: Comment['id']) => void;
}

const CommentList = ({
name = '코멘트',
comments,
hidden,
isHidden,
hiddenText,
emptyText,
isEditableComment,
onChangeConfirm,
onEditConfirm,
onDeleteConfirm,
}: CommentListProps) => {
const titleOnCommentChange = useMemo(
const titleOnCommentEdit = useMemo(
() => [name, '수정하기'].join(' '),
[name]
);

if (hidden) {
if (isHidden) {
return <p className="py-[2rem] text-center text-sm">{hiddenText}</p>;
}

Expand All @@ -55,11 +55,11 @@ const CommentList = ({
}

return (
<div className="flex flex-col gap-[1rem]">
<ul className="flex flex-col gap-[1rem]">
{comments.map(comment => {
const { id, writer, createdAt, content } = comment;
return (
<div className="flex flex-col gap-[1rem] py-[1rem]" key={id}>
<li className="flex flex-col gap-[1rem] py-[1rem]" key={id}>
<div className="flex gap-[1rem]">
<Avatar
src={writer.profileImageSrc}
Expand All @@ -71,19 +71,19 @@ const CommentList = ({
<Date date={createdAt} />
</div>
{isEditableComment && isEditableComment(comment) && (
<EditCommentMenu
<CommentActionMenu
comment={comment}
titleOnCommentChange={titleOnCommentChange}
onChangeConfirm={onChangeConfirm}
titleOnCommentEdit={titleOnCommentEdit}
onEditConfirm={onEditConfirm}
onDeleteConfirm={onDeleteConfirm}
/>
)}
</div>
<CommentContent content={content} />
</div>
</li>
);
})}
</div>
</ul>
);
};

Expand All @@ -101,15 +101,15 @@ const CommentContent = ({ content }: { content: string }) => (
<p className="text-justify text-md">{content}</p>
);

const EditCommentMenu = ({
const CommentActionMenu = ({
comment,
titleOnCommentChange,
onChangeConfirm,
titleOnCommentEdit,
onEditConfirm,
onDeleteConfirm,
}: {
comment: Comment;
titleOnCommentChange?: string;
onChangeConfirm?: (commentId: Comment['id']) => void;
titleOnCommentEdit?: string;
onEditConfirm?: (commentId: Comment['id']) => void;
onDeleteConfirm?: (commentId: Comment['id']) => void;
}) => {
const { id: commentId, content } = comment;
Expand All @@ -127,7 +127,7 @@ const EditCommentMenu = ({
} = useDisclosure();

const handleChangeConfirm = () => {
onChangeConfirm && onChangeConfirm(commentId);
onEditConfirm && onEditConfirm(commentId);
};

const handleDeleteConfirm = () => {
Expand All @@ -143,11 +143,11 @@ const EditCommentMenu = ({
<Menu.Item onSelect={onModalOpen}>삭제하기</Menu.Item>
</Menu.DropdownList>
</Menu>
<ChangeCommentDrawer
<EditCommentDrawer
isOpen={isDrawerOpen}
onClose={onDrawerClose}
onConfirm={handleChangeConfirm}
drawerTitle={titleOnCommentChange}
drawerTitle={titleOnCommentEdit}
defaultComment={content}
/>
<DeleteCommentModal
Expand All @@ -159,7 +159,7 @@ const EditCommentMenu = ({
);
};

const ChangeCommentDrawer = ({
const EditCommentDrawer = ({
isOpen,
onClose,
onConfirm,
Expand Down

0 comments on commit 59aef4d

Please sign in to comment.