Skip to content
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

Merged
merged 18 commits into from
Dec 30, 2024

Conversation

stairaku
Copy link
Collaborator

No description provided.

@stairaku stairaku added enhancement New feature or request 5.7 labels Dec 24, 2024
@stairaku stairaku self-assigned this Dec 24, 2024
Comment on lines 19 to 20
findByText,
queryByText,
Copy link
Collaborator

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...

Copy link
Collaborator Author

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

!hasEmail(values) &&
!hasPhoneNumber(values) &&
!hasAddress(values) &&
values.isDisabled === false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the validatePerson() method below has the following logic:

if (
   ... &&
   (values.isDisabled === 'false' || values.isDisabled === false)
) {
...
}

But the validateOrganization() has a different logic: values.isDisabled === false
wouldn't it make sense to have the same check for disabled for person and organization?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/4552

1 similar comment
Copy link
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/4552

Copy link
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/4552

1 similar comment
Copy link
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/4552

Copy link
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/4552

Copy link
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/4552


const onCancel = () => {
history.push(`/contact/O${organizationId}`);
};

const isContactMethodInvalid = useMemo(() => {
if (isOrganizationDisabled === 'true') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels weird that this should be a boolean but the rigth hand operator is a string?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because Formik values for dropdowns (SELECT input field) are always strings. We have several utility methods to convert from "stringy" booleans to "real" booleans

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me try with with booleans. I see the tranform method when it is saved and send to the API but not before that.

@@ -90,6 +91,9 @@ const UpdatePersonComponent: React.FC<
};

const isContactMethodInvalid = useMemo(() => {
if (isPersonDisabled === 'true') {
Copy link
Collaborator

Choose a reason for hiding this comment

The 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?

@@ -183,7 +183,7 @@ export class IEditableOrganizationForm {
alias?: string;
incorporationNumber?: string;
comment?: string;
isDisabled: boolean;
isDisabled: string | boolean = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field should always be string. Yes, it will contain string values of "true" or "false" but those are string representations of boolean values. We need this field to be a string because it is used in Formik to render the "disabled" dropdown (SELECT input) which always takes string values (so no boolean values are accepted for select)

The pattern we follow is to use the utility method booleanToString() to convert from the API value (which is boolean) into the string representation that the dropdown can render. We do this in the fromApi() method.

Then in the corresponding toApi() method we call the "inverse" function - stringToBoolean() to convert the string representation from formik into the API boolean value.

From what I see the code in contact is doing this half-way. The "toApi" is correctly converting from string to boolean. BUT the "fromApi" is missing the conversion from a boolean. The solution is to make "isDisabled" here a string and follow the pattern from "UpdatePropertyDetailsFormModel.ts" below:

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the comments and lead me to a better solution. I'm updating this PR with the suggested changes. Thank you!!!!

Comment on lines 30 to 31
(values.isDisabled === 'false' || values.isDisabled === false)
) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you follow the pattern I described in my other comment, then here you would only need to check for the string "false"

Comment on lines 52 to 53
(values.isDisabled === 'false' || values.isDisabled === false)
) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment here re: checking for the string representation value

Copy link
Collaborator

@asanchezr asanchezr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see comments

Copy link
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/4552

Copy link
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/4552

Copy link
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/4552

@stairaku stairaku merged commit 102f2f4 into bcgov:dev Dec 30, 2024
8 checks passed
Copy link
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/4552

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.7 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants