Browse Source

resolve comments

pull/8015/head
KenTandrian 2 weeks ago
parent
commit
269ee973ee
  1. 21
      libs/ui/src/lib/fire-calculator/fire-calculator.component.ts

21
libs/ui/src/lib/fire-calculator/fire-calculator.component.ts

@ -53,6 +53,7 @@ import {
addDays, addDays,
addYears, addYears,
getMonth, getMonth,
parseISO,
setMonth, setMonth,
setYear, setYear,
startOfMonth, startOfMonth,
@ -60,7 +61,7 @@ import {
} from 'date-fns'; } from 'date-fns';
import { addIcons } from 'ionicons'; import { addIcons } from 'ionicons';
import { calendarClearOutline } from 'ionicons/icons'; import { calendarClearOutline } from 'ionicons/icons';
import { isNumber } from 'lodash-es'; import { isNumber, isString } from 'lodash-es';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { debounceTime } from 'rxjs'; import { debounceTime } from 'rxjs';
@ -88,12 +89,12 @@ import { FireCalculatorService } from './fire-calculator.service';
export class GfFireCalculatorComponent implements OnChanges, OnDestroy { export class GfFireCalculatorComponent implements OnChanges, OnDestroy {
@Input() public annualInterestRate?: number = 0; @Input() public annualInterestRate?: number = 0;
@Input() public colorScheme?: ColorScheme; @Input() public colorScheme?: ColorScheme;
@Input() public currency?: string = DEFAULT_CURRENCY; @Input() public currency?: string;
@Input() public deviceType: string; @Input() public deviceType: string;
@Input() public fireWealth = 0; @Input() public fireWealth = 0;
@Input() public hasPermissionToUpdateUserSettings: boolean; @Input() public hasPermissionToUpdateUserSettings: boolean;
@Input() public locale?: string = getLocale(); @Input() public locale?: string = getLocale();
@Input() public projectedTotalAmount?: number; @Input() public projectedTotalAmount?: number = 0;
@Input() public retirementDate?: Date | string; @Input() public retirementDate?: Date | string;
@Input() public savingsRate?: number = 0; @Input() public savingsRate?: number = 0;
@ -246,10 +247,10 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy {
annualInterestRate: this.annualInterestRate ?? 0, annualInterestRate: this.annualInterestRate ?? 0,
paymentPerPeriod: this.savingsRate ?? 0, paymentPerPeriod: this.savingsRate ?? 0,
principalInvestmentAmount: this.fireWealth, principalInvestmentAmount: this.fireWealth,
projectedTotalAmount: this.projectedTotalAmount ?? null, projectedTotalAmount: this.projectedTotalAmount ?? 0,
retirementDate: this.retirementDate retirementDate: isString(this.retirementDate)
? new Date(this.retirementDate) ? parseISO(this.retirementDate)
: this.DEFAULT_RETIREMENT_DATE : (this.retirementDate ?? this.DEFAULT_RETIREMENT_DATE)
}, },
{ {
emitEvent: false emitEvent: false
@ -511,9 +512,9 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy {
return periods; return periods;
} else { } else {
const today = new Date(); const today = new Date();
const retirementDate = this.retirementDate const retirementDate =
? new Date(this.retirementDate) this.calculatorForm.get('retirementDate')?.value ??
: this.DEFAULT_RETIREMENT_DATE; this.DEFAULT_RETIREMENT_DATE;
return ( return (
12 * (retirementDate.getFullYear() - today.getFullYear()) + 12 * (retirementDate.getFullYear() - today.getFullYear()) +

Loading…
Cancel
Save