2018-04-24 08:10:54 -05:00
|
|
|
import { Component, OnInit } from '@angular/core'
|
|
|
|
import { ActivatedRoute } from '@angular/router'
|
|
|
|
import { AccountService } from '@app/shared/account/account.service'
|
|
|
|
import { Account } from '@app/shared/account/account.model'
|
2018-05-31 04:35:01 -05:00
|
|
|
import { RestExtractor } from '@app/shared'
|
|
|
|
import { catchError } from 'rxjs/operators'
|
2018-04-24 08:10:54 -05:00
|
|
|
|
|
|
|
@Component({
|
2018-04-25 09:56:13 -05:00
|
|
|
templateUrl: './accounts.component.html',
|
|
|
|
styleUrls: [ './accounts.component.scss' ]
|
2018-04-24 08:10:54 -05:00
|
|
|
})
|
2018-04-25 09:56:13 -05:00
|
|
|
export class AccountsComponent implements OnInit {
|
2018-04-25 03:21:38 -05:00
|
|
|
account: Account
|
2018-04-24 08:10:54 -05:00
|
|
|
|
|
|
|
constructor (
|
|
|
|
private route: ActivatedRoute,
|
2018-05-31 04:35:01 -05:00
|
|
|
private accountService: AccountService,
|
|
|
|
private restExtractor: RestExtractor
|
2018-04-24 08:10:54 -05:00
|
|
|
) {}
|
|
|
|
|
|
|
|
ngOnInit () {
|
2018-05-24 08:30:28 -05:00
|
|
|
const accountId = this.route.snapshot.params['accountId']
|
2018-04-24 08:10:54 -05:00
|
|
|
|
|
|
|
this.accountService.getAccount(accountId)
|
2018-05-31 04:35:01 -05:00
|
|
|
.pipe(catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ])))
|
2018-04-24 08:10:54 -05:00
|
|
|
.subscribe(account => this.account = account)
|
|
|
|
}
|
|
|
|
}
|