tanshu
5ea09df272
Now all that is needed is to make it ready for strict compiling. Removed eslint-plugin-prettier as it is not recommended and causes errors for both eslint and prettier Bumped to v8.0.0
26 lines
783 B
TypeScript
26 lines
783 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
|
|
import { Observable } from 'rxjs/internal/Observable';
|
|
|
|
import { Voucher } from '../core/voucher';
|
|
import { VoucherService } from '../core/voucher.service';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class ReceiptResolver implements Resolve<Voucher> {
|
|
constructor(private ser: VoucherService) {}
|
|
|
|
resolve(route: ActivatedRouteSnapshot): Observable<Voucher> {
|
|
const id = route.paramMap.get('id');
|
|
const account = route.queryParamMap.get('a') || null;
|
|
if (id !== null) {
|
|
return this.ser.get(id, 'Receipt');
|
|
}
|
|
if (account !== null) {
|
|
return this.ser.getOfType('Receipt', account);
|
|
}
|
|
return this.ser.getOfType('Receipt');
|
|
}
|
|
}
|