Skip to content

Commit

Permalink
Sync develop with Main for release candidate v1.5.1 (#1128)
Browse files Browse the repository at this point in the history
* Fix results page on language toggle (#1124)

fix results page on language toggle

* removing months from the age

---------

Co-authored-by: Alex Soloviev <[email protected]>
  • Loading branch information
MarcoGoC and alex-solo authored Dec 17, 2024
1 parent 98743e4 commit b92c410
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pages/results/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const ResultsPage = dynamic(
const Results: NextPage<{ adobeAnalyticsUrl: string }> = ({
adobeAnalyticsUrl,
}) => {
const [inputs, setInputs]: [
const [_inputs, setInputs]: [
FieldInputsObject,
(value: FieldInputsObject) => void
] = useSessionStorage('inputs', {})
Expand All @@ -43,7 +43,7 @@ const Results: NextPage<{ adobeAnalyticsUrl: string }> = ({
const [response, setResponse]: [any, (value: any) => void] =
useSessionStorage('calculationResults', {})

const [savedInputs, setSavedInputs]: [any, (value: any) => void] =
const [savedInputs, _setSavedInputs]: [any, (value: any) => void] =
useSessionStorage('resultPageInputs', {})

const inputHelper = new InputHelper(
Expand All @@ -61,6 +61,12 @@ const Results: NextPage<{ adobeAnalyticsUrl: string }> = ({
}
}, []) // eslint-disable-line react-hooks/exhaustive-deps

useEffect(() => {
const mainHandler = new MainHandler(inputHelper.asObjectWithLanguage)
const response: ResponseSuccess | ResponseError = mainHandler.results
setResponse(response)
}, [language])

return (
<>
<Head>
Expand Down
8 changes: 8 additions & 0 deletions utils/api/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ export function OasEligibility(
yearsInCanada++
}

// If client is n years + months. #219890
// the oas should be 65 exactly not 65 plus months
age =
age > minAgeEligibility && age < minAgeEligibility + 1
? Math.floor(age)
: age

ageOfEligibility =
yearsInCanadaAtStart < minYearsOfResEligibility ? age : Math.floor(age)

Expand Down Expand Up @@ -269,6 +276,7 @@ export function evaluateOASInput(input) {
const age = input.age // 66.42
const ageJuly2013 = calculate2013Age(age, input.clientBirthDate)
const yearsInCanada = input.yearsInCanadaSince18

let eliObj = OasEligibility(
age,
yearsInCanada,
Expand Down

0 comments on commit b92c410

Please sign in to comment.