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/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/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(() => { 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 (
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('읽음처리 에러 발생'); } };