Skip to content

Commit

Permalink
update formField phone number cb (#5622)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashika01 committed Apr 29, 2020
1 parent 9b05aee commit f5db38d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
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

0 comments on commit f5db38d

Please sign in to comment.