Skip to content

Commit

Permalink
[Fix] 오류 코드 수정
Browse files Browse the repository at this point in the history
- 커뮤니티 컴포넌트 관련 코드 오류 존재하여 수정 후 커밋
* 해당 컴포넌트 작성 담당자와 합의 마친 후 수정함

Issues #14
  • Loading branch information
novice1993 committed Sep 7, 2023
1 parent 113ae9c commit 25fdeb8
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions client/src/components/communityComponents/Comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ const Comments = ({ postId }: { postId: number }) => {
setCommentData((prevCommentData) => [...prevCommentData, newCommentData]);

// 게시물 ID에 따라 로컬 스토리지에 댓글 데이터를 저장합니다.
localStorage.setItem(
`commentData_${postId}`,
JSON.stringify([...commentData, newCommentData])
);
localStorage.setItem(`commentData_${postId}`, JSON.stringify([...commentData, newCommentData]));

// 댓글 입력창 초기화
setCommentsValue("");
Expand All @@ -48,20 +45,17 @@ const Comments = ({ postId }: { postId: number }) => {
setVisibleComments(close ? 1 : commentData.length);
};

const CommentText = {
write: "작성",
replyCount: `댓글${commentData.length}개 모두보기`,
};

return (
<CommentContainer>
<div>
<CommentInput
type="text"
value={commentsValue}
onChange={handleOnChange}
/>
<CommentInputSubmit onClick={() => handleClickSubmit()}>
{CommentText.write}
</CommentInputSubmit>
<CommentCount onClick={handleShowMoreComments}>
{CommentText.replyCount}
</CommentCount>
<CommentInput type="text" value={commentsValue} onChange={handleOnChange} />
<CommentInputSubmit onClick={() => handleClickSubmit()}>{CommentText.write}</CommentInputSubmit>
<CommentCount onClick={handleShowMoreComments}>{CommentText.replyCount}</CommentCount>
{commentData.slice(0, visibleComments).map((el) => (
<CommentsDiv key={el.id}>&#187; {el.comments}</CommentsDiv>
))}
Expand All @@ -72,21 +66,18 @@ const Comments = ({ postId }: { postId: number }) => {

export default Comments;

const CommentText = {
write: "작성",
replyCount: `댓글${commentData.length}개 모두보기`,
};

const CommentInput = styled.input`
border: 1px solid#40797c;
outline: none;
width: 280px;
`;

const CommentInputSubmit = styled.button`
outline: none;
border: 1px solid#40797;
background-color: #40797;
border: 1px solid #400797;
background-color: #400797;
`;

const CommentContainer = styled.div`
display: flex;
justify-content: space-around;
Expand Down

0 comments on commit 25fdeb8

Please sign in to comment.