-
Notifications
You must be signed in to change notification settings - Fork 24
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
PSP-9471: UI UX Clean Up - Contact – Manage Contacts: Allow to save contacts that are set as Inactive without Contact Methods #4552
Changes from 6 commits
63df019
7c580e6
eef09b5
1f6c9bf
18d9c21
914c15e
24572ab
991b36d
acb5b41
7f3641e
a51985c
799ada0
e06fc4c
350ae84
c49de85
b5b7326
ce0c73f
6da46e7
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 |
---|---|---|
|
@@ -79,6 +79,7 @@ const UpdatePersonComponent: React.FC< | |
> = ({ values, errors, touched, dirty, submitForm, setFieldValue, isSubmitting }) => { | ||
const history = useHistory(); | ||
const { getOrganization } = useApiContacts(); | ||
const isPersonDisabled = getIn(values, 'isDisabled'); | ||
|
||
const personId = getIn(values, 'id'); | ||
const organizationId = getIn(values, 'organization.id'); | ||
|
@@ -90,6 +91,9 @@ const UpdatePersonComponent: React.FC< | |
}; | ||
|
||
const isContactMethodInvalid = useMemo(() => { | ||
if (isPersonDisabled === 'true') { | ||
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. one is a boolean, the right hand is a string. probably need to check the right type? |
||
return false; | ||
} | ||
return ( | ||
!!touched.phoneContactMethods && | ||
!!touched.emailContactMethods && | ||
|
@@ -98,7 +102,7 @@ const UpdatePersonComponent: React.FC< | |
!!touched.billingAddress?.streetAddress1) && | ||
getIn(errors, 'needsContactMethod') | ||
); | ||
}, [touched, errors]); | ||
}, [touched, errors, isPersonDisabled]); | ||
|
||
// update mailing address sub-form when "useOrganizationAddress" checkbox is toggled | ||
useEffect(() => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,9 +23,14 @@ export const onValidateOrganization = ( | |
const errors = {} as any; | ||
try { | ||
// combine yup schema validation with custom rules | ||
if (!hasEmail(values) && !hasPhoneNumber(values) && !hasAddress(values)) { | ||
if ( | ||
!hasEmail(values) && | ||
!hasPhoneNumber(values) && | ||
!hasAddress(values) && | ||
values.isDisabled === false | ||
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. the if (
... &&
(values.isDisabled === 'false' || values.isDisabled === false)
) {
...
} But the 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 agree, but I'll have to do a refactor on the logic we have now on contacts. I'll give it a go and update my PR. |
||
) { | ||
errors.needsContactMethod = | ||
'Contacts must have a minimum of one method of contact to be saved. (ex: email,phone or address)'; | ||
'Contacts must have a minimum of one method of contact to be saved. (ex: email, phone or address)'; | ||
} | ||
validateYupSchema(values, OrganizationValidationSchema, true, { | ||
otherCountry: otherCountryId, | ||
|
@@ -40,9 +45,14 @@ export const onValidatePerson = (values: IEditablePersonForm, otherCountryId?: s | |
const errors = {} as any; | ||
try { | ||
// combine yup schema validation with custom rules | ||
if (!hasEmail(values) && !hasPhoneNumber(values) && !hasAddress(values)) { | ||
if ( | ||
!hasEmail(values) && | ||
!hasPhoneNumber(values) && | ||
!hasAddress(values) && | ||
(values.isDisabled === 'false' || values.isDisabled === false) | ||
) { | ||
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. same comment here re: checking for the string representation value |
||
errors.needsContactMethod = | ||
'Contacts must have a minimum of one method of contact to be saved. (ex: email,phone or address)'; | ||
'Contacts must have a minimum of one method of contact to be saved. (ex: email, phone or address)'; | ||
} | ||
validateYupSchema(values, PersonValidationSchema, true, { otherCountry: otherCountryId }); | ||
|
||
|
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.
not sure we are using these 2 imports in the test file here...
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.
Let me check and will update my PR