1- import {
2- API_URLS ,
3- getApiUrl ,
4- getAuthHeaders ,
5- handleFetchResponse ,
6- } from "./config" ;
1+ import { API_URLS , apiClient } from "./config" ;
72import type {
83 RecruitmentItemType ,
94 SubmitApplicationRequest ,
@@ -43,22 +38,11 @@ export type ApplicationDetailResponse = {
4338export const getApplicationDetail = async (
4439 applicationId : number
4540) : Promise < ApplicationDetailResponse > => {
46- const headers = getAuthHeaders ( ) ;
47-
48- const response = await fetch (
49- getApiUrl (
50- API_URLS . APPLICATION_DETAIL . replace (
51- ":applicationId" ,
52- String ( applicationId )
53- )
54- ) ,
55- {
56- method : "GET" ,
57- headers,
58- }
41+ const { data } = await apiClient . get (
42+ API_URLS . APPLICATION_DETAIL . replace ( ":applicationId" , String ( applicationId ) )
5943 ) ;
6044
61- return handleFetchResponse < ApplicationDetailResponse > ( response ) ;
45+ return data as ApplicationDetailResponse ;
6246} ;
6347
6448export type UpdateApplicationRequest = SubmitApplicationRequest ;
@@ -75,23 +59,15 @@ export const updateApplication = async (
7559 applicationId : number ,
7660 payload : UpdateApplicationRequest
7761) : Promise < UpdateApplicationResponse > => {
78- const headers = getAuthHeaders ( ) ;
79-
80- const response = await fetch (
81- getApiUrl (
82- API_URLS . APPLICATION_DETAIL . replace (
83- ":applicationId" ,
84- String ( applicationId )
85- )
62+ const { data } = await apiClient . patch (
63+ API_URLS . APPLICATION_DETAIL . replace (
64+ ":applicationId" ,
65+ String ( applicationId )
8666 ) ,
87- {
88- method : "PATCH" ,
89- headers,
90- body : JSON . stringify ( payload ) ,
91- }
67+ payload
9268 ) ;
9369
94- return handleFetchResponse < UpdateApplicationResponse > ( response ) ;
70+ return data as UpdateApplicationResponse ;
9571} ;
9672
9773export type ApplicationAdminAnswer = {
@@ -139,22 +115,14 @@ export type ApplicationAdminDetailResponse = {
139115export const getApplicationAdminDetail = async (
140116 applicationId : number
141117) : Promise < ApplicationAdminDetailResponse > => {
142- const headers = getAuthHeaders ( ) ;
143-
144- const response = await fetch (
145- getApiUrl (
146- API_URLS . APPLICATION_ADMIN_DETAIL . replace (
147- ":applicationId" ,
148- String ( applicationId )
149- )
150- ) ,
151- {
152- method : "GET" ,
153- headers,
154- }
118+ const { data } = await apiClient . get (
119+ API_URLS . APPLICATION_ADMIN_DETAIL . replace (
120+ ":applicationId" ,
121+ String ( applicationId )
122+ )
155123 ) ;
156124
157- return handleFetchResponse < ApplicationAdminDetailResponse > ( response ) ;
125+ return data as ApplicationAdminDetailResponse ;
158126} ;
159127
160128export type UpdateInterviewScheduleRequest = {
@@ -176,23 +144,34 @@ export const updateInterviewSchedule = async (
176144 applicationId : number ,
177145 payload : UpdateInterviewScheduleRequest
178146) : Promise < UpdateInterviewScheduleResponse > => {
179- const headers = getAuthHeaders ( ) ;
180-
181- const response = await fetch (
182- getApiUrl (
183- API_URLS . APPLICATION_INTERVIEW_SCHEDULE . replace (
184- ":applicationId" ,
185- String ( applicationId )
186- )
147+ const { data } = await apiClient . patch (
148+ API_URLS . APPLICATION_INTERVIEW_SCHEDULE . replace (
149+ ":applicationId" ,
150+ String ( applicationId )
187151 ) ,
188- {
189- method : "PATCH" ,
190- headers,
191- body : JSON . stringify ( payload ) ,
192- }
152+ payload
193153 ) ;
194154
195- return handleFetchResponse < UpdateInterviewScheduleResponse > ( response ) ;
155+ return data as UpdateInterviewScheduleResponse ;
156+ } ;
157+
158+ export type UpdateDocumentDecisionRequest = {
159+ decision : "INTERVIEW" | "FAILED" ;
160+ } ;
161+
162+ export const updateDocumentDecision = async (
163+ applicationId : number ,
164+ payload : UpdateDocumentDecisionRequest
165+ ) : Promise < MessageResponse > => {
166+ const { data } = await apiClient . patch (
167+ API_URLS . APPLICATION_DOCUMENT_DECISION . replace (
168+ ":applicationId" ,
169+ String ( applicationId )
170+ ) ,
171+ payload
172+ ) ;
173+
174+ return data as MessageResponse ;
196175} ;
197176
198177export type ApplicationComment = {
@@ -213,22 +192,14 @@ export type GetApplicationCommentsResponse = {
213192export const getApplicationComments = async (
214193 applicationId : number
215194) : Promise < GetApplicationCommentsResponse > => {
216- const headers = getAuthHeaders ( ) ;
217-
218- const response = await fetch (
219- getApiUrl (
220- API_URLS . APPLICATION_COMMENTS . replace (
221- ":applicationId" ,
222- String ( applicationId )
223- )
224- ) ,
225- {
226- method : "GET" ,
227- headers,
228- }
195+ const { data } = await apiClient . get (
196+ API_URLS . APPLICATION_COMMENTS . replace (
197+ ":applicationId" ,
198+ String ( applicationId )
199+ )
229200 ) ;
230201
231- return handleFetchResponse < GetApplicationCommentsResponse > ( response ) ;
202+ return data as GetApplicationCommentsResponse ;
232203} ;
233204
234205export type CreateApplicationCommentRequest = {
@@ -245,23 +216,15 @@ export const createApplicationComment = async (
245216 applicationId : number ,
246217 payload : CreateApplicationCommentRequest
247218) : Promise < MessageResponse > => {
248- const headers = getAuthHeaders ( ) ;
249-
250- const response = await fetch (
251- getApiUrl (
252- API_URLS . APPLICATION_COMMENTS . replace (
253- ":applicationId" ,
254- String ( applicationId )
255- )
219+ const { data } = await apiClient . post (
220+ API_URLS . APPLICATION_COMMENTS . replace (
221+ ":applicationId" ,
222+ String ( applicationId )
256223 ) ,
257- {
258- method : "POST" ,
259- headers,
260- body : JSON . stringify ( payload ) ,
261- }
224+ payload
262225 ) ;
263226
264- return handleFetchResponse < MessageResponse > ( response ) ;
227+ return data as MessageResponse ;
265228} ;
266229
267230export type UpdateApplicationCommentRequest = {
@@ -273,43 +236,114 @@ export const updateApplicationComment = async (
273236 commentId : number ,
274237 payload : UpdateApplicationCommentRequest
275238) : Promise < MessageResponse > => {
276- const headers = getAuthHeaders ( ) ;
277-
278- const response = await fetch (
279- getApiUrl (
280- `${ API_URLS . APPLICATION_COMMENTS . replace (
281- ":applicationId" ,
282- String ( applicationId )
283- ) } /${ commentId } `
284- ) ,
285- {
286- method : "PATCH" ,
287- headers,
288- body : JSON . stringify ( payload ) ,
289- }
239+ const { data } = await apiClient . patch (
240+ `${ API_URLS . APPLICATION_COMMENTS . replace (
241+ ":applicationId" ,
242+ String ( applicationId )
243+ ) } /${ commentId } `,
244+ payload
290245 ) ;
291246
292- return handleFetchResponse < MessageResponse > ( response ) ;
247+ return data as MessageResponse ;
293248} ;
294249
295250export const deleteApplicationComment = async (
296251 applicationId : number ,
297252 commentId : number
298253) : Promise < MessageResponse > => {
299- const headers = getAuthHeaders ( ) ;
300-
301- const response = await fetch (
302- getApiUrl (
303- `${ API_URLS . APPLICATION_COMMENTS . replace (
304- ":applicationId" ,
305- String ( applicationId )
306- ) } /${ commentId } `
254+ const { data } = await apiClient . delete (
255+ `${ API_URLS . APPLICATION_COMMENTS . replace (
256+ ":applicationId" ,
257+ String ( applicationId )
258+ ) } /${ commentId } `
259+ ) ;
260+
261+ return data as MessageResponse ;
262+ } ;
263+
264+ export type InterviewDecisionRequest = {
265+ status : "PASSED" | "FAILED" ;
266+ } ;
267+
268+ export const updateInterviewDecision = async (
269+ applicationId : number ,
270+ payload : InterviewDecisionRequest
271+ ) : Promise < MessageResponse > => {
272+ const { data } = await apiClient . patch (
273+ API_URLS . APPLICATION_INTERVIEW_DECISION . replace (
274+ ":applicationId" ,
275+ String ( applicationId )
276+ ) ,
277+ payload
278+ ) ;
279+ return data as MessageResponse ;
280+ } ;
281+
282+ export type ApplicationEvaluation = {
283+ evaluationId : number ;
284+ councilManagerId : number ;
285+ councilManagerName : string ;
286+ evaluation : string ;
287+ createdAt : string ;
288+ updatedAt ?: string ;
289+ } ;
290+
291+ export type GetApplicationEvaluationsResponse = {
292+ code : number ;
293+ message : string ;
294+ data : ApplicationEvaluation [ ] ;
295+ } ;
296+
297+ export const getApplicationEvaluations = async (
298+ applicationId : number
299+ ) : Promise < GetApplicationEvaluationsResponse > => {
300+ const { data } = await apiClient . get (
301+ API_URLS . APPLICATION_EVALUATIONS . replace (
302+ ":applicationId" ,
303+ String ( applicationId )
304+ )
305+ ) ;
306+ return data as GetApplicationEvaluationsResponse ;
307+ } ;
308+
309+ export const createApplicationEvaluation = async (
310+ applicationId : number ,
311+ payload : { evaluation : string }
312+ ) : Promise < MessageResponse > => {
313+ const { data } = await apiClient . post (
314+ API_URLS . APPLICATION_EVALUATIONS . replace (
315+ ":applicationId" ,
316+ String ( applicationId )
307317 ) ,
308- {
309- method : "DELETE" ,
310- headers,
311- }
318+ payload
319+ ) ;
320+ return data as MessageResponse ;
321+ } ;
322+
323+ export const updateApplicationEvaluation = async (
324+ applicationId : number ,
325+ evaluationId : number ,
326+ payload : { evaluation : string }
327+ ) : Promise < MessageResponse > => {
328+ const { data } = await apiClient . patch (
329+ `${ API_URLS . APPLICATION_EVALUATIONS . replace (
330+ ":applicationId" ,
331+ String ( applicationId )
332+ ) } /${ evaluationId } `,
333+ payload
312334 ) ;
335+ return data as MessageResponse ;
336+ } ;
313337
314- return handleFetchResponse < MessageResponse > ( response ) ;
338+ export const deleteApplicationEvaluation = async (
339+ applicationId : number ,
340+ evaluationId : number
341+ ) : Promise < MessageResponse > => {
342+ const { data } = await apiClient . delete (
343+ `${ API_URLS . APPLICATION_EVALUATIONS . replace (
344+ ":applicationId" ,
345+ String ( applicationId )
346+ ) } /${ evaluationId } `
347+ ) ;
348+ return data as MessageResponse ;
315349} ;
0 commit comments