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

Replace phone number field in sign up flow #5894

Open
justinmakaila opened this issue Oct 11, 2024 · 7 comments
Open

Replace phone number field in sign up flow #5894

justinmakaila opened this issue Oct 11, 2024 · 7 comments
Labels
Authenticator An issue or a feature-request for an Authenticator UI Component feature-request Request a new feature

Comments

@justinmakaila
Copy link

My cognito pool collects phone numbers at sign up. The Authenticator UI in react allows for modifying the phone number field to allow dropdown selection of country codes, but I can't seem to fine the equivalent in react-native. I don't want to rely on users putting in the '+1' manually. How can I manually override the component that is rendered in the form fields to replace it with a masked field or a field that provides a drop down for country codes?

@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending response from an Amplify UI maintainer labels Oct 11, 2024
@justinmakaila
Copy link
Author

I'd love to get this component piped in there:

https://www.npmjs.com/package/react-native-phone-number-input

@justinmakaila
Copy link
Author

justinmakaila commented Oct 11, 2024

Here's my current workaround to support US country codes only:

    <Authenticator.SignUp
      {...props}
      fields={normalizedFields}
      handleSubmit={values => {
        const normalizedPhoneNumber = values.country_code + values.phone_number
        const parsedPhoneNumber = parsePhoneNumber(normalizedPhoneNumber, 'US')
        const internationalPhoneNumber = parsedPhoneNumber.format('E.164')

        const normalizedValues = {
          ...values,
          country_code: internationalPhoneNumber.substring(0, 3),
          phone_number: internationalPhoneNumber.substring(3),
        }

        props.handleSubmit(normalizedValues)
      }}
    />

parsePhoneNumber() is from libphonenumber-js

@reesscot
Copy link
Contributor

Have you taken a look at the Subcomponent override slots?
https://ui.docs.amplify.aws/react-native/connected-components/authenticator/customization#subcomponent-override-slots

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify UI maintainer label Oct 11, 2024
@cwomack cwomack added question General question pending-community-response Issue is pending response from the issue requestor or other community members and removed pending-triage Issue is pending triage labels Oct 11, 2024
@justinmakaila
Copy link
Author

@reesscot i have but that doesn't let me replace the independent fields. Its always a TextInput component and I can't change or format the values with the onChange and "set state" bits due to the "black box" of the useFieldValues hook

@github-actions github-actions bot added pending-maintainer-response Issue is pending response from an Amplify UI maintainer and removed pending-community-response Issue is pending response from the issue requestor or other community members labels Oct 11, 2024
@justinmakaila
Copy link
Author

Im using the subcomponent replacement to customize the handleSubmit functions

@reesscot
Copy link
Contributor

Hi @justinmakaila,

The API doesn't currently support replacing individual fields, you have to replace the whole SignIn screen if you want to customize it. I'm converting this to a feature request for consideration on our roadmap.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify UI maintainer label Oct 15, 2024
@reesscot reesscot added feature-request Request a new feature Authenticator An issue or a feature-request for an Authenticator UI Component and removed question General question labels Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Authenticator An issue or a feature-request for an Authenticator UI Component feature-request Request a new feature
Projects
None yet
Development

No branches or pull requests

4 participants
@justinmakaila @reesscot @cwomack and others