AW-3441 fix package validation
All checks were successful
FarmMaps/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user