From aab5411b30b7f3c2f0812706c6016741e310d735 Mon Sep 17 00:00:00 2001 From: Brandon Wortman Date: Thu, 5 Dec 2024 13:13:33 -0500 Subject: [PATCH] Replace use of prompt() in portfolio-summary, to use new GfPromptDialogComponent #3955 --- .../portfolio-summary.component.ts | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts index cac21c069..db23d10b1 100644 --- a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts +++ b/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` + }); } }