Browse Source

Refactoring

pull/6034/head
Thomas Kaul 2 weeks ago
parent
commit
0ba286e176
  1. 30
      apps/client/src/app/pages/portfolio/fire/fire-page.component.ts
  2. 9
      apps/client/src/app/pages/portfolio/fire/fire-page.html
  3. 0
      libs/common/src/lib/interfaces/fire-calculation-complete-event.interface.ts
  4. 2
      libs/common/src/lib/interfaces/index.ts

30
apps/client/src/app/pages/portfolio/fire/fire-page.component.ts

@ -48,8 +48,8 @@ export class GfFirePageComponent implements OnDestroy, OnInit {
public safeWithdrawalRateOptions = [0.025, 0.03, 0.035, 0.04, 0.045]; public safeWithdrawalRateOptions = [0.025, 0.03, 0.035, 0.04, 0.045];
public user: User; public user: User;
public withdrawalRatePerMonth: Big; public withdrawalRatePerMonth: Big;
public withdrawalRatePerYear: Big;
public withdrawalRatePerMonthProjected: Big; public withdrawalRatePerMonthProjected: Big;
public withdrawalRatePerYear: Big;
public withdrawalRatePerYearProjected: Big; public withdrawalRatePerYearProjected: Big;
private unsubscribeSubject = new Subject<void>(); private unsubscribeSubject = new Subject<void>();
@ -145,6 +145,18 @@ export class GfFirePageComponent implements OnDestroy, OnInit {
}); });
} }
public onCalculationComplete({
projectedTotalAmount,
retirementDate
}: FireCalculationCompleteEvent) {
this.projectedTotalAmount = projectedTotalAmount;
this.retirementDate = retirementDate;
this.calculateWithdrawalRatesProjected();
this.isLoading = false;
}
public onRetirementDateChange(retirementDate: Date) { public onRetirementDateChange(retirementDate: Date) {
this.dataService this.dataService
.putUserSetting({ .putUserSetting({
@ -176,7 +188,7 @@ export class GfFirePageComponent implements OnDestroy, OnInit {
this.user = user; this.user = user;
this.calculateWithdrawalRates(); this.calculateWithdrawalRates();
this.calculateProjectedWithdrawalRates(); this.calculateWithdrawalRatesProjected();
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
}); });
@ -218,18 +230,6 @@ export class GfFirePageComponent implements OnDestroy, OnInit {
}); });
} }
public onCalculationComplete({
projectedTotalAmount,
retirementDate
}: FireCalculationCompleteEvent) {
this.projectedTotalAmount = projectedTotalAmount;
this.retirementDate = retirementDate;
this.calculateProjectedWithdrawalRates();
this.isLoading = false;
}
public ngOnDestroy() { public ngOnDestroy() {
this.unsubscribeSubject.next(); this.unsubscribeSubject.next();
this.unsubscribeSubject.complete(); this.unsubscribeSubject.complete();
@ -245,7 +245,7 @@ export class GfFirePageComponent implements OnDestroy, OnInit {
} }
} }
private calculateProjectedWithdrawalRates() { private calculateWithdrawalRatesProjected() {
if ( if (
this.fireWealth && this.fireWealth &&
this.projectedTotalAmount && this.projectedTotalAmount &&

9
apps/client/src/app/pages/portfolio/fire/fire-page.html

@ -63,7 +63,7 @@
</div> </div>
} @else { } @else {
<div [ngClass]="{ 'text-muted': user?.subscription?.type === 'Basic' }"> <div [ngClass]="{ 'text-muted': user?.subscription?.type === 'Basic' }">
<div> <div class="mb-2">
<ng-container i18n <ng-container i18n
>If you retire today, you would be able to withdraw</ng-container >If you retire today, you would be able to withdraw</ng-container
> >
@ -135,11 +135,13 @@
} }
</div> </div>
<div class="mt-2"> @if (user?.settings?.isExperimentalFeatures) {
<div>
<ng-container i18n>By</ng-container> <ng-container i18n>By</ng-container>
<ng-container>&nbsp;</ng-container> <ng-container>&nbsp;</ng-container>
<span class="font-weight-bold">{{ <span class="font-weight-bold">{{
user?.settings?.retirementDate ?? retirementDate | date: 'MMMM yyyy' user?.settings?.retirementDate ?? retirementDate
| date: 'MMMM yyyy'
}}</span> }}</span>
<ng-container i18n>,</ng-container> <ng-container i18n>,</ng-container>
<ng-container>&nbsp;</ng-container> <ng-container>&nbsp;</ng-container>
@ -184,6 +186,7 @@
<ng-container>&nbsp;</ng-container> <ng-container>&nbsp;</ng-container>
<ng-container i18n>annual interest rate</ng-container>. <ng-container i18n>annual interest rate</ng-container>.
</div> </div>
}
</div> </div>
} }
</div> </div>

0
libs/common/src/lib/interfaces/fire-calculation.interface.ts → libs/common/src/lib/interfaces/fire-calculation-complete-event.interface.ts

2
libs/common/src/lib/interfaces/index.ts

@ -18,7 +18,7 @@ import type { DataProviderInfo } from './data-provider-info.interface';
import type { EnhancedSymbolProfile } from './enhanced-symbol-profile.interface'; import type { EnhancedSymbolProfile } from './enhanced-symbol-profile.interface';
import type { FilterGroup } from './filter-group.interface'; import type { FilterGroup } from './filter-group.interface';
import type { Filter } from './filter.interface'; import type { Filter } from './filter.interface';
import type { FireCalculationCompleteEvent } from './fire-calculation.interface'; import type { FireCalculationCompleteEvent } from './fire-calculation-complete-event.interface';
import type { FireWealth } from './fire-wealth.interface'; import type { FireWealth } from './fire-wealth.interface';
import type { HistoricalDataItem } from './historical-data-item.interface'; import type { HistoricalDataItem } from './historical-data-item.interface';
import type { HoldingWithParents } from './holding-with-parents.interface'; import type { HoldingWithParents } from './holding-with-parents.interface';

Loading…
Cancel
Save