Skip to content

Commit

Permalink
feat/#416 : 관리자 글감 관련 400 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
moondda committed Aug 21, 2024
1 parent 28eaa40 commit f7dfb64
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/pages/admin/hooks/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ export const usePostAdminTopic = (groupId: string | undefined, pageNum: number)
queryKey: ['adminTopic', groupId, pageNum],
});
},
onError: (err) => {
if (isAxiosError(err) && err.response?.status) {
const errorCode = err.response?.data.status;
if (errorCode === 40005) {
alert('요청 값에 빈 값이 존재합니다');
} else if (errorCode === 40006) {
alert('요청 값이 길이를 초과했습니다');
} else {
console.error();
}
}
},
});

const postMutateAdminTopic = ({ topic, topicTag, topicDescription }: postAdminTopicPropTypes) =>
Expand Down Expand Up @@ -122,6 +134,18 @@ export const useEditAdminTopic = (
queryKey: ['adminTopic', groupId, pageNum],
});
},
onError: (err) => {
if (isAxiosError(err) && err.response?.status) {
const errorCode = err.response?.data.status;
if (errorCode === 40005) {
alert('요청 값에 빈 값이 존재합니다');
} else if (errorCode === 40006) {
alert('요청 값이 길이를 초과했습니다');
} else {
console.error();
}
}
},
});

const editMutateAdminTopic = ({ topic, topicTag, topicDescription }: editTopicPropType) =>
Expand All @@ -145,6 +169,16 @@ export const useDeleteAdminTopic = (
queryKey: ['adminTopic', groupId, pageNum],
});
},
onError: (err) => {
if (isAxiosError(err) && err.response?.status) {
const errorCode = err.response?.data.status;
if (errorCode === 40015) {
alert('모임에 최소 하나의 글감이 있어야 합니다');
} else {
console.error();
}
}
},
});

const deleteMutateAdminTopic = () => {
Expand Down

0 comments on commit f7dfb64

Please sign in to comment.