Skip to content

Commit

Permalink
fix MergeYears to accept retireDate passed codeforboston#264
Browse files Browse the repository at this point in the history
  • Loading branch information
djmVHB committed Mar 3, 2021
1 parent 8ca5ce5 commit 87031d0
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/library/user-state-manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,15 @@ const useYear62State = createPersistedState("Year62", global.sessionStorage);
*/
function mergeYears(
earnings: EarningsRecord,
birthDate: Date | null
//,retireDate: Date | null
birthDate: Date | null,
retireDate: Date | null
): EarningsRecord {
/* if we don't have other info, just return what was passed in */
if (birthDate === null) return earnings;
//let cleanRetireDate = retireDate === null? dayjs(birthDate).add(70,'year').toDate(): retireDate;
let cleanRetireDate = dayjs(birthDate).add(71,'year').toDate();
let cleanRetireDate = (retireDate === null) ? dayjs(birthDate).add(70,'year').toDate(): retireDate;

const earningsRecord = earnings || {};

/*TODO(TDK) why do we need to create a new date object here, it is a string coming in? */
const birthYear = new Date(birthDate).getFullYear();
const birthYear = birthDate.getFullYear();
const startEmploymentYear =
(earnings && Object.keys(earnings) && Number(Object.keys(earnings)[0])) ||
birthYear + 18;
Expand All @@ -123,7 +120,6 @@ function mergeYears(
}
return tempRecord;
}

/**
* Helper function to get a Date object equivalent to the start of the date given
*/
Expand Down

0 comments on commit 87031d0

Please sign in to comment.