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

fix(@aws-amplify/ui-component) - formField phone_number compose #5622

Merged
merged 1 commit into from Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -65,7 +65,7 @@ export class AmplifyForgotPassword {
{
type: 'email',
required: true,
handleInputChange: this.handleFormFieldInput('email'),
handleInputChange: this.handleFormFieldInputChange('email'),
inputProps: {
'data-test': 'forgot-password-email-input',
},
Expand All @@ -77,7 +77,7 @@ export class AmplifyForgotPassword {
{
type: 'phone_number',
required: true,
handleInputChange: this.handleFormFieldInput('phone_number'),
handleInputChange: this.handleFormFieldInputChange('phone_number'),
inputProps: {
'data-test': 'forgot-password-phone-number-input',
},
Expand All @@ -90,7 +90,7 @@ export class AmplifyForgotPassword {
{
type: 'username',
required: true,
handleInputChange: this.handleFormFieldInput('username'),
handleInputChange: this.handleFormFieldInputChange('username'),
inputProps: {
'data-test': 'forgot-password-username-input',
},
Expand All @@ -107,7 +107,7 @@ export class AmplifyForgotPassword {
}
}

private handleFormFieldInput(fieldType) {
private handleFormFieldInputChange(fieldType) {
switch (fieldType) {
case 'username':
case 'email':
Expand All @@ -128,10 +128,7 @@ export class AmplifyForgotPassword {
: (event, cb) => {
cb(event);
};
const callback =
field.type === 'phone_number'
? event => (this.forgotPasswordAttrs.userInput = event.target.value)
: this.handleFormFieldInput(field.type);
const callback = this.handleFormFieldInputChange(field.type);
fnToCall(event, callback.bind(this));
}

Expand Down Expand Up @@ -177,15 +174,15 @@ export class AmplifyForgotPassword {
{
type: 'code',
required: true,
handleInputChange: this.handleFormFieldInput('code'),
handleInputChange: this.handleFormFieldInputChange('code'),
inputProps: {
'data-test': 'forgot-password-code-input',
},
},
{
type: 'password',
required: true,
handleInputChange: this.handleFormFieldInput('password'),
handleInputChange: this.handleFormFieldInputChange('password'),
label: 'New password',
placeholder: 'Enter your new password',
},
Expand Down
Expand Up @@ -80,7 +80,7 @@ export class AmplifySignIn {
password: '',
};

private handleFormFieldInput(fieldType) {
private handleFormFieldInputChange(fieldType) {
switch (fieldType) {
case 'username':
case 'email':
Expand All @@ -98,10 +98,7 @@ export class AmplifySignIn {
: (event, cb) => {
cb(event);
};
const callback =
field.type === 'phone_number'
? event => (this.signInAttributes.userInput = event.target.value)
: this.handleFormFieldInput(field.type);
const callback = this.handleFormFieldInputChange(field.type);
fnToCall(event, callback.bind(this));
}

Expand Down Expand Up @@ -200,7 +197,7 @@ export class AmplifySignIn {
formFieldInputs.push({
type: 'email',
required: true,
handleInputChange: this.handleFormFieldInput('email'),
handleInputChange: this.handleFormFieldInputChange('email'),
inputProps: {
'data-test': 'sign-in-email-input',
},
Expand All @@ -210,7 +207,7 @@ export class AmplifySignIn {
formFieldInputs.push({
type: 'phone_number',
required: true,
handleInputChange: this.handleFormFieldInput('phone_number'),
handleInputChange: this.handleFormFieldInputChange('phone_number'),
inputProps: {
'data-test': 'sign-in-phone-number-input',
},
Expand All @@ -221,7 +218,7 @@ export class AmplifySignIn {
formFieldInputs.push({
type: 'username',
required: true,
handleInputChange: this.handleFormFieldInput('username'),
handleInputChange: this.handleFormFieldInputChange('username'),
inputProps: {
'data-test': 'sign-in-username-input',
},
Expand All @@ -244,7 +241,7 @@ export class AmplifySignIn {
</div>
),
required: true,
handleInputChange: this.handleFormFieldInput('password'),
handleInputChange: this.handleFormFieldInputChange('password'),
inputProps: {
'data-test': 'sign-in-password-input',
},
Expand Down
Expand Up @@ -97,10 +97,7 @@ export class AmplifySignUp {
: (event, cb) => {
cb(event);
};
const callback =
field.type === 'phone_number'
? event => (this.signUpAttributes.attributes.phone_number = event.target.value)
: this.handleFormFieldInputChange(field.type);
const callback = this.handleFormFieldInputChange(field.type);
fnToCall(event, callback.bind(this));
}

Expand Down