Skip to content

Commit

Permalink
Merge pull request #97 from modern-agile-team/feature/boardComment/#68
Browse files Browse the repository at this point in the history
Fix(JaeJin/boardReComment) : 대댓글 UX기능 수정
  • Loading branch information
zzzRYT authored Nov 21, 2023
2 parents 2a82b06 + cac2bf4 commit 1e2a69f
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/apis/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const COMMENTS = {
},
},
);
return result;
return result.data;
},

//reComment 삭제 api [delete요청]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const PostCreateReComment = ({ commentId }: PostCreateRCommentProps) => {
useSetRecoilState<ReCommentCreateType>(ReCommentLoadAtom);
const loginState = useRecoilValue(LoginStateAtom);

console.log('Com', commentId);

const handleInputReComment = (e: React.ChangeEvent<HTMLInputElement>) => {
const event = e.target.value;
setModifyReComment(event);
Expand All @@ -42,7 +44,8 @@ const PostCreateReComment = ({ commentId }: PostCreateRCommentProps) => {
setCreateReComment((prev) => {
return {
...prev,
id: commentId,
id: response.id,
commentId: commentId,
content: modifyReComment,
user: {
name: userInfo.userName,
Expand Down
2 changes: 2 additions & 0 deletions src/components/molecules/post-comment/PostReComment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const PostReComment = ({ reComment }: PostReCommentProps) => {
);
const focusOnInput = useRef<HTMLInputElement>(null);

console.log('Re', reComment);

//대댓글 삭제 핸들러
const handleDelReComment = async () => {
handleModal();
Expand Down
3 changes: 2 additions & 1 deletion src/components/molecules/post-comment/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const Option = styled.div`
font-size: 14px;
padding: 6px 8px;
transition: background-color 0.2s ease-in;
cursor: pointer;
&:hover {
background-color: #ddd;
}
Expand All @@ -62,7 +63,7 @@ export const CommentInput = styled.input`
outline: none;
border: none;
width: 250px;
margin: 0px 0px 10px 0px;
margin: 0px 0px 10px 10px;
`;

export const CommentSubmitButton = styled.button`
Expand Down
6 changes: 4 additions & 2 deletions src/components/organisms/post-unit/PostComments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import PostCreateReComment from '@/components/molecules/post-comment/PostCreateR

export interface ReCommentCreateType {
id: number;
commentId: number;
content: string;
reCommentowner: boolean;
user: {
Expand All @@ -42,6 +43,7 @@ const PostComments = (commentData: CommentInfo) => {
useRecoilValue<ReCommentCreateType>(ReCommentLoadAtom);
const focusOnInput = useRef<HTMLInputElement>(null);
const [tempDelArr, setTempDelArr] = useState<ReCommentCreateType[]>([]);
const [reCommentIdNumber, setReCommenntIdNumber] = useState(0);

//댓글 삭제 핸들러
const handleDelComment = async () => {
Expand Down Expand Up @@ -82,7 +84,7 @@ const PostComments = (commentData: CommentInfo) => {
useEffect(() => {
if (
getCreateReComment.content.length > 0 &&
commentData.id === getCreateReComment.id
commentData.id === getCreateReComment.commentId
) {
setReCommentList((prev) => [...prev, getCreateReComment]);
}
Expand Down Expand Up @@ -130,7 +132,7 @@ const PostComments = (commentData: CommentInfo) => {
</form>
</S.CommentArea>
{commentData.commentowner && (
<div>
<div style={{ cursor: 'pointer' }}>
{isOpenModal && (
<Modal show={isOpenModal} hide={handleModal}>
<div>
Expand Down
1 change: 1 addition & 0 deletions src/components/organisms/post-unit/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export const Option = styled.div`
font-size: 14px;
padding: 6px 8px;
transition: background-color 0.2s ease-in;
cursor: pointer;
&:hover {
background-color: #ddd;
}
Expand Down
1 change: 1 addition & 0 deletions src/recoil/atoms/CommentAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const ReCommentLoadAtom = atom<ReCommentCreateType>({
key: 'reCommentLoad',
default: {
content: '',
commentId: 0,
reCommentowner: true,
id: 0,
user: {
Expand Down

0 comments on commit 1e2a69f

Please sign in to comment.