Browse Source

Replace use of prompt() in portfolio-summary, to use new GfPromptDialogComponent #3955

pull/4117/head
Brandon Wortman 9 months ago
parent
commit
aab5411b30
No known key found for this signature in database GPG Key ID: C63DB7DA05AEC086
  1. 24
      apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts

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

@ -1,3 +1,4 @@
import { NotificationService } from '@ghostfolio/client/core/notification/notification.service';
import { getDateFnsLocale, getLocale } from '@ghostfolio/common/helper';
import { PortfolioSummary, User } from '@ghostfolio/common/interfaces';
import { translate } from '@ghostfolio/ui/i18n';
@ -34,6 +35,8 @@ export class PortfolioSummaryComponent implements OnChanges {
);
public timeInMarket: string;
constructor(private notificationService: NotificationService) {}
public ngOnChanges() {
if (this.summary) {
if (this.summary.firstOrderDate) {
@ -49,14 +52,17 @@ export class PortfolioSummaryComponent implements OnChanges {
}
public onEditEmergencyFund() {
const emergencyFundInput = prompt(
$localize`Please enter the amount of your emergency fund:`,
this.summary.emergencyFund?.total?.toString() ?? '0'
);
const emergencyFund = parseFloat(emergencyFundInput?.trim());
if (emergencyFund >= 0) {
this.emergencyFundChanged.emit(emergencyFund);
}
this.notificationService.prompt({
confirmFn: (value) => {
const emergencyFund = parseFloat(value.trim());
if (emergencyFund >= 0) {
this.emergencyFundChanged.emit(emergencyFund);
}
},
confirmLabel: $localize`Save`,
defaultValue: this.summary.emergencyFund?.total?.toString() ?? '0',
title: $localize`Please enter the amount of your emergency fund:`,
valueLabel: $localize`Emergency fund`
});
}
}

Loading…
Cancel
Save