Newer
Older
import {ChangeDetectionStrategy, Component, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {GetById} from '@app/deposit/deposit.action';
import {DepositStateModel} from '@app/deposit/deposit.state';
import {DepositsModel} from '@app/generated-api';
import {Select, Store} from '@ngxs/store';
import {Observable} from 'rxjs';
@Component({
selector: 'dlcm-deposit-detail-view',
templateUrl: './deposit-detail-view.component.html',
styleUrls: ['./deposit-detail-view.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DepositDetailViewComponent implements OnInit {
@Select((state) => ((state.deposit) as DepositStateModel).isLoading) isLoading$: Observable<boolean>;
@Select((state) => ((state.deposit) as DepositStateModel).currentDeposit) currentDeposit$: Observable<DepositsModel>;
constructor(private store: Store, private route: ActivatedRoute) {
}
ngOnInit() {
this.getCurrentDeposit();
}
private getCurrentDeposit() {
const id = this.route.snapshot.paramMap.get('id');
this.getById(id);
}
private getById(id: string) {
this.store.dispatch(new GetById(id));
}
}