-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bug on hearing details page where email error messages weren't being displayed #15044
Changes from all commits
35aeac1
8863470
494f0b5
172816f
76f04da
37f1cbc
d5adc7e
fa94551
ce55e75
5b8cf1c
7a7eeac
59fcf2a
513f66b
c9184e0
c77bece
0f4ae82
e6d6357
6e173c8
45ebeef
d943588
4c82a19
d98fe9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,9 +95,10 @@ export const ReadOnlyEmails = ({ | |
{virtualHearing.appellantEmail} | ||
</p> | ||
)} | ||
{(representativeEmailEdited || showAllEmails) && ( | ||
{(virtualHearing.representativeEmail && | ||
(representativeEmailEdited || showAllEmails)) && ( | ||
<p> | ||
<strong>Representative Email</strong> | ||
<strong>POA/Representative Email</strong> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes this label match the pop-up that shows for formerly central virtual hearings |
||
<br /> | ||
{virtualHearing.representativeEmail} | ||
</p> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ export const VirtualHearingFields = ({ | |
requestType, | ||
defaultAppellantTz, | ||
defaultRepresentativeTz, | ||
initialRepresentativeTz, | ||
virtualHearing, | ||
readOnly, | ||
update, | ||
|
@@ -55,7 +56,7 @@ export const VirtualHearingFields = ({ | |
<div className="usa-width-one-third"> | ||
<Timezone | ||
errorMessage={errors?.representativeTz} | ||
required={virtualHearing?.representativeEmail} | ||
required={Boolean(virtualHearing?.representativeEmail)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes a console |
||
value={virtualHearing?.representativeTz || defaultRepresentativeTz} | ||
onChange={(representativeTz) => update('virtualHearing', { representativeTz })} | ||
readOnly={readOnly || !virtualHearing?.representativeEmail} | ||
|
@@ -72,7 +73,17 @@ export const VirtualHearingFields = ({ | |
emailType="representativeEmail" | ||
email={virtualHearing?.representativeEmail} | ||
error={errors?.representativeEmail} | ||
update={update} | ||
update={(key, value) => { | ||
// Switch the representative timezone back to the initial value if the | ||
// representative email is changed to null. This should prevent `deepDiff`` | ||
// from trying to send any changes to the representative timezone if the | ||
// representative email is being removed. | ||
if (!value.representativeEmail) { | ||
value.representativeTz = initialRepresentativeTz; | ||
} | ||
|
||
update(key, value); | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
|
@@ -114,4 +125,5 @@ VirtualHearingFields.propTypes = { | |
errors: PropTypes.object, | ||
defaultAppellantTz: PropTypes.string, | ||
defaultRepresentativeTz: PropTypes.string, | ||
initialRepresentativeTz: PropTypes.string, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,11 +44,15 @@ const formatHearing = (hearing) => ({ | |
}); | ||
|
||
export const SET_UPDATED = 'setUpdated'; | ||
const setUpdated = (state, value) => ({ | ||
...state, | ||
hearing: { ...state.hearing, ...value }, | ||
formsUpdated: !isEmpty(deepDiff(state.initialHearing, { ...state.hearing, ...value })) | ||
}); | ||
const setUpdated = (state, value) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refactoring this way doesnt change the logic at all, I think we should leave this as is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO the refactor makes it a bit easier to understand what's going on. Previously, the expression which represents the merged new hearing, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refactoring this way also adds mutation to the function because instead of using the splat operator to assign the formsUpdated value, you are first creating an object and then assigning the value. I really think we should leave this as is because it follows functional programming guidelines of not-mutating There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I generally agree with not-mutating, but I don't see the downside here because we are mutating a local that's declared and instantiated inside the function. I could see it being a bigger problem if we were mutating the field of an argument that was being passed in. One alternative way of doing this could be:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That refactor is better because it does not mutate. While I don't agree that this makes the code easier to read IMO it actually makes it more difficult, this does follow guidelines so I will concede |
||
const newHearing = { ...state.hearing, ...value }; | ||
|
||
return { | ||
...state, | ||
hearing: newHearing, | ||
formsUpdated: !isEmpty(deepDiff(state.initialHearing, newHearing)) | ||
}; | ||
}; | ||
|
||
// Full reset of everything. | ||
export const RESET_HEARING = 'reset'; | ||
|
@@ -62,22 +66,26 @@ const reset = (state, hearing) => ({ | |
// Resets only the `virtualHearing` field, and should preserve all other fields. | ||
export const RESET_VIRTUAL_HEARING = 'resetVirtualHearing'; | ||
const resetVirtualHearing = (state, virtualHearing) => { | ||
const newHearing = { | ||
...state.hearing, | ||
virtualHearing: { | ||
...(state.hearing?.virtualHearing || {}), | ||
...virtualHearing | ||
} | ||
}; | ||
const newInitialHearing = { | ||
...state.initialHearing, | ||
virtualHearing: { | ||
...(state.initialHearing?.virtualHearing || {}), | ||
...virtualHearing | ||
} | ||
}; | ||
|
||
return { | ||
...state, | ||
initialHearing: { | ||
...state.initialHearing, | ||
virtualHearing: { | ||
...(state.initialHearing?.virtualHearing || {}), | ||
...virtualHearing | ||
} | ||
}, | ||
hearing: { | ||
...state.hearing, | ||
virtualHearing: { | ||
...(state.hearing?.virtualHearing || {}), | ||
...virtualHearing | ||
} | ||
} | ||
initialHearing: newInitialHearing, | ||
hearing: newHearing, | ||
formsUpdated: !isEmpty(deepDiff(newInitialHearing, newHearing)) | ||
}; | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15321,7 +15321,7 @@ exports[`Fields Matches snapshot with default props 1`] = ` | |
name="representativeTz" | ||
onChange={[Function]} | ||
readOnly={false} | ||
required="[email protected]" | ||
required={true} | ||
time="08:15" | ||
value={null} | ||
> | ||
|
@@ -16098,7 +16098,7 @@ exports[`Fields Matches snapshot with default props 1`] = ` | |
} | ||
placeholder="Select a timezone" | ||
readOnly={false} | ||
required="[email protected]" | ||
required={true} | ||
strongLabel={true} | ||
styling={ | ||
Object { | ||
|
@@ -30334,6 +30334,7 @@ exports[`Fields Matches snapshot with default props 1`] = ` | |
email="[email protected]" | ||
emailType="representativeEmail" | ||
label="POA/Representative Email" | ||
update={[Function]} | ||
> | ||
<TextField | ||
className={ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,7 +154,7 @@ SAN FRANCISCO, CA 94103 | |
name="POA/Representative Timezone" | ||
onChange={[Function]} | ||
readOnly={false} | ||
required="[email protected]" | ||
required={true} | ||
time="06:00" | ||
value={null} | ||
> | ||
|
@@ -930,7 +930,7 @@ SAN FRANCISCO, CA 94103 | |
} | ||
placeholder="Select a timezone" | ||
readOnly={false} | ||
required="[email protected]" | ||
required={true} | ||
strongLabel={true} | ||
styling={ | ||
Object { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small fix so this returns
false
instead ofnil
ifadvance_on_docket_motion_attributes == nil