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

feat(company data): improved white space handling and update identifier error messages #210

Conversation

typecastcloud
Copy link
Contributor

@typecastcloud typecastcloud commented Jul 9, 2024

Description

  1. Move trimming to onBlur and save.
  2. Update error messages for changes to pattern introduced in PR fix(pattern validation): Prevent wrong white spaces in business data #196.
    See: https://github.com/Cofinity-X/entry-portal-frontend-registration/blob/main/src/types/Patterns.ts#L23-L45

Why

This improves usability and stability. Handling by regex error is hard to understand when customer can't see the whitespace.

Issue

Refs: #190

Checklist

  • I have followed the contributing guidelines
  • I have performed IP checks for added or updated 3rd party libraries
  • I have created and linked IP issues or requested their creation by a committer
  • I have performed a self-review of my own code
  • I have successfully tested my changes locally
  • I have added tests that prove my changes work
  • I have checked that new and existing tests pass locally with my changes
  • I have commented my code, particularly in hard-to-understand areas

@typecastcloud typecastcloud requested review from oyo and jjeroch July 9, 2024 15:18
@evegufy
Copy link
Contributor

evegufy commented Jul 11, 2024

Hi @typecastcloud the pr is still set to draft, is that intended?

@typecastcloud
Copy link
Contributor Author

typecastcloud commented Jul 11, 2024

Hi @typecastcloud the pr is still set to draft, is that intended?

Hi @evegufy, last time @oyo merged before all questions were resolved. I can set this to ready for review now.

@typecastcloud typecastcloud marked this pull request as ready for review July 11, 2024 11:11
Changes to patterns introduced in PR eclipse-tractusx#196 were not yet included in error messages.
@typecastcloud
Copy link
Contributor Author

@oyo @evegufy ready for review

@typecastcloud typecastcloud self-assigned this Jul 11, 2024
@evegufy
Copy link
Contributor

evegufy commented Jul 11, 2024

@typecastcloud could you please update the pr title to something like: feat: improve white space handling and update error messages

@typecastcloud typecastcloud changed the title feat(company data): improved white space handling for company data feat(company data): improved white space handling and update identifier error message Jul 11, 2024
@typecastcloud typecastcloud changed the title feat(company data): improved white space handling and update identifier error message feat(company data): improved white space handling and update identifier error messages Jul 11, 2024
Copy link
Contributor

@oyo oyo left a comment

Choose a reason for hiding this comment

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

approved - but just a few thoughts in the comments

@@ -206,7 +206,7 @@ export const CompanyDataCax = () => {
}

const onSearchChange = (expr: string) => {
if (isBPN(expr)) {
if (isBPN(expr?.trim())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if we follow the discussed convention to always trim any input value I think it's better to do the trim inside the isBPN (and all other similar) functions so the code here would be better readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would be unexpected behavior for isXYZ functions imho. You check a value against REGEX. Trimming here is only valid because we take care of white spaces somewhere else.

Copy link
Contributor

Choose a reason for hiding this comment

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

okay - there are different ways to solve that. Anyway the trim has to go somewhere. Thinking about different input fields the question becomes more generic and tricky anyway: for example let's consider spaces inside some values like IBAN or phone numbers and how the system should deal with those. From a user perspective i guess it is less annoying if the system automatically parses and reformats values instead of showing an error like when pasting IBANs, phone numbers, etc. which are common to be written with spaces.

@@ -222,7 +222,7 @@ export const CompanyDataCax = () => {
const validateLegalEntity = (value: string) => {
setLegalEntity(value)

if (!Patterns.legalEntityPattern.test(value)) {
if (!Patterns.legalEntityPattern.test(value?.trim())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

personally I'd prefer to replace all the Patterns.xyz.test(value) with isXYZ - here isLegalEntity just like isBPN above. Makes the code more readable.

@evegufy evegufy merged commit 6f1f8c6 into eclipse-tractusx:main Jul 12, 2024
10 checks passed
shubhamv-ss pushed a commit to shubhamv-ss/portal-frontend-registration that referenced this pull request Aug 1, 2024
…er error messages (eclipse-tractusx#210)

* feat(company data): improved white space handling for company data

Move trimming to onBlur and save.

Refs: eclipse-tractusx#190

* Update error messages for identifiers.

Changes to patterns introduced in PR eclipse-tractusx#196 were not yet included in error messages.
shubhamv-ss pushed a commit to shubhamv-ss/portal-frontend-registration that referenced this pull request Aug 8, 2024
…er error messages (eclipse-tractusx#210)

* feat(company data): improved white space handling for company data

Move trimming to onBlur and save.

Refs: eclipse-tractusx#190

* Update error messages for identifiers.

Changes to patterns introduced in PR eclipse-tractusx#196 were not yet included in error messages.
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.

3 participants