AW-3441 fix package validation
All checks were successful
FarmMaps/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
2022-01-27 17:07:24 +01:00
parent b7c80dfdd8
commit 519b81d1fd
4 changed files with 60 additions and 60 deletions

View File

@@ -14,24 +14,33 @@ import {Observable} from 'rxjs';
})
export class PackageService {
private packages: {[key: string]: IPackage} = {};
private packages: { [key: string]: IPackage } = {};
constructor(private store$: Store<appCommonReducer.State>, public httpClient: HttpClient, public appConfig: AppConfig) {
store$.select(appCommonReducer.SelectGetValidUserPackages).subscribe((packages) => {
this.packages = packages;
});
constructor(private store$: Store<appCommonReducer.State>, public httpClient: HttpClient, public appConfig: AppConfig) {
store$.select(appCommonReducer.SelectGetValidUserPackages).subscribe((packages) => {
this.packages = packages;
});
}
ApiEndpoint() {
return this.appConfig.getConfig('apiEndPoint');
}
hasPackage(id: string): boolean {
if (!this.packages[id]) {
return false;
}
ApiEndpoint() {
return this.appConfig.getConfig("apiEndPoint");
}
return this.packages[id].enabled;
}
hasPackage(id:string):boolean {
if(!this.packages[id]) return false;
return this.packages[id].enabled ? this.packages[id].enabled === true : true;
}
postItemPackageTask(item: IItem, task: IItemTask): Observable<IItemTask> {
return this.httpClient.post<IItemTask>(`${this.ApiEndpoint()}/api/v1/items/${item.code}/packagetasks`, task);
}
postItemPackageTask(item: IItem, task: IItemTask): Observable<IItemTask> {
return this.httpClient.post<IItemTask>(`${this.ApiEndpoint()}/api/v1/items/${item.code}/packagetasks`, task);
}
}
export function isValidPackage(pack: IPackage): boolean {
const today = new Date(new Date(Date.now()).toUTCString()).setHours(0, 0, 0, 0);
return pack !== null && pack.dataDate.getTime() <= today
&& (!pack.dataEndDate || pack.dataEndDate.getTime() >= today);
}