Skip to content

Commit

Permalink
fix(aws-amplify-react-native): set Resend Code enabled/disabled from …
Browse files Browse the repository at this point in the history
…current username value (aws-amplify#9767)
  • Loading branch information
bensewell authored Jun 1, 2022
1 parent 9e3792f commit 94813a9
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions packages/aws-amplify-react-native/src/Auth/ConfirmSignUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,10 @@
import React from 'react';
import { View } from 'react-native';
import { Auth, I18n, Logger } from 'aws-amplify';
import {
FormField,
LinkCell,
Header,
ErrorRow,
AmplifyButton,
SignedOutMessage,
Wrapper,
} from '../AmplifyUI';
import { FormField, LinkCell, Header, ErrorRow, AmplifyButton, SignedOutMessage, Wrapper } from '../AmplifyUI';
import AuthPiece, { IAuthPieceProps, IAuthPieceState } from './AuthPiece';
import TEST_ID from '../AmplifyTestIDs';
import { setTestId } from '../Utils'
import { setTestId } from '../Utils';

const logger = new Logger('ConfirmSignUp');

Expand All @@ -35,10 +27,7 @@ interface IConfirmSignUpState extends IAuthPieceState {
code: string | null;
}

export default class ConfirmSignUp extends AuthPiece<
IConfirmSignUpProps,
IConfirmSignUpState
> {
export default class ConfirmSignUp extends AuthPiece<IConfirmSignUpProps, IConfirmSignUpState> {
constructor(props: IConfirmSignUpProps) {
super(props);

Expand All @@ -58,16 +47,16 @@ export default class ConfirmSignUp extends AuthPiece<
const username = this.getUsernameFromInput();
logger.debug('Confirm Sign Up for ' + username);
Auth.confirmSignUp(username, code)
.then(data => this.changeState('signedUp'))
.catch(err => this.error(err));
.then((data) => this.changeState('signedUp'))
.catch((err) => this.error(err));
}

resend() {
const username = this.getUsernameFromInput();
logger.debug('Resend Sign Up for ' + username);
Auth.resendSignUp(username)
.then(() => logger.debug('code sent'))
.catch(err => this.error(err));
.catch((err) => this.error(err));
}

static getDerivedStateFromProps(props, state) {
Expand All @@ -93,7 +82,7 @@ export default class ConfirmSignUp extends AuthPiece<
{this.renderUsernameField(theme)}
<FormField
theme={theme}
onChangeText={text => this.setState({ code: text })}
onChangeText={(text) => this.setState({ code: text })}
label={I18n.get('Confirmation Code')}
placeholder={I18n.get('Enter your confirmation code')}
required={true}
Expand All @@ -111,7 +100,7 @@ export default class ConfirmSignUp extends AuthPiece<
<LinkCell
theme={theme}
onPress={this.resend}
disabled={!this.state.username}
disabled={!username}
testID={TEST_ID.AUTH.RESEND_CODE_BUTTON}
>
{I18n.get('Resend code')}
Expand Down

0 comments on commit 94813a9

Please sign in to comment.