Browse Source

#3955 Make constructor public and handle empty emergency fund input

If negative, fallback to defaultValue.
If empty/user deletes entry, fallback to 0.
pull/4117/head
Brandon Wortman 8 months ago
parent
commit
3f0677946f
No known key found for this signature in database GPG Key ID: C63DB7DA05AEC086
  1. 5
      apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts

5
apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts

@ -35,7 +35,7 @@ export class PortfolioSummaryComponent implements OnChanges {
); );
public timeInMarket: string; public timeInMarket: string;
constructor(private notificationService: NotificationService) {} public constructor(private notificationService: NotificationService) {}
public ngOnChanges() { public ngOnChanges() {
if (this.summary) { if (this.summary) {
@ -54,7 +54,8 @@ export class PortfolioSummaryComponent implements OnChanges {
public onEditEmergencyFund() { public onEditEmergencyFund() {
this.notificationService.prompt({ this.notificationService.prompt({
confirmFn: (value) => { confirmFn: (value) => {
const emergencyFund = parseFloat(value.trim()); // If empty/deleted value by user, default to 0.
const emergencyFund = parseFloat(value.trim()) || 0;
if (emergencyFund >= 0) { if (emergencyFund >= 0) {
this.emergencyFundChanged.emit(emergencyFund); this.emergencyFundChanged.emit(emergencyFund);
} }

Loading…
Cancel
Save