Skip to content

Commit

Permalink
Merge pull request #826 from DTS-STN/ado-132333-132303
Browse files Browse the repository at this point in the history
ADO-132333, 132303: added two changes based on regression testing
  • Loading branch information
MarcoGoC authored Jul 15, 2023
2 parents 223484d + ccf3820 commit 8c25a09
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
27 changes: 26 additions & 1 deletion components/ResultsPage/WillBeEligible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export const WillBeEligible: React.VFC<{
const apiTrans = getTranslations(tsln._language)
const language = useRouter().locale as Language

const multipleOAS_GIS =
futureResults.filter((obj) => !!obj[Object.keys(obj)[0]]['oas']).length > 1

return (
<>
<h2
Expand All @@ -30,7 +33,29 @@ export const WillBeEligible: React.VFC<{

{futureResults.map((resultObj, idx) => {
const age = Object.keys(resultObj)[0]
const text = `${language === 'en' ? 'At' : 'À'} ${age}, ${
const onlyOASGIS = Object.keys(
resultObj[Object.keys(resultObj)[0]]
).filter((key) => key === 'oas' || key === 'gis')

// show if some are non zero
const nonZeroExist = onlyOASGIS.some(
(key) => resultObj[age][key].entitlement?.result > 0
)

const enStr =
multipleOAS_GIS && nonZeroExist
? partner
? 'If your partner starts receiving at'
: 'If you start receiving at'
: 'At'
const frStr =
multipleOAS_GIS && nonZeroExist
? partner
? 'Si votre conjoint commence à'
: 'Si vous commencez à'
: 'À'

const text = `${language === 'en' ? enStr : frStr} ${age}, ${
partner
? tsln.resultsPage.partnerToReceive
: tsln.resultsPage.toReceive
Expand Down
7 changes: 3 additions & 4 deletions utils/api/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,13 @@ export function getAgeArray(ages: number[]) {
return result
}

export function buildQuery(query, ageSet, ageFraction) {
export function buildQuery(query, ageSet) {
const newQuery = { ...query }
const [userAge, partnerAge] = ageSet
const [userFraction, partnerFraction] = ageFraction

// CLIENT
newQuery['age'] = String(userAge + userFraction)
newQuery['partnerAge'] = String(partnerAge + partnerFraction)
newQuery['age'] = String(userAge)
newQuery['partnerAge'] = String(partnerAge)

if (userAge >= 65) {
addKeyValue(newQuery, 'receiveOAS', 'false')
Expand Down
4 changes: 1 addition & 3 deletions utils/api/mainHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ function getFutureResults(query, locale) {
const ageFloored = Math.floor(age)
const partnerAgeFloored = Math.floor(partnerAge)

const ageFraction = [age - ageFloored, partnerAge - partnerAgeFloored]

const ages = [ageFloored, partnerAgeFloored]
if (ages.some((age) => isNaN(age))) return futureResultsObj
const futureAges = getAgeArray(ages)
Expand All @@ -113,7 +111,7 @@ function getFutureResults(query, locale) {

futureAges.forEach((ageSet) => {
const [userAge, partnerAge] = ageSet
const newQuery = buildQuery(query, ageSet, ageFraction)
const newQuery = buildQuery(query, ageSet)
const { value } = schema.validate(newQuery, { abortEarly: false })
const futureHandler = new BenefitHandler(value, true)

Expand Down

0 comments on commit 8c25a09

Please sign in to comment.