Skip to content

Commit abf5300

Browse files
committed
feat [#52] 롤링페이퍼 삭제 구현 (/list로 이동)
1 parent ca14967 commit abf5300

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/features/rolling-paper/api/recipients.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,11 @@ async function getRecipient({ id }) {
99
return response.data;
1010
}
1111

12-
export { getRecipient };
12+
async function deleteRecipient({ id }) {
13+
const response = await apiClient.delete(`recipients/${id}/`);
14+
if (response.status !== 204) {
15+
throw new Error("Recipient를 삭제하는데 실패했습니다.");
16+
}
17+
}
18+
19+
export { deleteRecipient, getRecipient };

src/pages/messages-page.jsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import {
1010
getNextPageMessages,
1111
} from "../features/message/api/messages";
1212
import MessagesGrid from "../features/message/components/messages-grid";
13-
import { getRecipient } from "../features/rolling-paper/api/recipients";
13+
import {
14+
deleteRecipient,
15+
getRecipient,
16+
} from "../features/rolling-paper/api/recipients";
1417
import RollingPaperHeader from "../features/rolling-paper/components/header/rolling-paper-header";
1518
import { useMedia } from "../hooks/use-media";
1619
import ContentLayout from "../layouts/content-layout";
@@ -102,10 +105,14 @@ function MessagesPage() {
102105
navigate("edit");
103106
};
104107

105-
const handleRollingPaperDelete = () => {
106-
// TODO: Rolling Paper 삭제
107-
console.log(`Delete Rolling Paper ${recipient.id}`);
108-
navigate(-1);
108+
const handleRollingPaperDelete = async () => {
109+
try {
110+
await deleteRecipient({ id: recipient.id });
111+
navigate(`/list`);
112+
} catch (error) {
113+
// TODO: Error 처리
114+
console.log(error);
115+
}
109116
};
110117

111118
const handleEditCancel = () => {

0 commit comments

Comments
 (0)