-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat : 공지사항 수정, 작성 비속어 처리 * feat : 공지사항 5번째 줄 부터 ellipsis 처리 * refactor : 모달 close기능 훅의 onSuccess로 옮김
- Loading branch information
Showing
5 changed files
with
58 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,36 @@ | ||
import postClubNotice from '@/apis/club/postClubNotice'; | ||
import useTextException from '@/hooks/useTextException'; | ||
import useToast from '@/hooks/useToast'; | ||
import { HttpException } from '@/types/common'; | ||
|
||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
|
||
import { AxiosError } from 'axios'; | ||
|
||
import { QUERY_KEY } from './useGetClubNoticeQuery'; | ||
|
||
const usePostNoticeMutation = () => { | ||
interface usePostNoticeMutationProps { | ||
handleSuccess?: () => void; | ||
} | ||
|
||
const usePostNoticeMutation = ({ handleSuccess }: usePostNoticeMutationProps) => { | ||
const queryClient = useQueryClient(); | ||
const { createToast } = useToast(); | ||
const { handleTextException } = useTextException(); | ||
|
||
const { mutate: postNotice } = useMutation({ | ||
const { mutate: postNotice, isSuccess: postSuccess } = useMutation({ | ||
mutationFn: postClubNotice, | ||
onSuccess: () => { | ||
queryClient.invalidateQueries([QUERY_KEY.CLUB_NOTICE]); | ||
handleSuccess?.(); | ||
}, | ||
onError: (error: AxiosError<HttpException>) => { | ||
handleTextException(error); | ||
createToast({ message: '공지사항 작성에 실패했습니다.', toastType: 'error' }); | ||
}, | ||
}); | ||
|
||
return { postNotice }; | ||
return { postNotice, postSuccess }; | ||
}; | ||
|
||
export default usePostNoticeMutation; |