From b098436905716b2688a3f2ccbdb9bafb4d3e012c Mon Sep 17 00:00:00 2001 From: cjeongmin Date: Wed, 8 May 2024 15:39:30 +0900 Subject: [PATCH] feat: POST /shared/posts/dormitory/{postId}/scrap API (#75) --- src/features/shared/shared.api.ts | 7 ++++++- src/features/shared/shared.hook.ts | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/features/shared/shared.api.ts b/src/features/shared/shared.api.ts index 7629dfeef1..daa149eea0 100644 --- a/src/features/shared/shared.api.ts +++ b/src/features/shared/shared.api.ts @@ -114,7 +114,7 @@ export const deleteSharedPost = async (postId: number) => await axios.delete(`/maru-api/shared/posts/studio/${postId}`); export const scrapPost = async (postId: number) => - await axios.get( + await axios.post( `/maru-api/shared/posts/studio/${postId}/scrap`, ); @@ -152,3 +152,8 @@ export const deleteDormitorySharedPost = async (postId: number) => await axios.delete( `/maru-api/shared/posts/dormitory/${postId}`, ); + +export const scrapDormitoryPost = async (postId: number) => + await axios.post( + `/maru-api/shared/posts/dormitory/${postId}/scrap`, + ); diff --git a/src/features/shared/shared.hook.ts b/src/features/shared/shared.hook.ts index 5e9dffceac..aa8a26a089 100644 --- a/src/features/shared/shared.hook.ts +++ b/src/features/shared/shared.hook.ts @@ -10,6 +10,7 @@ import { getDormitorySharedPosts, getSharedPost, getSharedPosts, + scrapDormitoryPost, scrapPost, } from './shared.api'; import { @@ -435,3 +436,8 @@ export const useDeleteDormitorySharedPost = ({ onSuccess, onError, }); + +export const useScrapDormitorySharedPost = () => + useMutation, FailureDTO, number>({ + mutationFn: scrapDormitoryPost, + });