Skip to content

Commit

Permalink
Cleanup, add "Enter"-listener to email input, relates to #66
Browse files Browse the repository at this point in the history
  • Loading branch information
tjjalava committed Aug 18, 2017
1 parent d2d463a commit 547326f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 2 additions & 6 deletions src/SizeMeApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SizeMeApp extends React.Component {
matchResult, selectedSize,
profiles, selectedProfile, setSelectedProfile,
measurementInputs,
onSignup, signupStatus,
onSignup,
product
} = this.props;

Expand Down Expand Up @@ -92,9 +92,7 @@ class SizeMeApp extends React.Component {
setSelectedProfile={setSelectedProfile}/>}
</div>
{measurementInputs && <SizeForm fields={measurementInputs} />}
{!loggedIn && currentMatch && <SignupBox onLogin={this.userLoggedIn}
onSignup={onSignup}
signupStatus={signupStatus}/>}
{!loggedIn && currentMatch && <SignupBox onSignup={onSignup}/>}
{resolved && !uiOptions.disableSizeGuide && <SizeGuide/>}
<LoginFrame id="login-frame" onLogin={this.userLoggedIn}/>
</div>
Expand All @@ -118,7 +116,6 @@ SizeMeApp.propTypes = {
getProfiles: PropTypes.func.isRequired,
getProduct: PropTypes.func.isRequired,
onSignup: PropTypes.func.isRequired,
signupStatus: PropTypes.object.isRequired,
product: PropTypes.object
};

Expand All @@ -132,7 +129,6 @@ const mapStateToProps = state => ({
.map(m => m.essentialMeasurements).orElse(null),
profiles: state.profileList.profiles,
selectedProfile: state.selectedProfile,
signupStatus: state.signupStatus,
product: state.productInfo.product
});

Expand Down
10 changes: 7 additions & 3 deletions src/common/SignupBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ class SignupBox extends React.Component {
this.setState({ email, valid });
};

handleEnter = (event) => {
if (event.key === "Enter") {
this.handleClick();
}
};

handleClick = () => {
if (this.state.valid) {
this.props.onSignup(this.state.email)
Expand All @@ -46,7 +52,7 @@ class SignupBox extends React.Component {
<div>{t("signupBox.message")}</div>
<div className={inputClassName}>
<input type="email" value={this.state.email} onChange={this.handleChange}
placeholder={t("signupBox.emailPlaceholder")}/>
placeholder={t("signupBox.emailPlaceholder")} onKeyPress={this.handleEnter}/>
<a disabled={!this.state.valid} onClick={this.handleClick}>{t("signupBox.save")}</a>
</div>
{isError && <div className="signup-alert">
Expand All @@ -59,9 +65,7 @@ class SignupBox extends React.Component {
}

SignupBox.propTypes = {
onLogin: PropTypes.func.isRequired,
onSignup: PropTypes.func.isRequired,
signupStatus: PropTypes.object.isRequired,
t: PropTypes.func
};

Expand Down

0 comments on commit 547326f

Please sign in to comment.