Skip to content

Commit

Permalink
✨ feat: 문서별 수정 api 통신 함수, 훅 작성 #54
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMirror21 committed Oct 26, 2024
1 parent 4aee802 commit d8a95d7
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 2 deletions.
50 changes: 48 additions & 2 deletions src/api/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
SearchSchoolResponse,
} from '@/types/api/document';
import { api } from '.';
import { PartTimePermitFormRequest } from '../types/api/document';

//시간제 취업허가서 작성 api 통신 함수
export const postPartTimeEmployPermit = async ({
Expand All @@ -21,7 +22,22 @@ export const postPartTimeEmployPermit = async ({
return response.data;
};

//표준 근로계약서 작성 api 통신 함수
// 8.10 (유학생) 시간제 취업허가서 수정하기
export const putPartTimeEmployPermit = async ({
id,
document,
}: {
id: number;
document: PartTimePermitFormRequest;
}): Promise<{ success: boolean }> => {
const response = await api.put(
`/users/documents/${id}/part-time-employment-permits`,
document,
);
return response.data;
};

// 8.6 표준 근로계약서 작성 api 통신 함수
export const postStandardLaborContracts = async ({
id,
document,
Expand All @@ -36,7 +52,22 @@ export const postStandardLaborContracts = async ({
return response.data;
};

// 8.8 표준 근로계약서 작성 api 통신 함수
// 8.12 (유학생) 근로계약서 수정하기
export const putStandardLaborContracts = async ({
id,
document,
}: {
id: number;
document: LaborContractEmployeeInfo;
}): Promise<{ success: boolean }> => {
const response = await api.put(
`/users/documents/${id}/standard-labor-contracts`,
document,
);
return response.data;
};

// 8.8 통합신청서 작성 api 통신 함수
export const postIntegratedApplications = async ({
id,
document,
Expand All @@ -51,6 +82,21 @@ export const postIntegratedApplications = async ({
return response.data;
};

// 8.14 통합신청서 수정 api 통신 함수
export const putIntegratedApplications = async ({
id,
document,
}: {
id: number;
document: IntegratedApplicationData;
}): Promise<{ success: boolean }> => {
const response = await api.post(
`/users/documents/${id}/integrated-applications`,
document,
);
return response.data;
};

// 9.1 (유학생)학교명 검색 api 통신 함수
export const searchSchool = async (
name: string,
Expand Down
54 changes: 54 additions & 0 deletions src/hooks/api/useDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import {
postIntegratedApplications,
postPartTimeEmployPermit,
postStandardLaborContracts,
putIntegratedApplications,
putPartTimeEmployPermit,
putStandardLaborContracts,
searchSchool,
} from '@/api/document';
import { DocumentType, SearchSchoolResponse } from '@/types/api/document';
Expand All @@ -25,6 +28,23 @@ export const usePostPartTimeEmployPermit = () => {
});
};

// 8.10 (유학생)시간제취업허가서 수정 api 통신 커스텀 훅
export const usePutPartTimeEmployPermit = () => {
const navigate = useNavigate();
return useMutation({
mutationFn: putPartTimeEmployPermit,
onSuccess: () => {
navigate('/');
},
onError: () =>
navigate('/write-documents', {
state: {
type: DocumentType.PART_TIME_PERMIT,
},
}),
});
};

//표준 근로계약서 작성 api 통신 커스텀 훅
export const usePostStandardLaborContracts = () => {
const navigate = useNavigate();
Expand All @@ -42,6 +62,23 @@ export const usePostStandardLaborContracts = () => {
});
};

// 8.12 (유학생) 표준 근로계약서 수정 api 통신 커스텀 훅
export const usePutStandardLaborContracts = () => {
const navigate = useNavigate();
return useMutation({
mutationFn: putStandardLaborContracts,
onSuccess: () => {
navigate('/');
},
onError: () =>
navigate('/write-documents', {
state: {
type: DocumentType.LABOR_CONTRACT,
},
}),
});
};

// 8.8 통합신청서 생성 api 통신 커스텀 훅
export const usePostIntegratedApplicants = () => {
const navigate = useNavigate();
Expand All @@ -59,6 +96,23 @@ export const usePostIntegratedApplicants = () => {
});
};

// 8.14 (유학생) 통합신청서 수정 api 통신 커스텀 훅
export const usePutIntegratedApplicants = () => {
const navigate = useNavigate();
return useMutation({
mutationFn: putIntegratedApplications,
onSuccess: () => {
navigate('/');
},
onError: () =>
navigate('/write-documents', {
state: {
type: DocumentType.INTEGRATED_APPLICATION,
},
}),
});
};

// 9.1 (유학생) 학교 검색하기 api 통신 커스텀 훅
export const useSearchSchool = ({
onSuccess,
Expand Down

0 comments on commit d8a95d7

Please sign in to comment.