Cleaned up Redemptions with use of AsyncPipe & input transformers.

This commit is contained in:
Tom
2025-04-09 20:57:19 +00:00
parent b0f9a2dea8
commit daa500111c
14 changed files with 136 additions and 203 deletions

View File

@@ -1,9 +1,8 @@
import { Component, EventEmitter, inject, input, Input, OnInit, Output } from '@angular/core';
import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { ActivatedRoute } from '@angular/router';
import RedeemableAction from '../../shared/models/redeemable-action';
@Component({
@@ -21,20 +20,9 @@ export class ActionDropdownComponent implements OnInit {
@Input() action: string | undefined;
@Output() readonly actionChange = new EventEmitter<string>();
private readonly route = inject(ActivatedRoute);
errorMessageKeys: string[] = []
constructor() {
this.route.data.subscribe(data => {
if (!data['redeemableActions'])
return;
this.actions = data['redeemableActions'];
});
}
ngOnInit(): void {
this.errorMessageKeys = Object.keys(this.errorMessages);

View File

@@ -58,7 +58,7 @@ export class ActionsComponent implements OnInit, OnDestroy {
ngOnInit(): void {
this.route.data.subscribe(data => this._actions = data['redeemableActions'] || []);
this.subscriptions.push(this.redeemableActionService.delete$?.subscribe(_ => this.redeemableActionService.fetch().subscribe(a => this._actions = a)));
this.subscriptions.push(this.redeemableActionService.changes$?.subscribe(a => this._actions = a));
this.client.fetchRedeemableActions();
}