]>
Commit | Line | Data |
---|---|---|
0626e7af C |
1 | import { Component, OnInit } from '@angular/core' |
2 | import { ActivatedRoute } from '@angular/router' | |
3 | import { AccountService } from '@app/shared/account/account.service' | |
4 | import { Account } from '@app/shared/account/account.model' | |
a51bad1a C |
5 | import { RestExtractor } from '@app/shared' |
6 | import { catchError } from 'rxjs/operators' | |
0626e7af C |
7 | |
8 | @Component({ | |
170726f5 C |
9 | templateUrl: './accounts.component.html', |
10 | styleUrls: [ './accounts.component.scss' ] | |
0626e7af | 11 | }) |
170726f5 | 12 | export class AccountsComponent implements OnInit { |
6b738c7a | 13 | account: Account |
0626e7af C |
14 | |
15 | constructor ( | |
16 | private route: ActivatedRoute, | |
a51bad1a C |
17 | private accountService: AccountService, |
18 | private restExtractor: RestExtractor | |
0626e7af C |
19 | ) {} |
20 | ||
21 | ngOnInit () { | |
d14a9532 | 22 | const accountId = this.route.snapshot.params['accountId'] |
0626e7af C |
23 | |
24 | this.accountService.getAccount(accountId) | |
a51bad1a | 25 | .pipe(catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ]))) |
0626e7af C |
26 | .subscribe(account => this.account = account) |
27 | } | |
0626e7af | 28 | } |