From 5ab384c70deab50c3ce20a08e25795699e1cfea5 Mon Sep 17 00:00:00 2001 From: ww8007 Date: Wed, 26 Jul 2023 01:08:46 +0900 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20memberId=EC=99=80=20profileEmoji=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bookmarks/api/bookmark.ts | 2 ++ src/comment/ui/bookmark/CommentList.tsx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/bookmarks/api/bookmark.ts b/src/bookmarks/api/bookmark.ts index 934b996b..b6e1632f 100644 --- a/src/bookmarks/api/bookmark.ts +++ b/src/bookmarks/api/bookmark.ts @@ -430,6 +430,8 @@ export const useGETBookmarkDetailQuery = (params: GetBookmarkDetailRequest) => { export interface BookmarkCommentItem { id: number; member: string; + memberId: number; + profileEmoji: string; bookmark: string; category: string; isOwnerComment: boolean; diff --git a/src/comment/ui/bookmark/CommentList.tsx b/src/comment/ui/bookmark/CommentList.tsx index 85bd9cd1..f2f5dc47 100644 --- a/src/comment/ui/bookmark/CommentList.tsx +++ b/src/comment/ui/bookmark/CommentList.tsx @@ -43,6 +43,8 @@ const CommentList = () => { {commentList?.map((comment) => ( Date: Wed, 26 Jul 2023 01:09:07 +0900 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AA=A8=EC=A7=80=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=EC=97=90=20=EB=A0=8C=EB=8D=94=EB=A7=81=20?= =?UTF-8?q?=EB=B0=8F=20=EC=82=AC=EC=9A=A9=EC=9E=90=20=EB=88=84=EB=A5=B4?= =?UTF-8?q?=EB=A9=B4=20=EC=82=AC=EC=9A=A9=EC=9E=90=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=EB=A1=9C=20=EC=9D=B4=EB=8F=99=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/comment/ui/bookmark/CommentItem.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/comment/ui/bookmark/CommentItem.tsx b/src/comment/ui/bookmark/CommentItem.tsx index f60b28d0..b2dbdb87 100644 --- a/src/comment/ui/bookmark/CommentItem.tsx +++ b/src/comment/ui/bookmark/CommentItem.tsx @@ -6,8 +6,12 @@ import Icon from '@/common-ui/assets/Icon'; import getRem from '@/utils/getRem'; import TriggerBottomSheet from '@/common-ui/BottomSheet/TriggerBottomSheet'; import IconButton from '@/common/ui/IconButton'; +import { useNavigate } from 'react-router-dom'; +import { navigatePath } from '@/constants/navigatePath'; interface CommentProps { + id: number; + profileEmoji: string; nickname: string; content: string; updatedAt: string; @@ -18,6 +22,8 @@ interface CommentProps { } const CommentItem = ({ + id, + profileEmoji, nickname, content, updatedAt, @@ -26,14 +32,20 @@ const CommentItem = ({ onClickEdit, onClickReport, }: CommentProps) => { + const navigate = useNavigate(); + const onClickUserProfile = () => { + if (isWriter) return; + navigate(navigatePath.FRIEND_BOOKMARK.replace(':id', String(id))); + }; + return ( - + + {profileEmoji} {nickname} - {isWriter && }
From 2d5c03a298c4422dcfe570ea28d9ca55222efaba Mon Sep 17 00:00:00 2001 From: ww8007 Date: Wed, 26 Jul 2023 01:25:00 +0900 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=EB=8C=93=EA=B8=80=20=EC=8B=A0?= =?UTF-8?q?=EA=B3=A0=ED=95=98=EA=B8=B0=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 9 ++++++++- .../hooks/detail/useHandleBookmarkDetailMore.ts | 2 +- src/comment/ui/bookmark/CommentItem.tsx | 14 +++++++------- src/constants/navigatePath.ts | 3 ++- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 1f8210d7..3131c0ee 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -55,7 +55,14 @@ const App = () => { element={} /> } /> - } /> + } + /> + } + /> } diff --git a/src/bookmarks/service/hooks/detail/useHandleBookmarkDetailMore.ts b/src/bookmarks/service/hooks/detail/useHandleBookmarkDetailMore.ts index f60fccb6..af0f95a0 100644 --- a/src/bookmarks/service/hooks/detail/useHandleBookmarkDetailMore.ts +++ b/src/bookmarks/service/hooks/detail/useHandleBookmarkDetailMore.ts @@ -60,7 +60,7 @@ const useHandleBookmarkDetailMore = () => { const writtenId = bookmarkDetail?.memberId ?? 0; const isMyBookmark = memberId === writtenId; const onClickReportBookmark = () => { - router(navigatePath.REPORT.replace(':id', id)); + router(navigatePath.BOOKMARK_REPORT.replace(':id', id)); }; return { diff --git a/src/comment/ui/bookmark/CommentItem.tsx b/src/comment/ui/bookmark/CommentItem.tsx index b2dbdb87..092e2f21 100644 --- a/src/comment/ui/bookmark/CommentItem.tsx +++ b/src/comment/ui/bookmark/CommentItem.tsx @@ -11,6 +11,7 @@ import { navigatePath } from '@/constants/navigatePath'; interface CommentProps { id: number; + memberId: number; profileEmoji: string; nickname: string; content: string; @@ -18,11 +19,11 @@ interface CommentProps { isWriter: boolean; onClickDelete?: () => void; onClickEdit?: () => void; - onClickReport?: () => void; } const CommentItem = ({ id, + memberId, profileEmoji, nickname, content, @@ -30,12 +31,14 @@ const CommentItem = ({ isWriter, onClickDelete, onClickEdit, - onClickReport, }: CommentProps) => { const navigate = useNavigate(); const onClickUserProfile = () => { if (isWriter) return; - navigate(navigatePath.FRIEND_BOOKMARK.replace(':id', String(id))); + navigate(navigatePath.FRIEND_BOOKMARK.replace(':id', String(memberId))); + }; + const onClickReport = () => { + navigate(navigatePath.COMMENT_REPORT.replace(':id', String(id))); }; return ( @@ -61,10 +64,7 @@ const CommentItem = ({ onClickEdit={onClickEdit ?? (() => {})} /> ) : ( - {})} - /> + )} diff --git a/src/constants/navigatePath.ts b/src/constants/navigatePath.ts index d110d128..161adfd1 100644 --- a/src/constants/navigatePath.ts +++ b/src/constants/navigatePath.ts @@ -14,7 +14,8 @@ const navigatePath = { CATEGORY_ADD: '/category/add', CATEGORY_EDIT: '/category/edit/:id', CATEGORY_LIST: '/category/list', - REPORT: '/bookmark/:id/report', + COMMENT_REPORT: '/comment/:id/report', + BOOKMARK_REPORT: '/bookmark/:id/report', COMMENT: '/comment', LIKE_PAGE: '/likes', } as const; From 20cb9aa254ef3787c22939938f5ce64cbdda8092 Mon Sep 17 00:00:00 2001 From: ww8007 Date: Wed, 26 Jul 2023 01:25:26 +0900 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20=EB=8C=93=EA=B8=80=20=EC=8B=A0?= =?UTF-8?q?=EA=B3=A0=20=EC=9E=84=EC=8B=9C=20=EC=97=B0=EB=8F=99=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/comment/api/Comment.ts | 56 ++++++++++++++++++++++++++++++++++++++ src/pages/ReportPage.tsx | 37 +++++++++++++++++-------- 2 files changed, 82 insertions(+), 11 deletions(-) diff --git a/src/comment/api/Comment.ts b/src/comment/api/Comment.ts index ca3f834e..d5d050ab 100644 --- a/src/comment/api/Comment.ts +++ b/src/comment/api/Comment.ts @@ -3,6 +3,8 @@ import client from '@/common/service/client'; import { navigatePath } from '../../constants/navigatePath'; import { GET_BOOKMARK_COMMENT } from '@/bookmarks/api/bookmark'; import useToast from '@/common-ui/Toast/hooks/useToast'; +import { useNavigate } from 'react-router-dom'; +import { AxiosError } from 'axios'; const DOMAIN = 'COMMENT'; @@ -191,3 +193,57 @@ export const useDELETECommentQuery = ({ }, }); }; + +// 댓글 신고 +interface POSTCommentReportRequest { + reporterId: number; + reportedId: number; + content: string; +} + +const postCommentReportAPI = async (params: POSTCommentReportRequest) => { + const { data } = await client({ + method: 'post', + url: '/reports/comments', + data: params, + }); + + return data; +}; + +const dummyCommentReportAPI = async (params: POSTCommentReportRequest) => { + console.log(params); + return new Promise((resolve) => { + resolve({ + data: true, + }); + }); +}; + +export interface POSTBookmarkReportMutation { + reporterId: number; +} + +export const usePOSTReportCommentQuery = () => { + const toast = useToast(); + const router = useNavigate(); + return useMutation(dummyCommentReportAPI, { + onSuccess: () => { + toast.fireToast({ + message: '신고 되었습니다', + mode: 'SUCCESS', + }); + router(-1); + }, + onError: (e: AxiosError) => { + const errorCode = e.response?.status; + if (errorCode && errorCode === 500) { + toast.fireToast({ + message: '이미 신고한 북마크에요', + mode: 'DELETE', + }); + router(-1); + } + }, + }); +}; diff --git a/src/pages/ReportPage.tsx b/src/pages/ReportPage.tsx index bc0a39a5..a9f9b826 100644 --- a/src/pages/ReportPage.tsx +++ b/src/pages/ReportPage.tsx @@ -1,6 +1,7 @@ import { usePOSTBookmarkReportMutation } from '@/bookmarks/api/bookmark'; import BookmarkReportList from '@/bookmarks/ui/Report/BookmarkReportList'; import BookmarkReportWrite from '@/bookmarks/ui/Report/BookmarkReportWrite'; +import { usePOSTReportCommentQuery } from '@/comment/api/Comment'; import BottomFixedButton from '@/common-ui/BottomFixedButton'; import Header from '@/common-ui/Header/Header'; import Text from '@/common-ui/Text'; @@ -12,8 +13,12 @@ import { useParams } from 'react-router-dom'; export type ReportMode = 'CHECK' | 'WRITE'; -const ReportPage = () => { - const [mode, setMode] = useState('CHECK'); +interface ReportPageProps { + mode: 'BOOKMARK' | 'COMMENT'; +} + +const ReportPage = ({ mode }: ReportPageProps) => { + const [reportMode, setReportMode] = useState('CHECK'); const [reportText, setReportText] = useState(''); const [selectedReport, setSelectedReport] = useState(''); const { memberId } = useAuthStore(); @@ -27,18 +32,28 @@ const ReportPage = () => { const { mutate: reportBookmark } = usePOSTBookmarkReportMutation({ reporterId: memberId, }); + const { mutate: reportComment } = usePOSTReportCommentQuery(); const onSubmit = (e: React.FormEvent) => { e.preventDefault(); - const content = mode === 'WRITE' ? reportText : selectedReport; - reportBookmark({ - reportedId: Number(id), - reporterId: memberId, - content, - }); + const content = reportMode === 'WRITE' ? reportText : selectedReport; + if (mode === 'BOOKMARK') { + reportBookmark({ + reportedId: Number(id), + reporterId: memberId, + content, + }); + } + if (mode === 'COMMENT') { + reportComment({ + reportedId: Number(id), + reporterId: memberId, + content, + }); + } }; const buttonDisabled = - mode === 'WRITE' ? !reportText.length : !selectedReport.length; + reportMode === 'WRITE' ? !reportText.length : !selectedReport.length; return ( <> @@ -48,12 +63,12 @@ const ReportPage = () => { 신고 사유를 선택해 주세요 From d005569d6719110898eca6ef9426f3510a51e94f Mon Sep 17 00:00:00 2001 From: ww8007 Date: Wed, 26 Jul 2023 01:25:37 +0900 Subject: [PATCH 5/6] =?UTF-8?q?fix:=20memberId=EC=99=80=20id=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC=ED=95=98=EC=97=AC=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/comment/ui/bookmark/CommentList.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/comment/ui/bookmark/CommentList.tsx b/src/comment/ui/bookmark/CommentList.tsx index f2f5dc47..80a6088a 100644 --- a/src/comment/ui/bookmark/CommentList.tsx +++ b/src/comment/ui/bookmark/CommentList.tsx @@ -43,7 +43,8 @@ const CommentList = () => { {commentList?.map((comment) => ( Date: Wed, 26 Jul 2023 01:28:05 +0900 Subject: [PATCH 6/6] =?UTF-8?q?fix:=20=EC=82=AC=EC=9A=A9=ED=95=98=EC=A7=80?= =?UTF-8?q?=20=EC=95=8A=EB=8A=94=20api=20=EC=9E=84=EC=8B=9C=20=EC=A3=BC?= =?UTF-8?q?=EC=84=9D=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/comment/api/Comment.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/comment/api/Comment.ts b/src/comment/api/Comment.ts index d5d050ab..c5efd34e 100644 --- a/src/comment/api/Comment.ts +++ b/src/comment/api/Comment.ts @@ -201,15 +201,15 @@ interface POSTCommentReportRequest { content: string; } -const postCommentReportAPI = async (params: POSTCommentReportRequest) => { - const { data } = await client({ - method: 'post', - url: '/reports/comments', - data: params, - }); - - return data; -}; +// const postCommentReportAPI = async (params: POSTCommentReportRequest) => { +// const { data } = await client({ +// method: 'post', +// url: '/reports/comments', +// data: params, +// }); + +// return data; +// }; const dummyCommentReportAPI = async (params: POSTCommentReportRequest) => { console.log(params);