Skip to content

Commit 093a1c5

Browse files
feat: 아티클 수정 api axios, query 함수 작성
1 parent 23bd2df commit 093a1c5

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

apps/client/src/shared/apis/axios.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import apiRequest from '@shared/apis/setting/axiosInstance';
2+
import { EditArticleRequest } from '@shared/types/api';
23
import { formatLocalDateTime } from '@shared/utils/formatDateTime';
34

45
export const getDashboardCategories = async () => {
@@ -29,12 +30,22 @@ export const getAcorns = async () => {
2930
};
3031

3132
export interface postSignUpRequest {
32-
email: string,
33-
remindDefault: string,
34-
fcmToken: string
33+
email: string;
34+
remindDefault: string;
35+
fcmToken: string;
3536
}
3637

3738
export const postSignUp = async (responsedata: postSignUpRequest) => {
38-
const {data} = await apiRequest.post('/api/v1/auth/signup', responsedata);
39+
const { data } = await apiRequest.post('/api/v1/auth/signup', responsedata);
3940
return data;
40-
};
41+
};
42+
43+
export const putEditArticle = async (
44+
articleId: number,
45+
editArticleData: EditArticleRequest
46+
) => {
47+
const response = await apiRequest.put(`/api/v1/articles/${articleId}`, {
48+
editArticleData,
49+
});
50+
return response;
51+
};

apps/client/src/shared/apis/queries.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ import {
44
postCategory,
55
postSignUp,
66
postSignUpRequest,
7+
putEditArticle,
78
putCategory,
89
} from '@shared/apis/axios';
910
import { AxiosError } from 'axios';
10-
import { DashboardCategoriesResponse, AcornsResponse } from '@shared/types/api';
11+
import {
12+
DashboardCategoriesResponse,
13+
AcornsResponse,
14+
EditArticleRequest,
15+
} from '@shared/types/api';
1116
import { getAcorns } from './axios';
1217

1318
export const useGetDashboardCategories = (): UseQueryResult<
@@ -56,3 +61,15 @@ export const usePostSignUp = () => {
5661
},
5762
});
5863
};
64+
65+
export const usePutEditArticle = () => {
66+
return useMutation({
67+
mutationFn: ({
68+
articleId,
69+
editArticleData,
70+
}: {
71+
articleId: number;
72+
editArticleData: EditArticleRequest;
73+
}) => putEditArticle(articleId, editArticleData),
74+
});
75+
};

apps/client/src/shared/types/api.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@ export type AcornsResponse = {
1212
acornCount: number;
1313
remindDateTime: string;
1414
};
15+
16+
export interface EditArticleRequest {
17+
categoryId: number;
18+
memo: string;
19+
now: string;
20+
remindTime: string;
21+
}

0 commit comments

Comments
 (0)