Skip to content

Commit

Permalink
Use Prettier and format all the things
Browse files Browse the repository at this point in the history
  • Loading branch information
samouri committed Mar 23, 2017
1 parent ee53e49 commit 737e1b5
Show file tree
Hide file tree
Showing 3,423 changed files with 319,886 additions and 303,463 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
96 changes: 48 additions & 48 deletions client/account-recovery/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,73 +17,73 @@ import TransactionIdForm from 'account-recovery/reset-password/transaction-id-fo
import ResetPasswordConfirmForm from 'account-recovery/reset-password/reset-password-confirm-form';
import { getCurrentUser } from 'state/current-user/selectors';

export function lostPassword( context, next ) {
context.primary = <LostPasswordPage basePath={ context.path } />;
next();
export function lostPassword(context, next) {
context.primary = <LostPasswordPage basePath={context.path} />;
next();
}

export function forgotUsername( context, next ) {
context.primary = <ForgotUsernamePage basePath={ context.path } />;
next();
export function forgotUsername(context, next) {
context.primary = <ForgotUsernamePage basePath={context.path} />;
next();
}

export function resetPassword( context, next ) {
context.primary = (
<ResetPasswordPage basePath={ context.path }>
<ResetPasswordForm />
</ResetPasswordPage>
);
export function resetPassword(context, next) {
context.primary = (
<ResetPasswordPage basePath={context.path}>
<ResetPasswordForm />
</ResetPasswordPage>
);

next();
next();
}

export function resetPasswordSmsForm( context, next ) {
context.primary = (
<ResetPasswordPage basePath={ context.path }>
<ResetPasswordSmsForm />
</ResetPasswordPage>
);
export function resetPasswordSmsForm(context, next) {
context.primary = (
<ResetPasswordPage basePath={context.path}>
<ResetPasswordSmsForm />
</ResetPasswordPage>
);

next();
next();
}

export function resetPasswordEmailForm( context, next ) {
context.primary = (
<ResetPasswordPage basePath={ context.path }>
<ResetPasswordEmailForm />
</ResetPasswordPage>
);
export function resetPasswordEmailForm(context, next) {
context.primary = (
<ResetPasswordPage basePath={context.path}>
<ResetPasswordEmailForm />
</ResetPasswordPage>
);

next();
next();
}

export function resetPasswordByTransactionId( context, next ) {
context.primary = (
<ResetPasswordPage basePath={ context.path }>
<TransactionIdForm />
</ResetPasswordPage>
);
export function resetPasswordByTransactionId(context, next) {
context.primary = (
<ResetPasswordPage basePath={context.path}>
<TransactionIdForm />
</ResetPasswordPage>
);

next();
next();
}

export function resetPasswordConfirmForm( context, next ) {
context.primary = (
<ResetPasswordPage basePath={ context.path }>
<ResetPasswordConfirmForm />
</ResetPasswordPage>
);
export function resetPasswordConfirmForm(context, next) {
context.primary = (
<ResetPasswordPage basePath={context.path}>
<ResetPasswordConfirmForm />
</ResetPasswordPage>
);

next();
next();
}

export function redirectLoggedIn( context, next ) {
const currentUser = getCurrentUser( context.store.getState() );
export function redirectLoggedIn(context, next) {
const currentUser = getCurrentUser(context.store.getState());

if ( currentUser ) {
page.redirect( '/' );
return;
}
if (currentUser) {
page.redirect('/');
return;
}

next();
next();
}
240 changes: 124 additions & 116 deletions client/account-recovery/forgot-username/forgot-username-form/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,131 +15,139 @@ import FormLabel from 'components/forms/form-label';
import FormInput from 'components/forms/form-text-input';

import {
fetchResetOptionsByNameAndUrl,
updatePasswordResetUserData,
fetchResetOptionsByNameAndUrl,
updatePasswordResetUserData,
} from 'state/account-recovery/reset/actions';

import {
isRequestingAccountRecoveryResetOptions,
getAccountRecoveryResetUserData,
getAccountRecoveryResetOptionsError,
isRequestingAccountRecoveryResetOptions,
getAccountRecoveryResetUserData,
getAccountRecoveryResetOptionsError,
} from 'state/selectors';

export class ForgotUsernameFormComponent extends Component {
submitForm = () => {
const { userData } = this.props;

this.props.fetchResetOptionsByNameAndUrl( userData.firstName, userData.lastName, userData.url );
};

firstNameUpdated = ( event ) => {
this.props.updatePasswordResetUserData( { firstName: event.target.value } );
};

lastNameUpdated = ( event ) => {
this.props.updatePasswordResetUserData( { lastName: event.target.value } );
};

siteUrlUpdated = ( event ) => {
this.props.updatePasswordResetUserData( { url: event.target.value } );
};

getErrorMessage = ( requestError ) => {
const { translate } = this.props;

if ( ! requestError ) {
return '';
}

if ( requestError.statusCode === 404 ) {
return translate( "We're not able to find an account matching that information. " +
'Double-check your spelling, or try another name or URL.' );
}

return translate( "We've encountered some technical issues. Please try again later." );
};

render() {
const {
translate,
userData,
isRequesting,
requestError,
} = this.props;

const {
firstName = '',
lastName = '',
url = '',
} = userData;

const isPrimaryButtonEnabled = firstName && lastName && url && ! isRequesting;

return (
<Card>
<h2 className="forgot-username-form__title">
{ translate( 'Forgot your username?' ) }
</h2>
<p>{ translate( 'Enter your full name and URL instead.' ) }</p>
<FormLabel>
{ translate( 'First Name' ) }
<FormInput
className="forgot-username-form__first-name-input"
onChange={ this.firstNameUpdated }
value={ firstName }
disabled={ isRequesting } />
</FormLabel>
<FormLabel>
{ translate( 'Last Name' ) }
<FormInput
className="forgot-username-form__last-name-input"
onChange={ this.lastNameUpdated }
value={ lastName }
disabled={ isRequesting } />
</FormLabel>
<FormLabel>
{ translate( "Your site's URL" ) }
<FormInput
className="forgot-username-form__site-url-input"
onChange={ this.siteUrlUpdated }
value={ url }
disabled={ isRequesting } />
</FormLabel>
{
requestError && (
<p className="forgot-username-form__error-message">
{ this.getErrorMessage( requestError ) }
</p> )
}
<Button
className="forgot-username-form__submit-button"
onClick={ this.submitForm }
disabled={ ! isPrimaryButtonEnabled }
primary>
{ translate( 'Continue' ) }
</Button>
</Card>
);
}
submitForm = () => {
const { userData } = this.props;

this.props.fetchResetOptionsByNameAndUrl(
userData.firstName,
userData.lastName,
userData.url
);
};

firstNameUpdated = event => {
this.props.updatePasswordResetUserData({ firstName: event.target.value });
};

lastNameUpdated = event => {
this.props.updatePasswordResetUserData({ lastName: event.target.value });
};

siteUrlUpdated = event => {
this.props.updatePasswordResetUserData({ url: event.target.value });
};

getErrorMessage = requestError => {
const { translate } = this.props;

if (!requestError) {
return '';
}

if (requestError.statusCode === 404) {
return translate(
"We're not able to find an account matching that information. " +
'Double-check your spelling, or try another name or URL.'
);
}

return translate("We've encountered some technical issues. Please try again later.");
};

render() {
const {
translate,
userData,
isRequesting,
requestError,
} = this.props;

const {
firstName = '',
lastName = '',
url = '',
} = userData;

const isPrimaryButtonEnabled = firstName && lastName && url && !isRequesting;

return (
<Card>
<h2 className="forgot-username-form__title">
{translate('Forgot your username?')}
</h2>
<p>{translate('Enter your full name and URL instead.')}</p>
<FormLabel>
{translate('First Name')}
<FormInput
className="forgot-username-form__first-name-input"
onChange={this.firstNameUpdated}
value={firstName}
disabled={isRequesting}
/>
</FormLabel>
<FormLabel>
{translate('Last Name')}
<FormInput
className="forgot-username-form__last-name-input"
onChange={this.lastNameUpdated}
value={lastName}
disabled={isRequesting}
/>
</FormLabel>
<FormLabel>
{translate("Your site's URL")}
<FormInput
className="forgot-username-form__site-url-input"
onChange={this.siteUrlUpdated}
value={url}
disabled={isRequesting}
/>
</FormLabel>
{requestError &&
<p className="forgot-username-form__error-message">
{this.getErrorMessage(requestError)}
</p>}
<Button
className="forgot-username-form__submit-button"
onClick={this.submitForm}
disabled={!isPrimaryButtonEnabled}
primary
>
{translate('Continue')}
</Button>
</Card>
);
}
}

ForgotUsernameFormComponent.defaultProps = {
isRequesting: false,
userData: {},
requestError: null,
translate: identity,
fetchResetOptionsByNameAndUrl: noop,
updatePasswordResetUserData: noop,
isRequesting: false,
userData: {},
requestError: null,
translate: identity,
fetchResetOptionsByNameAndUrl: noop,
updatePasswordResetUserData: noop,
};

export default connect(
( state ) => ( {
isRequesting: isRequestingAccountRecoveryResetOptions( state ),
userData: getAccountRecoveryResetUserData( state ),
requestError: getAccountRecoveryResetOptionsError( state ),
} ),
{
fetchResetOptionsByNameAndUrl,
updatePasswordResetUserData,
}
)( localize( ForgotUsernameFormComponent ) );
state => ({
isRequesting: isRequestingAccountRecoveryResetOptions(state),
userData: getAccountRecoveryResetUserData(state),
requestError: getAccountRecoveryResetOptionsError(state),
}),
{
fetchResetOptionsByNameAndUrl,
updatePasswordResetUserData,
}
)(localize(ForgotUsernameFormComponent));
Loading

0 comments on commit 737e1b5

Please sign in to comment.