import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { ITimeOffPolicy , ITimeOffPolicyCreateInput , ITimeOffPolicyFindInput , ITimeOffPolicyUpdateInput , ITimeOffCreateInput , ITimeOff , ITimeOffFindInput , IPagination } from '@gauzy/contracts' ; import { Observable } from 'rxjs' ; import { API_PREFIX } from '../constants/app.constants' ; @ Injectable ( { providedIn : 'root' } ) export class TimeOffService { constructor ( private http ) { } createPolicy ( createInput ) { return this . http . post < ITimeOffPolicy > ( `${ API_PREFIX }/time-off-policy` , createInput ) ; } getAllPolicies ( relations ? , findInput ? ) { const data = JSON . stringify ( { relations , findInput } ) ; return this . http . get < IPagination < ITimeOffPolicy > > ( `${ API_PREFIX }/time-off-policy` , { params : { data } } ) ; } updatePolicy ( id , updateInput ) { return this . http . put < ITimeOffPolicy > ( `${ API_PREFIX }/time-off-policy/${ id }` , updateInput ) ; } deletePolicy ( id ) { return this . http . delete ( `${ API_PREFIX }/time-off-policy/${ id }` ) ; } createRequest ( timeOffRequest ) { return this . http . post < ITimeOff > ( `${ API_PREFIX }/time-off-request` , timeOffRequest ) ; } updateRequest ( id , timeOffRequest ) { return this . http . put < ITimeOff > ( `${ API_PREFIX }/time-off-request/${ id }` , timeOffRequest ) ; } getAllTimeOffRecords ( relations ? , findInput ? , filterDate ? ) { const data = JSON . stringify ( { relations , findInput , filterDate } ) ; return this . http . get < IPagination < ITimeOff > > ( `${ API_PREFIX }/time-off-request` , { params : { data } } ) ; } updateRequestStatus ( id , action ) { return this . http . put < ITimeOff > ( `${ API_PREFIX }/time-off-request/${ action }/${ id }` , { } ) ; } deleteDaysOffRequest ( id ) { return this . http . delete ( `${ API_PREFIX }/time-off-request/${ id }` ) ; } }