From 379c7e4408ceed128a9e54148e2f103763eb2a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=88=EC=A7=80=EC=9B=90?= Date: Sun, 9 Mar 2025 19:29:20 +0900 Subject: [PATCH 1/3] =?UTF-8?q?refactor=20:=20API=20=EC=9D=BC=EB=B6=80=20?= =?UTF-8?q?=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/admin.ts | 20 ++++++++----------- src/pages/Admin/components/AddInputButton.tsx | 7 ++++--- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/apis/admin.ts b/src/apis/admin.ts index c5152e7..5eb1580 100644 --- a/src/apis/admin.ts +++ b/src/apis/admin.ts @@ -3,9 +3,8 @@ import client from './client'; const postReports = async (postReportRequest: PostReportRequest) => { try { const res = await client.post(`/api/reports`, postReportRequest); - if (res.status === 200) { - return res; - } + if (!res) throw new Error('신고 요청중 에러가 발생했습니다.'); + return res; } catch (error) { console.error(error); } @@ -51,25 +50,22 @@ const getBadWords = async (setBadWords: React.Dispatch void) => { +const postBadWords = async (badWordsRequest: BadWords) => { try { const res = await client.post('/api/bad-words', badWordsRequest); - if (callBack) callBack(); console.log(res); + if (!res) throw new Error('금칙어 등록 도중 에러가 발생했습니다.'); + return res; } catch (error) { console.error(error); } }; // 내 상상대로 만든 필터링 단어 취소 버튼 -const patchBadWords = async ( - badWordId: number, - badWordsRequest: BadWords, - callBack?: () => void, -) => { +const patchBadWords = async (badWordId: number) => { try { - const res = await client.patch(`/api/bad-words/${badWordId}/status`, badWordsRequest); - if (callBack) callBack(); + const res = await client.patch(`/api/bad-words/${badWordId}/status`, { isUsed: false }); + if (!res) throw new Error('검열 단어 삭제 도중 에러가 발생했습니다.'); console.log(res); } catch (error) { console.error(error); diff --git a/src/pages/Admin/components/AddInputButton.tsx b/src/pages/Admin/components/AddInputButton.tsx index 8b04232..72ac896 100644 --- a/src/pages/Admin/components/AddInputButton.tsx +++ b/src/pages/Admin/components/AddInputButton.tsx @@ -19,12 +19,13 @@ export default function AddInputButton({ target.style.width = `${target.scrollWidth}px`; }; - const handlePostBadWords = () => { + const handlePostBadWords = async () => { if (inputText.word === '') return setAddInputShow(false); - postBadWords(inputText, () => { + const res = await postBadWords(inputText); + if (res?.status === 200) { setBadWords((cur) => [...cur, inputText]); setAddInputShow(false); - }); + } }; useEffect(() => { From 077309afbf15d877dabf1ec5dec7627a1d4212ce Mon Sep 17 00:00:00 2001 From: "wl990@naver.com" Date: Sun, 9 Mar 2025 21:47:18 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat=20:=20=EC=95=8C=EB=A6=BC=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EC=95=8C=EB=A6=BC=20=EB=8B=A8=EC=9D=BC?= =?UTF-8?q?=ED=99=95=EC=9D=B8=EC=8B=9C=20=EC=9D=BD=EC=9D=8C=EC=95=8C?= =?UTF-8?q?=EB=A6=BC=EC=9C=BC=EB=A1=9C=20=EC=B2=98=EB=A6=AC=EB=90=98?= =?UTF-8?q?=EC=A7=80=EC=95=8A=EB=8D=98=20=ED=98=84=EC=83=81=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Notifications/index.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pages/Notifications/index.tsx b/src/pages/Notifications/index.tsx index 7226f55..a3c0cdc 100644 --- a/src/pages/Notifications/index.tsx +++ b/src/pages/Notifications/index.tsx @@ -48,7 +48,16 @@ const NotificationsPage = () => { const handlePatchReadNotification = async (timelineId: number) => { const res = await patchReadNotification(timelineId); - if (res?.status !== 200) { + if (res?.status === 200) { + setNoti((curNoti) => + curNoti.map((noti) => { + if (noti.timelineId === timelineId) { + return { ...noti, read: true }; + } + return noti; + }), + ); + } else { console.log('읽음처리 에러 발생'); } }; From 834bd4080a6f3a2d280508ac52205735cf776c31 Mon Sep 17 00:00:00 2001 From: "wl990@naver.com" Date: Sun, 9 Mar 2025 22:46:04 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat=20:=20=EC=8B=A0=EA=B3=A0=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20status=20=ED=95=84=ED=84=B0=EB=A7=81=20?= =?UTF-8?q?=EC=9E=84=EC=8B=9C=20=EA=B5=AC=ED=98=84(=EC=88=98=EC=A0=95?= =?UTF-8?q?=ED=95=B4=EC=95=BC=ED=95=A8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Admin/Report.tsx | 20 +++++++++++++++++-- .../Admin/components/PagenationNavigation.tsx | 3 ++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/pages/Admin/Report.tsx b/src/pages/Admin/Report.tsx index dc52d8c..d107ef6 100644 --- a/src/pages/Admin/Report.tsx +++ b/src/pages/Admin/Report.tsx @@ -28,7 +28,7 @@ export default function ReportManage() { reportType: null, status: 'PENDING', page: '1', - size: '2', + size: '1', }); const handleGetReports = async (reportQueryString: ReportQueryString) => { @@ -47,6 +47,10 @@ export default function ReportManage() { setReportQueryString((cur) => ({ ...cur, page: page })); }; + const handleStatus = (status: Status) => { + setReportQueryString((cur) => ({ ...cur, status: status })); + }; + useEffect(() => { handleGetReports(reportQueryString); }, [reportQueryString]); @@ -54,7 +58,19 @@ export default function ReportManage() { <> 검열 관리 / 신고 편지 목록 - +
+ + +
diff --git a/src/pages/Admin/components/PagenationNavigation.tsx b/src/pages/Admin/components/PagenationNavigation.tsx index 1bfa810..44a86a4 100644 --- a/src/pages/Admin/components/PagenationNavigation.tsx +++ b/src/pages/Admin/components/PagenationNavigation.tsx @@ -50,7 +50,8 @@ export default function PagenationNavigation({ } }; - const buttonStyle = 'rounded-full bg-white w-8 h-8 disabled:bg-gray-20'; + const buttonStyle = + 'rounded-full bg-white w-8 h-8 disabled:bg-gray-20 disabled:text-white disabled:cursor-auto'; return (