From 309b320534a282d3b2ff88f67ab9eed678cb0ac8 Mon Sep 17 00:00:00 2001 From: Peter Bastiani Date: Tue, 4 Aug 2020 14:08:50 +0200 Subject: [PATCH] AW-1415 Add postItemPackageTask --- .../common/src/fm/services/package.service.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/projects/common/src/fm/services/package.service.ts b/projects/common/src/fm/services/package.service.ts index b5b1257..063f7fb 100644 --- a/projects/common/src/fm/services/package.service.ts +++ b/projects/common/src/fm/services/package.service.ts @@ -3,6 +3,11 @@ import { Store} from '@ngrx/store'; import * as appCommonReducer from '../reducers/app-common.reducer' import { IPackages } from '../models/package'; +import { IItem } from '../models/item'; +import { IItemTask } from '../models/itemTask'; +import { HttpClient } from "@angular/common/http"; +import { AppConfig } from "../shared/app.config"; +import { Observable } from 'rxjs'; @Injectable({ providedIn: 'root', @@ -11,14 +16,22 @@ import { IPackages } from '../models/package'; export class PackageService { private packages$:IPackages = {}; - constructor(private store$: Store) { + constructor(private store$: Store, public httpClient: HttpClient, public appConfig: AppConfig) { store$.select(appCommonReducer.SelectGetUserPackages).subscribe((packages) => { this.packages$ = packages; }) } + ApiEndpoint() { + return this.appConfig.getConfig("apiEndPoint"); + } + hasPackage(id:string):boolean { if(!this.packages$[id]) return false; return this.packages$[id].enabled == true; } + + postItemPackageTask(item: IItem, task: IItemTask): Observable { + return this.httpClient.post(`${this.ApiEndpoint()}/api/v1/items/${item.code}/packagetasks`, task); + } } \ No newline at end of file