Total Complexity | 1 |
Complexity/F | 0 |
Lines of Code | 40 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /* eslint-disable @typescript-eslint/camelcase */ |
||
2 | import { baseUrl, ApiResponse, parseDateStrict, axios } from "./base"; |
||
3 | import { AssessmentPlanNotification } from "../models/types"; |
||
4 | |||
5 | export const parseAssessmentPlanNotification = ( |
||
6 | data: any, |
||
7 | ): AssessmentPlanNotification => ({ |
||
8 | ...data, |
||
9 | created_at: parseDateStrict(data.created_at), |
||
10 | }); |
||
11 | |||
12 | export const getAssessmentPlanNotificationsByJob = ( |
||
13 | jobId: number, |
||
14 | ): Promise<AssessmentPlanNotification[]> => { |
||
15 | return axios |
||
16 | .get(`${baseUrl()}/assessment-plan-notifications?job_poster_id=${jobId}`) |
||
17 | .then((response: ApiResponse): AssessmentPlanNotification[] => { |
||
18 | if (!Array.isArray(response.data)) { |
||
19 | throw Error("Response must be an array."); |
||
20 | } |
||
21 | return response.data.map(parseAssessmentPlanNotification); |
||
22 | }); |
||
23 | }; |
||
24 | |||
25 | export const updateAssessmentPlanNotification = ( |
||
26 | notification: AssessmentPlanNotification, |
||
27 | ): Promise<AssessmentPlanNotification> => { |
||
28 | return axios |
||
29 | .put( |
||
30 | `${baseUrl()}/assessment-plan-notifications/${notification.id}`, |
||
31 | notification, |
||
32 | ) |
||
33 | .then( |
||
34 | (response: ApiResponse): AssessmentPlanNotification => |
||
35 | parseAssessmentPlanNotification( |
||
36 | response.data.assessment_plan_notification, |
||
37 | ), |
||
38 | ); |
||
39 | }; |
||
40 |