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

Convert AddressForm From Angular to React #969

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

reldredge71
Copy link
Contributor

@reldredge71 reldredge71 commented Mar 9, 2022

Here is what I have so far for converting the AddressForm component into React. Right now this is being inserted into the CreditCardForm Angular component, but it shouldn't be too difficult to replace the Angular AddressForm throughout the app.
As a follow-up to this work, I would like to also:

  • Create a GraphQL proxy of the Geographies API service
  • Continue building out other components related to Payment Methods
  • Create unit tests for React components

Copy link
Contributor

@wrandall22 wrandall22 left a comment

Choose a reason for hiding this comment

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

Looks like translations are still to be figured out

<span>{error}</span>
{ retry && (
<button
id="retryButton"
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this work when there are multiples on the same page? Won't the ids clash? This might need to be overwrite-able.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, this might have to be more dynamic to account for multiple instances.

value,
error,
}: TextInputProps) => (
<div className={`form-group${required && ' is-required' || ''}${error && ' has-error' || ''}`}>
Copy link
Contributor

Choose a reason for hiding this comment

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

This structure isn't always in place for text inputs. What's the best way to build a different structure when we need it? (e.g. personalOptionsModal.tpl.html)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could maybe remove this wrapping div from here, and create a wrapper component that will only be used for AddressForm text inputs.

{ title && <label>{title}</label> }
<input
type={type}
className="form-control form-control-subtle"
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these overridable? Not all text inputs have form-control-subtle, for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I could create an optional prop that overrides the input className value.

src/common/components/addressForm/addressForm.react.tsx Outdated Show resolved Hide resolved
<CountrySelect
addressDisabled={addressDisabled}
countries={countries.map(country => ({ name: country.name, displayName: country['display-name']}))}
onChange={handleChange}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should call refreshRegions I think. Not seeing how that is being done here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that too, I'll push something that should address that.

country: Yup.string()
.required('You must select a country'),
streetAddress: Yup.string()
.max(200, 'This field cannot be longer than 200 characters')
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this use the maxLength property instead of hard-coded 200?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think the maxLength property on the input itself is accessible in this scope.

What I've also noticed is that setting maxLength on the input field prevents the user from entering any more characters than that limit. So I don't think this error will even show up at all. I think the input on its own does a good job of preventing the max length from being exceeded.

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