AW-1415 Add postItemPackageTask
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Peter (extern) 2020-08-04 14:08:50 +02:00
parent fdfa7d3387
commit 309b320534

View File

@ -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<appCommonReducer.State>) {
constructor(private store$: Store<appCommonReducer.State>, 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<IItemTask> {
return this.httpClient.post<IItemTask>(`${this.ApiEndpoint()}/api/v1/items/${item.code}/packagetasks`, task);
}
}