Skip to content

Commit

Permalink
✨feat: 지원 상태 api 정의하기 #61
Browse files Browse the repository at this point in the history
  • Loading branch information
naarang committed Oct 28, 2024
1 parent 850d09a commit 868cc43
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 6 deletions.
66 changes: 64 additions & 2 deletions src/api/application.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
import { PatchResumeAcceptedRequest } from '@/types/api/application';
import {
PatchHiKoreaResultRequest,
PatchResumeAcceptedRequest,
} from '@/types/api/application';
import { api } from '.';

// 4.8 (유학생) 공고 지원 자격 확인하기
export const getPostValidation = async (id: number) => {
const response = await api.get(`/api/v1/users/job-postings/${id}/validation`);
const response = await api.get(`/users/job-postings/${id}/validation`);
return response.data;
};

// 4.9 (유학생) 공고 지원하기
export const postApplyPost = async (id: number) => {
const response = await api.post(`/users/job-postings/${id}`);
return response.data;
};

// 6.2 (유학생) 지원 상태 상세 조회하기
export const getApplicationDetail = async (id: number) => {
const response = await api.get(
`/users/user-owner-job-postings/${id}/details`,
);
return response.data;
};

// 6.5 (유학생) 공고 담당자 정보 조회하기
export const getRecruiterInfo = async (id: number) => {
const response = await api.get(
`/users/user-owner-job-postings/${id}/job-postings/recruiters`,
);
return response.data;
};

Expand Down Expand Up @@ -45,3 +70,40 @@ export const patchInterviewFinish = async (id: number) => {
);
return response.data;
};

// 6.13 (유학생) 유학생 담당자 검토 완료
export const patchContactCoordinator = async (id: number) => {
const response = await api.patch(
`/users/user-owner-job-postings/${id}/step-document-under-review`,
);
return response.data;
};

// 6.14 (유학생) 하이코리아 지원
export const patchApplyHiKorea = async (id: number) => {
const response = await api.patch(
`/users/user-owner-job-postings/${id}/step-application-in-progress`,
);
return response.data;
};

// 6.15 (유학생) 하이코리아 처리결과 등록하기
export const patchHiKoreaResult = async ({
id,
body,
}: {
id: number;
body: PatchHiKoreaResultRequest;
}) => {
const response = await api.patch(
`/users/user-owner-job-postings/${id}/step-registering-results`,
body,
);
return response.data;
};

// 9.2 (유학생) 학교 정보 상세조회하기
export const getSchoolInfo = async () => {
const response = await api.get(`/users/resumes/schools/details`);
return response.data;
};
16 changes: 15 additions & 1 deletion src/api/post.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AscendingSortType } from '@/types/common/sort';
import { api } from '.';
import { GetPostListReqType } from '@/types/api/post';
import { GetApplyPostListReqType, GetPostListReqType } from '@/types/api/post';
import { APPLICATION_STATUS_TYPE } from '@/constants/application';

// 4.2 (게스트) 공고 상세 조회하기
export const getPostDetailGuest = async (id: number) => {
Expand Down Expand Up @@ -69,6 +70,19 @@ export const getBookmarkPostList = async (page: number, size: number) => {
return response.data;
};

// 6.1 (유학생) 지원한 공고 리스트 조회하기
export const getApplyPostList = async ({
page,
size,
sorting,
status,
}: GetApplyPostListReqType) => {
const response = await api.get(
`/users/user-owner-job-postings/overviews?page=${page}&size=${size}&sorting=${sorting}&${status === APPLICATION_STATUS_TYPE.TOTAL ? '' : `status=${status}`}`,
);
return response.data;
};

// 6.3 (유학생) 현재 진행중인 인터뷰 리스트 조회하기
export const getInterviewList = async (page: number, size: number) => {
const response = await api.get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const EmployerApplicationList = ({
KO_ASCENDING_SORT_TYPE.ASCENDING,
);
const [selectedStatus, setSelectedStatus] = useState<KoApplicationStatusType>(
KO_APPLICATION_STATUS_TYPE.INPROGRESS,
KO_APPLICATION_STATUS_TYPE.TOTAL,
);

useEffect(() => {
Expand Down
2 changes: 2 additions & 0 deletions src/constants/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const enum APPLICATION_STEP {
}

export const APPLICATION_STATUS_TYPE = {
TOTAL: 'Total',
INPROGRESS: 'Inprogress',
APPLICATION_SUCCESSFUL: 'Applicatioin successful',
APPLICATION_REJECTED: 'Applicatioin rejected',
Expand All @@ -26,6 +27,7 @@ export const APPLICATION_STATUS_TYPE = {
} as const;

export const KO_APPLICATION_STATUS_TYPE = {
TOTAL: '전체',
INPROGRESS: '진행중',
APPLICATION_SUCCESSFUL: '계약 성공',
APPLICATION_REJECTED: '시간제취업허가 실패',
Expand Down
80 changes: 80 additions & 0 deletions src/hooks/api/useApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import {
patchInterviewFinish,
patchResumeAccepted,
getPostValidation,
postApplyPost,
getApplicationDetail,
getRecruiterInfo,
getSchoolInfo,
patchContactCoordinator,
patchApplyHiKorea,
patchHiKoreaResult,
} from '@/api/application';
import { useMutation, useQuery } from '@tanstack/react-query';
import { useNavigate } from 'react-router-dom';
Expand All @@ -16,6 +23,32 @@ export const useGetPostValidation = (id: number) => {
});
};

// 4.9 (유학생) 공고 지원하기 훅
export const usePostApplyPost = () => {
return useMutation({
mutationFn: postApplyPost,
onError: (error) => {
console.error('공고 지원하기 실패', error);
},
});
};

// 6.2 (유학생) 지원 상태 상세 조회하기 훅
export const useGetApplicationDetail = (id: number) => {
return useQuery({
queryKey: ['application', id],
queryFn: () => getApplicationDetail(id),
});
};

// 6.5 (유학생) 공고 담당자 정보 조회하기 훅
export const useGetRecruiterInfo = (id: number) => {
return useQuery({
queryKey: ['application', id],
queryFn: () => getRecruiterInfo(id),
});
};

// 6.7 (고용주) 지원자 지원 상태 상세 조회 훅
export const useGetEmployerApplicationDetail = (id: number) => {
return useQuery({
Expand Down Expand Up @@ -58,3 +91,50 @@ export const usePatchInterviewFinish = () => {
},
});
};

// 6.13 (유학생) 유학생 담당자 검토 완료 훅
export const usePatchContactCoordinator = () => {
return useMutation({
mutationFn: patchContactCoordinator,
onSuccess: () => {
window.location.reload();
},
onError: (error) => {
console.error('유학생 담당자 검토 완료 실패', error);
},
});
};

// 6.14 (유학생) 하이코리아 지원 훅
export const usePatchApplyHiKorea = () => {
return useMutation({
mutationFn: patchApplyHiKorea,
onSuccess: () => {
window.location.reload();
},
onError: (error) => {
console.error('하이코리아 지원 실패', error);
},
});
};

// 6.15 (유학생) 하이코리아 처리결과 등록하기 훅
export const usePatchHiKoreaResult = () => {
return useMutation({
mutationFn: patchHiKoreaResult,
onSuccess: () => {
window.location.reload();
},
onError: (error) => {
console.error('하이코리아 처리결과 등록 실패', error);
},
});
};

// 9.2 (유학생) 학교 정보 상세조회하기 훅
export const useGetSchoolInfo = () => {
return useQuery({
queryKey: ['application'],
queryFn: () => getSchoolInfo(),
});
};
16 changes: 15 additions & 1 deletion src/hooks/api/usePost.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
deletePost,
getApplicantList,
getApplyPostList,
getBookmarkPostList,
getEmployerPostList,
getInterviewList,
Expand All @@ -11,7 +12,7 @@ import {
getRecommendPostList,
putPostBookmark,
} from '@/api/post';
import { GetPostListReqType } from '@/types/api/post';
import { GetApplyPostListReqType, GetPostListReqType } from '@/types/api/post';
import { AscendingSortType } from '@/types/common/sort';
import { useMutation, useQuery } from '@tanstack/react-query';
import { useNavigate } from 'react-router-dom';
Expand Down Expand Up @@ -95,6 +96,19 @@ export const useGetBookmarkPostList = (page: number, size: number) => {
});
};

// 6.1 (유학생) 지원한 공고 리스트 조회하기 훅
export const useGetApplyPostList = ({
page,
size,
sorting,
status,
}: GetApplyPostListReqType) => {
return useQuery({
queryKey: ['post'],
queryFn: () => getApplyPostList({ page, size, sorting, status }),
});
};

// 6.3 (유학생) 현재 진행중인 인터뷰 리스트 조회하기 훅
export const useGetInterviewList = (page: number, size: number) => {
return useQuery({
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Application/ApplicationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const ApplicationPage = () => {
ASCENDING_SORT_TYPE.ASCENDING,
);
const [selectedStatus, setSelectedStatus] = useState<ApplicationStatusType>(
APPLICATION_STATUS_TYPE.INPROGRESS,
APPLICATION_STATUS_TYPE.TOTAL,
);

return (
Expand Down
5 changes: 5 additions & 0 deletions src/types/api/application.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export type PatchResumeAcceptedRequest = {
is_accepted: boolean;
};

export type PatchHiKoreaResultRequest = {
is_approval: boolean;
feedback: string;
};
9 changes: 9 additions & 0 deletions src/types/api/post.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { POST_SEARCH_MENU } from '@/constants/postSearch';
import { ApplicationStatusType } from '../application/applicationStatus';
import { AscendingSortType } from '../common/sort';

export type GetPostListReqType = {
page: number;
Expand All @@ -18,3 +20,10 @@ export type GetPostListReqType = {
visa: string | null;
type: POST_SEARCH_MENU | null;
};

export type GetApplyPostListReqType = {
page: number;
size: number;
sorting: AscendingSortType;
status: ApplicationStatusType;
};

0 comments on commit 868cc43

Please sign in to comment.