Skip to content

Commit

Permalink
fix: put에 articleid 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
airman5573 committed Aug 18, 2022
1 parent f0f4f18 commit d45065f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 5 additions & 4 deletions frontend/src/api/community/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export type PostCommunityArticleResponseData = {

export type PutCommunityArticleRequestParams = {
studyId: number;
articleId: number;
};
export type PutCommunityArticleRequestBody = {
title: string;
Expand Down Expand Up @@ -90,9 +91,9 @@ const postCommunityArticle = async ({ studyId, title, content }: PostCommunityAr
return response.data;
};

const putCommunityArticle = async ({ studyId, title, content }: PutCommunityArticleRequestVariables) => {
const response = await axiosInstance.put<null, AxiosResponse<null>, PostCommunityArticleRequestBody>(
`/api/studies/${studyId}/community/articles`,
const putCommunityArticle = async ({ studyId, title, content, articleId }: PutCommunityArticleRequestVariables) => {
const response = await axiosInstance.put<null, AxiosResponse<null>, PutCommunityArticleRequestBody>(
`/api/studies/${studyId}/community/articles/${articleId}`,
{
title,
content,
Expand Down Expand Up @@ -123,7 +124,7 @@ export const usePostCommunityArticle = () => {
};

export const usePutCommunityArticle = () => {
return useMutation<null, AxiosError, PostCommunityArticleRequestVariables>(putCommunityArticle);
return useMutation<null, AxiosError, PutCommunityArticleRequestVariables>(putCommunityArticle);
};

export const useDeleteCommunityArticle = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ const Edit = () => {
const { title, content } = values;

const numStudyId = Number(studyId);
const numArticleId = Number(articleId);
mutateAsync(
{
studyId: numStudyId,
articleId: numArticleId,
title,
content,
},
Expand Down

0 comments on commit d45065f

Please sign in to comment.