Skip to content

Commit a8144d5

Browse files
authored
feat : 알림 페이지 알림 확인 처리 안되던 현상 수정 + 신고페이지 4차 구현 (#101)
* refactor : API 일부 리팩토링 * feat : 알림페이지 알림 단일확인시 읽음알림으로 처리되지않던 현상 수정 * feat : 신고 페이지 status 필터링 임시 구현(수정해야함)
1 parent 6917b3b commit a8144d5

File tree

5 files changed

+42
-19
lines changed

5 files changed

+42
-19
lines changed

src/apis/admin.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import client from './client';
33
const postReports = async (postReportRequest: PostReportRequest) => {
44
try {
55
const res = await client.post(`/api/reports`, postReportRequest);
6-
if (res.status === 200) {
7-
return res;
8-
}
6+
if (!res) throw new Error('신고 요청중 에러가 발생했습니다.');
7+
return res;
98
} catch (error) {
109
console.error(error);
1110
}
@@ -51,25 +50,22 @@ const getBadWords = async (setBadWords: React.Dispatch<React.SetStateAction<BadW
5150
}
5251
};
5352

54-
const postBadWords = async (badWordsRequest: BadWords, callBack?: () => void) => {
53+
const postBadWords = async (badWordsRequest: BadWords) => {
5554
try {
5655
const res = await client.post('/api/bad-words', badWordsRequest);
57-
if (callBack) callBack();
5856
console.log(res);
57+
if (!res) throw new Error('금칙어 등록 도중 에러가 발생했습니다.');
58+
return res;
5959
} catch (error) {
6060
console.error(error);
6161
}
6262
};
6363

6464
// 내 상상대로 만든 필터링 단어 취소 버튼
65-
const patchBadWords = async (
66-
badWordId: number,
67-
badWordsRequest: BadWords,
68-
callBack?: () => void,
69-
) => {
65+
const patchBadWords = async (badWordId: number) => {
7066
try {
71-
const res = await client.patch(`/api/bad-words/${badWordId}/status`, badWordsRequest);
72-
if (callBack) callBack();
67+
const res = await client.patch(`/api/bad-words/${badWordId}/status`, { isUsed: false });
68+
if (!res) throw new Error('검열 단어 삭제 도중 에러가 발생했습니다.');
7369
console.log(res);
7470
} catch (error) {
7571
console.error(error);

src/pages/Admin/Report.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function ReportManage() {
2828
reportType: null,
2929
status: 'PENDING',
3030
page: '1',
31-
size: '2',
31+
size: '1',
3232
});
3333

3434
const handleGetReports = async (reportQueryString: ReportQueryString) => {
@@ -47,14 +47,30 @@ export default function ReportManage() {
4747
setReportQueryString((cur) => ({ ...cur, page: page }));
4848
};
4949

50+
const handleStatus = (status: Status) => {
51+
setReportQueryString((cur) => ({ ...cur, status: status }));
52+
};
53+
5054
useEffect(() => {
5155
handleGetReports(reportQueryString);
5256
}, [reportQueryString]);
5357
return (
5458
<>
5559
<AdminPageTitle>검열 관리 / 신고 편지 목록</AdminPageTitle>
5660
<WrapperFrame>
57-
<WrapperTitle title="신고 편지 목록" Icon={AlarmIcon} />
61+
<div className="flex items-center justify-between">
62+
<WrapperTitle title="신고 편지 목록" Icon={AlarmIcon} />
63+
<select
64+
onChange={(e) => {
65+
const status = e.currentTarget.value as Status;
66+
handleStatus(status);
67+
}}
68+
>
69+
<option value="PENDING">대기중</option>
70+
<option value="RESOLVED">승인됨</option>
71+
<option value="REJECTED">거절됨</option>
72+
</select>
73+
</div>
5874

5975
<section className="mt-5 flex flex-col">
6076
<ListHeaderFrame>

src/pages/Admin/components/AddInputButton.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ export default function AddInputButton({
1919
target.style.width = `${target.scrollWidth}px`;
2020
};
2121

22-
const handlePostBadWords = () => {
22+
const handlePostBadWords = async () => {
2323
if (inputText.word === '') return setAddInputShow(false);
24-
postBadWords(inputText, () => {
24+
const res = await postBadWords(inputText);
25+
if (res?.status === 200) {
2526
setBadWords((cur) => [...cur, inputText]);
2627
setAddInputShow(false);
27-
});
28+
}
2829
};
2930

3031
useEffect(() => {

src/pages/Admin/components/PagenationNavigation.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ export default function PagenationNavigation({
5050
}
5151
};
5252

53-
const buttonStyle = 'rounded-full bg-white w-8 h-8 disabled:bg-gray-20';
53+
const buttonStyle =
54+
'rounded-full bg-white w-8 h-8 disabled:bg-gray-20 disabled:text-white disabled:cursor-auto';
5455

5556
return (
5657
<div className="mt-5 flex h-10 w-full items-center justify-center">

src/pages/Notifications/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,16 @@ const NotificationsPage = () => {
4848

4949
const handlePatchReadNotification = async (timelineId: number) => {
5050
const res = await patchReadNotification(timelineId);
51-
if (res?.status !== 200) {
51+
if (res?.status === 200) {
52+
setNoti((curNoti) =>
53+
curNoti.map((noti) => {
54+
if (noti.timelineId === timelineId) {
55+
return { ...noti, read: true };
56+
}
57+
return noti;
58+
}),
59+
);
60+
} else {
5261
console.log('읽음처리 에러 발생');
5362
}
5463
};

0 commit comments

Comments
 (0)