File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed
features/rolling-paper/api Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff 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 } ;
Original file line number Diff line number Diff line change @@ -10,7 +10,10 @@ import {
1010 getNextPageMessages ,
1111} from "../features/message/api/messages" ;
1212import 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" ;
1417import RollingPaperHeader from "../features/rolling-paper/components/header/rolling-paper-header" ;
1518import { useMedia } from "../hooks/use-media" ;
1619import 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 = ( ) => {
You can’t perform that action at this time.
0 commit comments