From 22351115c1449e196574476a32570b4124184b45 Mon Sep 17 00:00:00 2001 From: zzhhaa Date: Thu, 9 Jan 2025 17:46:02 +0000 Subject: [PATCH 1/2] nit: fix placeholder copy in form --- app/components/ui/CalculatorInput.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/components/ui/CalculatorInput.tsx b/app/components/ui/CalculatorInput.tsx index 22c6167..0c4cf74 100644 --- a/app/components/ui/CalculatorInput.tsx +++ b/app/components/ui/CalculatorInput.tsx @@ -206,7 +206,7 @@ const CalculatorInput = () => { { { { Mortgage interest rate - 6% + 6% {/* TODO: should we hook these up to the actual variables used so we don't have to maintain them in two places? */}
Mortgage term - 25 years + 30 years
Mortgage deposit - 25 years + 15%
From 8db84c1031b347dab444fbf111247f65e4e72331 Mon Sep 17 00:00:00 2001 From: zzhhaa Date: Fri, 10 Jan 2025 09:25:52 +0000 Subject: [PATCH 2/2] feat: move mortgage constants and import into CalculatorInput --- app/components/ui/CalculatorInput.tsx | 7 ++++--- app/models/Mortgage.ts | 7 +------ app/models/constants.ts | 4 ++++ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/components/ui/CalculatorInput.tsx b/app/components/ui/CalculatorInput.tsx index 0c4cf74..ff5e3af 100644 --- a/app/components/ui/CalculatorInput.tsx +++ b/app/components/ui/CalculatorInput.tsx @@ -6,6 +6,7 @@ import { Household } from "@/app/models/Household"; import Dashboard from "./Dashboard"; import { formSchema, FormFrontend } from "@/app/schemas/formSchema"; import { useSearchParams } from "next/navigation"; +import { DEFAULT_INTEREST_RATE, DEFAULT_MORTGAGE_TERM, DEFAULT_INITIAL_DEPOSIT } from "../../models/constants" import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { ClipLoader } from "react-spinners"; @@ -327,19 +328,19 @@ const CalculatorInput = () => { Mortgage interest rate - 6% {/* TODO: should we hook these up to the actual variables used so we don't have to maintain them in two places? */} + {DEFAULT_INTEREST_RATE * 100}%
Mortgage term - 30 years + {DEFAULT_MORTGAGE_TERM} years
Mortgage deposit - 15% + {DEFAULT_INITIAL_DEPOSIT * 100}%
diff --git a/app/models/Mortgage.ts b/app/models/Mortgage.ts index df69ba5..33a4db6 100644 --- a/app/models/Mortgage.ts +++ b/app/models/Mortgage.ts @@ -1,9 +1,4 @@ -import { MONTHS_PER_YEAR } from "./constants"; - -const DEFAULT_INTEREST_RATE = 0.06; -const DEFAULT_MORTGAGE_TERM = 30; -const DEFAULT_INITIAL_DEPOSIT = 0.15; - +import { MONTHS_PER_YEAR, DEFAULT_INTEREST_RATE, DEFAULT_MORTGAGE_TERM, DEFAULT_INITIAL_DEPOSIT } from "./constants"; interface MortgageParams { propertyValue: number; interestRate?: number; diff --git a/app/models/constants.ts b/app/models/constants.ts index 987ca1d..899a6c7 100644 --- a/app/models/constants.ts +++ b/app/models/constants.ts @@ -1,6 +1,10 @@ export const MONTHS_PER_YEAR = 12; export const WEEKS_PER_MONTH = 4.2; +export const DEFAULT_INTEREST_RATE = 0.06; +export const DEFAULT_MORTGAGE_TERM = 30; +export const DEFAULT_INITIAL_DEPOSIT = 0.15; + export type BedWeightsAndCaps = { numberOfBedrooms: number[]; weight: number[];