From 57bc3f173c00ccdf1dcaf8d4cb42452656c8f82e Mon Sep 17 00:00:00 2001 From: Shivansh-22866 Date: Fri, 10 Oct 2025 00:35:38 +0530 Subject: [PATCH] Review Changes --- .../portfolio/fire/fire-page.component.ts | 39 ++++++++++++------- .../app/pages/portfolio/fire/fire-page.html | 13 +++---- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/apps/client/src/app/pages/portfolio/fire/fire-page.component.ts b/apps/client/src/app/pages/portfolio/fire/fire-page.component.ts index f5169ce22..5f73d37d4 100644 --- a/apps/client/src/app/pages/portfolio/fire/fire-page.component.ts +++ b/apps/client/src/app/pages/portfolio/fire/fire-page.component.ts @@ -19,14 +19,14 @@ import { takeUntil } from 'rxjs/operators'; @Component({ imports: [ - CommonModule, - FormsModule, - ReactiveFormsModule, GfFireCalculatorComponent, GfPremiumIndicatorComponent, GfValueComponent, NgStyle, - NgxSkeletonLoaderModule + NgxSkeletonLoaderModule, + CommonModule, + FormsModule, + ReactiveFormsModule ], selector: 'gf-fire-page', styleUrls: ['./fire-page.scss'], @@ -38,13 +38,12 @@ export class GfFirePageComponent implements OnDestroy, OnInit { public hasImpersonationId: boolean; public hasPermissionToUpdateUserSettings: boolean; public isLoading = false; + public safeWithdrawalRateControl = new FormControl(0.025); public safeWithdrawalRateOptions = [0.025, 0.03, 0.035, 0.04, 0.045]; public user: User; public withdrawalRatePerMonth: Big; public withdrawalRatePerYear: Big; - public safeWithdrawalRateControl: FormControl; - private unsubscribeSubject = new Subject(); public constructor( @@ -100,12 +99,19 @@ export class GfFirePageComponent implements OnDestroy, OnInit { if (state?.user) { this.user = state.user; - const newSWR = this.user?.settings?.safeWithdrawalRate ?? 0.025; + const isWithdrawalRateDisabled = + this.user?.subscription?.type === 'Basic' || + this.hasImpersonationId; - if (this.safeWithdrawalRateControl.value !== newSWR) { - this.safeWithdrawalRateControl.setValue(newSWR, { - emitEvent: false - }); + this.safeWithdrawalRateControl.setValue( + this.user.settings.safeWithdrawalRate, + { emitEvent: false } + ); + + if (isWithdrawalRateDisabled) { + this.safeWithdrawalRateControl.disable({ emitEvent: false }); + } else { + this.safeWithdrawalRateControl.enable({ emitEvent: false }); } this.hasPermissionToUpdateUserSettings = @@ -122,10 +128,13 @@ export class GfFirePageComponent implements OnDestroy, OnInit { } }); - this.safeWithdrawalRateControl.valueChanges.subscribe((value: number) => { - console.log('New SWR selected:', value); - this.onSafeWithdrawalRateChange(Number(value)); - }); + this.safeWithdrawalRateControl.valueChanges + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe((value: number) => { + if (!this.safeWithdrawalRateControl.disabled) { + this.onSafeWithdrawalRateChange(Number(value)); + } + }); } public onAnnualInterestRateChange(annualInterestRate: number) { diff --git a/apps/client/src/app/pages/portfolio/fire/fire-page.html b/apps/client/src/app/pages/portfolio/fire/fire-page.html index cd9d9f2a6..adb84244b 100644 --- a/apps/client/src/app/pages/portfolio/fire/fire-page.html +++ b/apps/client/src/app/pages/portfolio/fire/fire-page.html @@ -107,15 +107,14 @@ and a safe withdrawal rate (SWR) of   }