From 4d8353e9fb6e29e0a0601e476fc1c590cfe3cfa1 Mon Sep 17 00:00:00 2001 From: Khalid Adan Date: Thu, 13 Jan 2022 17:22:41 -0500 Subject: [PATCH 1/2] Fix: track error state on home page (#88) --- pages/index.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index 5d2b6d9e7..640f44d62 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,6 +1,7 @@ import type { NextPage } from 'next' import Link from 'next/link' import { useRouter } from 'next/router' +import { useState } from 'react' import { Alert } from '../components/Alert' import { CurrencyField } from '../components/Forms/CurrencyField' import { Layout } from '../components/Layout' @@ -8,6 +9,7 @@ import { EstimationSummaryState } from '../utils/api/definitions/enums' const Home: NextPage = () => { const router = useRouter() + const [error, setError] = useState(null) return (
@@ -55,23 +57,28 @@ const Home: NextPage = () => { const input = document.querySelector( 'input[name="income"]' ) as HTMLInputElement - const sanitizedValue = input.value - .replaceAll('$', '') - .replaceAll(',', '') - router.push(`/eligibility?income=${sanitizedValue}`) + const sanitizedValue = input.value.replaceAll('$', '').replaceAll(',', '') + if (sanitizedValue == null || sanitizedValue == '') { + setError('This field is required') + } else { + router.push(`/eligibility?income=${sanitizedValue}`) + } }} onReset={(e) => { const input = document.querySelector( 'input[name="income"]' ) as HTMLInputElement input.setAttribute('value', '') + setError('') }} + noValidate >
From 7951ed81662ff3c21cc1f6733b70460c8530594b Mon Sep 17 00:00:00 2001 From: Khalid Adan Date: Fri, 14 Jan 2022 13:54:30 -0500 Subject: [PATCH 2/2] Fixed rounding bug! (#91) --- components/ResultsTable/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/ResultsTable/index.tsx b/components/ResultsTable/index.tsx index 0305542d7..a7f6bf959 100644 --- a/components/ResultsTable/index.tsx +++ b/components/ResultsTable/index.tsx @@ -63,10 +63,12 @@ export const ResultsTable = observer(() => { Total Monthly Benefit Amount $ - {root.oas.entitlementResult + + {( + root.oas.entitlementResult + root.gis.entitlementResult + root.allowance?.entitlementResult + - root.afs?.entitlementResult} + root.afs?.entitlementResult + ).toFixed(2)}