brewman/overlord/src/app/purchase-entries/purchase-entries.service.ts
tanshu 57ef355170 Fix: Login deleting old clients was conflicting with login history
Chore: Moved to angular linting using the recommended plugins / settings
2020-12-08 12:09:19 +05:30

27 lines
988 B
TypeScript

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/internal/Observable';
import { catchError } from 'rxjs/operators';
import { ErrorLoggerService } from '../core/error-logger.service';
import { PurchaseEntries } from './purchase-entries';
const url = '/api/purchase-entries';
const serviceName = 'PurchaseEntriesService';
@Injectable({
providedIn: 'root',
})
export class PurchaseEntriesService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
list(startDate: string | null, finishDate: string | null): Observable<PurchaseEntries> {
const startDateWithSlash = startDate ? `/${startDate}` : '';
const finishDateWithSlash = finishDate ? `/${finishDate}` : '';
return this.http
.get<PurchaseEntries>(`${url}${startDateWithSlash}${finishDateWithSlash}`)
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<PurchaseEntries>;
}
}