Created a period table for date ranges and made the recipes dependent on it instead of having arbitrary date ranges. This will enable easy copying into new months.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
@@ -22,9 +22,12 @@ export class RecipeService {
|
||||
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable<Recipe>;
|
||||
}
|
||||
|
||||
list(): Observable<Recipe[]> {
|
||||
list(periodId: string | null): Observable<Recipe[]> {
|
||||
if (periodId === null) {
|
||||
return observableOf([]);
|
||||
}
|
||||
return this.http
|
||||
.get<Recipe[]>(`${url}/list`)
|
||||
.get<Recipe[]>(`${url}/list`, { params: new HttpParams().set('p', periodId) })
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'getList'))) as Observable<Recipe[]>;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user