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

CustomErrorMessage and removeMaskDocument props #252

Open
wants to merge 5 commits into
base: 1.x
Choose a base branch
from

Conversation

TiagoGranelli
Copy link

@TiagoGranelli TiagoGranelli commented Feb 8, 2022

What did you change? *

Added two new properties that receive values from the store-theme, similar to the blockDocument prop

The first is the customErrorMessage property, which is used to change the default generic message in the handleSubmit in profileFormBox and receives a string

The second is the removeMaskDocument property, which is used to remove the mask from the document field before sending it to the customer table, it receives a boolean value

Validations were also added for these properties, making them optional and not interfering with the default behavior that stores currently use

Why? *

We needed a way to prevent users from entering a duplicate document (which is already registered in another account)

To reach this goal, we went through several problems. The first was a known issue "Unable to filter by text field", where it is suggested to change the document field to a Varchar 750, but to do that we would need to delete our field and create a new one, losing all our data.
We tried an alternative way through safeData, we were not successful either.

The only method that worked almost perfectly was to create an alternate key for the document field. \0/
Unfortunately the message that currently appears is very generic and it is not clear to the user which field the problem is in, so we made the customErrorMessage prop.
We added the removeMaskDocument prop because letting the mask mess up our MasterData, and this is a failure that cannot pass, since we use the document as an alternate key and there could be scenarios with documents like this: "999.999.999-99" and "99999999999"

How to test it? *

Testing removeMaskDocument prop

  1. link this branch from the MyAccount repository and this one CustomErrorMessage  my-account-commons#60 from the MyAccount Commons repository
  2. pass the prop through the store-theme
  3. access MyAccount
  4. edit your profile data and save a document, it should appear like this after saving:
    image

Testing customErrorMessage

  1. link this branch from the MyAccount repository and this one CustomErrorMessage  my-account-commons#60 from the MyAccount Commons repository
  2. pass the prop through the store-theme
  3. add document field as alternate key in MasterData
  4. access MyAccount
  5. access MyAccount with another account
  6. try using the same document you used in another account

Related to / Depends on?

depend on:
the custom Error Message prop was used here: vtex-apps/my-account-commons#60

does not depend, but is related... I would be grateful if you could review:
vtex/profile-form#143

Types of changes *

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical improvements

@vtex-io-ci-cd
Copy link
Contributor

vtex-io-ci-cd bot commented Feb 8, 2022

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)

  • Minor (backwards-compatible functionality)

  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

@vtex-io-docs-bot
Copy link

Beep boop 🤖

Thank you so much for keeping our documentation up-to-date ❤️

@TiagoGranelli TiagoGranelli changed the base branch from master to 1.x February 8, 2022 17:04
@TiagoGranelli TiagoGranelli marked this pull request as ready for review February 8, 2022 22:43
@TiagoGranelli TiagoGranelli changed the title Feature/document validate CustomErrorMessage and removeMaskDocument props Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants