From 6c74b719ff176d0c14f19d0322417d6c1a10c3d7 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 8 Jul 2024 12:16:26 -0400 Subject: [PATCH 1/2] Fixed a typo in yaml file names Renamed from .yaml to .yml --- .github/{dependabot.yaml => dependabot.yml} | 0 .github/{mergeable.yaml => mergeable.yml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/{dependabot.yaml => dependabot.yml} (100%) rename .github/{mergeable.yaml => mergeable.yml} (100%) diff --git a/.github/dependabot.yaml b/.github/dependabot.yml similarity index 100% rename from .github/dependabot.yaml rename to .github/dependabot.yml diff --git a/.github/mergeable.yaml b/.github/mergeable.yml similarity index 100% rename from .github/mergeable.yaml rename to .github/mergeable.yml From 47b99e8c10e0e6c939ef21483f7166478e9526bd Mon Sep 17 00:00:00 2001 From: David Poindexter Date: Mon, 15 Jul 2024 19:55:53 -0400 Subject: [PATCH 2/2] Updated to allow empty total amount and down payment with default value --- package-lock.json | 4 ++-- .../nvq-loan-calculator/nvq-loan-calculator.tsx | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3fe1b72..ffb86ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "nvq-loan-calculator", + "name": "@nvisionative/nvq-loan-calculator", "version": "1.0.0-beta0001", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "nvq-loan-calculator", + "name": "@nvisionative/nvq-loan-calculator", "version": "1.0.0-beta0001", "license": "MIT", "devDependencies": { diff --git a/src/components/nvq-loan-calculator/nvq-loan-calculator.tsx b/src/components/nvq-loan-calculator/nvq-loan-calculator.tsx index 39c03dc..e5cf24e 100644 --- a/src/components/nvq-loan-calculator/nvq-loan-calculator.tsx +++ b/src/components/nvq-loan-calculator/nvq-loan-calculator.tsx @@ -71,6 +71,11 @@ export class NvqLoanCalculator { } private getValidatedNumber(target: HTMLInputElement, digits: number, defaultValue: number = 0): number { + if (target.value === '') { + target.dataset.lastValidValue = defaultValue.toString(); + return undefined; + } + if (target.validity.valid) { const value = parseFloat(target.value); const roundedValue = this.roundTo(value, digits); @@ -115,6 +120,10 @@ export class NvqLoanCalculator { } private calculatePayment() { + if (isNaN(this.downPayment)) { + this.downPayment = 0; + } + // Assuming monthly compounding. const monthlyInterestRate = this.interestRate / 100 / 12; if (this.amortizationYears === undefined){ @@ -176,8 +185,7 @@ export class NvqLoanCalculator { min={0} max={this.totalAmount} step={0.01} - required - value={this.downPayment} + value={this.downPayment > 0 ? this.downPayment : ''} onKeyDown={e => this.onlyAllowNumbers(e)} onInput={e => this.downPayment = this.getValidatedNumber(e.target as HTMLInputElement, 2)} onBlur={e => this.displayErrorIfAny(e.target as HTMLInputElement)}