Skip to content

Commit

Permalink
Clear sideOfBody value onNavForward from condition and remove from is…
Browse files Browse the repository at this point in the history
…ItemIncomplete
  • Loading branch information
williamphelps13 committed Nov 14, 2024
1 parent 7f793c3 commit 6dbc6cd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ const newConditionsPages = arrayBuilderPages(
const index = getArrayIndexFromPathName(pathname);
const urlParamsString = stringifyUrlParams(urlParams) || '';

// TODO: This fixed bug where side of body was not being cleared when condition was edited which could result in 'Asthma, right'
// However, with this fix, when user doesn't change condition, side of body is cleared which could confuse users
formData.sideOfBody = undefined;

return hasSideOfBody(formData, index)
? helpers.navForwardKeepUrlParams(props)
: goPath(`new-conditions/${index}/date${urlParamsString}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ export const createTitle = (defaultTitle, editTitle) => {
return defaultTitle;
};

export const hasSideOfBody = (formData, index) => {
const condition = formData?.newConditions
? formData.newConditions[index]?.condition
: formData.condition;

const conditionObject = conditionObjects.find(
conditionObj => conditionObj.option === condition,
);

return conditionObject ? conditionObject.sideOfBody : false;
};

const createCauseDescriptions = item => {
return {
NEW: 'Caused by an injury or exposure during my service.',
Expand All @@ -31,18 +43,6 @@ const causeFollowUpChecks = {
VA: item => !item?.vaMistreatmentDescription || !item?.vaMistreatmentLocation,
};

export const hasSideOfBody = (formData, index) => {
const condition = formData?.newConditions
? formData.newConditions[index]?.condition
: formData.condition;

const conditionObject = conditionObjects.find(
conditionObj => conditionObj.option === condition,
);

return conditionObject ? conditionObject.sideOfBody : false;
};

// Different than lodash _capitalize because does not make rest of string lowercase which would break acronyms
const capitalizeFirstLetter = string => {
return string?.charAt(0).toUpperCase() + string?.slice(1);
Expand All @@ -68,7 +68,6 @@ export const arrayBuilderOptions = {
required: true,
isItemIncomplete: item =>
!item?.condition ||
(hasSideOfBody(item) && !item?.sideOfBody) ||
!item?.date ||
!item?.cause ||
(causeFollowUpChecks[item.cause] && causeFollowUpChecks[item.cause](item)),
Expand Down

0 comments on commit 6dbc6cd

Please sign in to comment.