Browse Source

feat(client): migrate errors to input signal

pull/7265/head
KenTandrian 1 week ago
parent
commit
8d70e1c0bc
  1. 2
      apps/client/src/app/components/portfolio-performance/portfolio-performance.component.html
  2. 9
      apps/client/src/app/components/portfolio-performance/portfolio-performance.component.ts

2
apps/client/src/app/components/portfolio-performance/portfolio-performance.component.html

@ -1,7 +1,7 @@
<div class="container p-0"> <div class="container p-0">
<div class="no-gutters row"> <div class="no-gutters row">
<div class="status-container text-muted text-right"> <div class="status-container text-muted text-right">
@if (errors?.length > 0 && !isLoading) { @if (errors()?.length > 0 && !isLoading) {
<ion-icon <ion-icon
i18n-title i18n-title
name="time-outline" name="time-outline"

9
apps/client/src/app/components/portfolio-performance/portfolio-performance.component.ts

@ -15,6 +15,7 @@ import {
Component, Component,
ElementRef, ElementRef,
inject, inject,
input,
Input, Input,
OnChanges, OnChanges,
viewChild viewChild
@ -34,7 +35,6 @@ import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
templateUrl: './portfolio-performance.component.html' templateUrl: './portfolio-performance.component.html'
}) })
export class GfPortfolioPerformanceComponent implements OnChanges { export class GfPortfolioPerformanceComponent implements OnChanges {
@Input() errors: ResponseError['errors'];
@Input() isLoading: boolean; @Input() isLoading: boolean;
@Input() locale = getLocale(); @Input() locale = getLocale();
@Input() performance: PortfolioPerformance; @Input() performance: PortfolioPerformance;
@ -42,6 +42,8 @@ export class GfPortfolioPerformanceComponent implements OnChanges {
@Input() showDetails: boolean; @Input() showDetails: boolean;
@Input() unit: string; @Input() unit: string;
public readonly errors = input<ResponseError['errors']>();
private readonly value = private readonly value =
viewChild.required<ElementRef<HTMLSpanElement>>('value'); viewChild.required<ElementRef<HTMLSpanElement>>('value');
@ -84,13 +86,14 @@ export class GfPortfolioPerformanceComponent implements OnChanges {
} }
protected onShowErrors() { protected onShowErrors() {
if (!this.errors?.length) { const errors = this.errors();
if (!errors?.length) {
return; return;
} }
const errorMessageParts: string[] = []; const errorMessageParts: string[] = [];
for (const error of this.errors) { for (const error of errors) {
errorMessageParts.push(`${error.symbol} (${error.dataSource})`); errorMessageParts.push(`${error.symbol} (${error.dataSource})`);
} }

Loading…
Cancel
Save