Files
brewman/overlord/src/app/net-transactions/net-transactions.service.ts
Amritanshu 72044476a8 Feature: Lazy loading
Lazy loaded everything
TODO: The cash flow module when clicking on sub-links, it reloads the whole page, it needs to be diagnosed and fixed, this problem also exists in the other modules
TODO: Rename folders and modules such as account to accounts to match the url
2019-06-13 16:36:43 +05:30

38 lines
1.1 KiB
TypeScript

import {Injectable} from '@angular/core';
import {catchError} from 'rxjs/operators';
import {Observable} from 'rxjs/internal/Observable';
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
import {NetTransactions} from './net-transactions';
import {ErrorLoggerService} from '../core/error-logger.service';
const httpOptions = {
headers: new HttpHeaders({'Content-Type': 'application/json'})
};
const url = '/api/net-transactions';
const serviceName = 'NetTransactionsService';
@Injectable({
providedIn: 'root'
})
export class NetTransactionsService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {
}
list(startDate: string, finishDate): Observable<NetTransactions> {
const options = {params: new HttpParams()};
if (startDate !== null) {
options.params = options.params.set('s', startDate);
}
if (finishDate !== null) {
options.params = options.params.set('f', finishDate);
}
return <Observable<NetTransactions>>this.http.get<NetTransactions>(url, options)
.pipe(
catchError(this.log.handleError(serviceName, 'list'))
);
}
}