diff --git a/components/community/ContentCard.tsx b/components/community/ContentCard.tsx index 6818b40..8310365 100644 --- a/components/community/ContentCard.tsx +++ b/components/community/ContentCard.tsx @@ -10,7 +10,7 @@ interface ContentInfoProps { content: string; userNickname?: string; replyCount?: number; - createdAt?: string; + createdAt: string; img?: string; } @@ -30,16 +30,25 @@ export default function ContentCard(props: ContentInfoProps) { - Router.push({ pathname: `/community/${id}` })} - > -

{title}

-

{content}

-
+ {!img ? ( + Router.push({ pathname: `/community/${id}` })} + > +

{title}

+

{content}

+
+ ) : ( + Router.push({ pathname: `/community/${id}` })} + > +

{title}

+

{content}

+
+ )} {userNickname} - {createdAt?.split('T')[0]} + {createdAt.split('T')[0]} @@ -48,9 +57,7 @@ export default function ContentCard(props: ContentInfoProps) { {replyCount}
- {img === undefined ? ( - <> - ) : ( + {img && ( theme.colors.gray005}; h1 { - width: 92.3rem; margin-top: 1.6rem; margin-bottom: 0.7rem; @@ -95,7 +101,13 @@ const StContentsCardWrapper = styled.div` cursor: pointer; } `; -const StMainInfo = styled.article``; +const StMainInfo = styled.article` + width: 97.6rem; +`; +const StImgMainInfo = styled.article` + width: 72.5rem; + margin-right: 3.3rem; +`; const StContentInfo = styled.section` display: flex; flex-direction: column; diff --git a/components/community/ReplyContent.tsx b/components/community/ReplyContent.tsx index 97828ff..b0abf93 100644 --- a/components/community/ReplyContent.tsx +++ b/components/community/ReplyContent.tsx @@ -6,11 +6,11 @@ interface ReplyContentProps { author: boolean; userNickname?: string; content: string; - createdAt: string; + createAt: string; } export default function ReplyContent(props: ReplyContentProps) { - const { userNickname, content, createdAt, author } = props; + const { userNickname, content, createAt, author } = props; return ( @@ -21,7 +21,7 @@ export default function ReplyContent(props: ReplyContentProps) {

{content}

- {createdAt} · {author ? '삭제' : '신고'} + {createAt.split('T')[0]} · {author ? '삭제' : '신고'}
diff --git a/components/community/ReplyList.tsx b/components/community/ReplyList.tsx index 968b3ee..93fc0cf 100644 --- a/components/community/ReplyList.tsx +++ b/components/community/ReplyList.tsx @@ -1,5 +1,5 @@ import styled from '@emotion/styled'; -import { useState, useEffect } from 'react'; +import { useState, useEffect, InputHTMLAttributes } from 'react'; import { postReply } from '../../core/api/community'; import { CommunityData, @@ -29,12 +29,11 @@ export default function ReplyList(props: ReplyListProps) { const [isFirst, setIsFirst] = useState(true); const handleInputText = (e: React.ChangeEvent) => { - setReplyText(e.target.value); - setNewReplyInfo({ ...newReplyInfo, content: e.target.value }); + setNewReplyInfo({ boardId: cid, content: e.target.value }); }; - const handleInputColor = () => { - setInputColor(replyText.length !== 0); + const handleInputColor = (e: any) => { + setInputColor(e.target.value.length !== 0); }; const handleReplyregister = async () => { @@ -44,12 +43,13 @@ export default function ReplyList(props: ReplyListProps) { return; } - const data = await postReply(newReplyInfo); + const status = await postReply(newReplyInfo); setNewReplyInfo({ - boardId: `${cid}`, + boardId: cid, content: replyText, }); - router.push(`/community/${data.id}`); + if (status === 200) router.push(`/community/${cid}`); + setNewReplyInfo({ boardId: cid, content: '' }); }; const handleCurrentPage = (nextPage: number) => { setCurrentPage(nextPage); @@ -89,20 +89,18 @@ export default function ReplyList(props: ReplyListProps) { - {pageReplyList.map( - ({ author, userNickname, content, createdAt }, idx) => ( - - ), - )} + {replyList.map(({ author, userNickname, content, createAt }, idx) => ( + + ))} - {replyList && ( + {pageReplyList && ( { export const postReply = async (body: PostCommentBody) => { try { - const { data } = await baseInstance.post('/board/comment', body); - return data; + const { status } = await baseInstance.post('/board/comment', body); + return status; } catch (e) { console.log(e); } diff --git a/types/community.ts b/types/community.ts index 675c3a8..9bc7542 100644 --- a/types/community.ts +++ b/types/community.ts @@ -3,7 +3,7 @@ export interface ReplyData { author: boolean; userNickname?: string; content: string; - createdAt: string; + createAt: string; } // 커뮤니티 데이터 export interface CommunityData { @@ -26,6 +26,7 @@ export interface PostCommunityBody { content: string; imageList?: ImgData[]; } + // 커뮤니티 수정 put body export interface PutCommunityBody { category?: string; @@ -40,11 +41,13 @@ export interface IsChangeCommunity { isChangeContent: boolean; isChangeImageList: boolean; } + // 커뮤니티 댓글 export interface PostCommentBody { boardId?: string; content: string; } + export interface GetCommunityList { communityList: CommunityData[]; isLoading: boolean;