diff --git a/src/hooks/api/useDocument.ts b/src/hooks/api/useDocument.ts new file mode 100644 index 00000000..5859e9b7 --- /dev/null +++ b/src/hooks/api/useDocument.ts @@ -0,0 +1,20 @@ +import { postPartTimeEmployPermit } from '@/api/document'; +import { DocumentType } from '@/types/api/document'; +import { useMutation } from '@tanstack/react-query'; +import { useNavigate } from 'react-router-dom'; + +export const usePostPartTimeEmployPermit = () => { + const navigate = useNavigate(); + return useMutation({ + mutationFn: postPartTimeEmployPermit, + onSuccess: () => { + navigate('/'); + }, + onError: () => + navigate('/write-documents', { + state: { + type: DocumentType.PART_TIME_PERMIT, + }, + }), + }); +};