This repository has been archived by the owner on Jan 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Update check out form to be editable and only visible to authenticated users #60
Merged
mjrousos
merged 4 commits into
Glimpse:master
from
mjrousos:Issue56-CartViewFormUsability
Jun 14, 2017
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f93ab02
Qualify calls to profileActions functions with the module name
mjrousos 5223651
Wire up React event handlers to allow editing the checkout form
mjrousos e58a8cd
Update the right pane of the cart view to change contents based on wh…
mjrousos 2257025
Fixed up a couple whitespace issues
mjrousos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,13 +75,65 @@ export default React.createClass({ | |
userProfile: React.PropTypes.object | ||
}, | ||
|
||
getInitialState() { | ||
return { | ||
fullName: this.props.userProfile != null && this.props.userProfile.isAuthenticated ? this.props.userProfile.fullName : '', | ||
email: this.props.userProfile != null && this.props.userProfile.isAuthenticated ? this.props.userProfile.email : '' | ||
}; | ||
}, | ||
|
||
onNameChanged(e) { | ||
this.setState({ fullName: e.target.value }); | ||
}, | ||
|
||
onEmailChanged(e) { | ||
this.setState({ email: e.target.value }); | ||
}, | ||
|
||
render() { | ||
const items = this.props.items; | ||
const fullName = this.props.userProfile != null && this.props.userProfile.isAuthenticated ? this.props.userProfile.fullName : ''; | ||
const email = this.props.userProfile != null && this.props.userProfile.isAuthenticated ? this.props.userProfile.email : ''; | ||
|
||
// TODO: items is an array of IDs, need to look up or convert to whole objects | ||
const itemRows = items.map((item) => <ItemRow item={item} key={item.id} />); | ||
|
||
var rightPane = null; | ||
if (this.props.userProfile != null && this.props.userProfile.isAuthenticated) { | ||
// If the user is logged in, include the checkout form in the right pane | ||
rightPane = | ||
<div className="gs-cartview-normal-rightpane"> | ||
<div className="gs-cartview-normal-rightpane-label">Name</div> | ||
<input placeholder="required" | ||
value={this.state.fullName} | ||
onChange={this.onNameChanged} | ||
className="gs-cartview-normal-rightpane-input" name="checkout-name" min="1"/> | ||
<div className="gs-cartview-normal-rightpane-label">Email Address</div> | ||
<input placeholder="required" | ||
name="email" | ||
value={this.state.email} | ||
onChange={this.onEmailChanged} | ||
className="gs-cartview-normal-rightpane-input" name="checkout-email" type="email" min="1"/> | ||
<div className="gs-cartview-normal-rightpane-disclaimer"> | ||
*You will be able to pick up your stickers right after the order is processed. No physical address is required. | ||
</div> | ||
<div className="gs-cartview-normal-rightpane-submitcontainer"> | ||
<button type="submit" className="gs-cartview-normal-rightpane-submit"> | ||
<Icon className="gs-cartview-normal-rightpane-submit-icon" name="lock" size="lg" /> | ||
<div>Print my stickers</div> | ||
</button> | ||
</div> | ||
</div> | ||
|
||
} else { | ||
// If the user is not logged in, provide a button to redirect to the login page | ||
rightPane = | ||
<div className="gs-cartview-normal-rightpane"> | ||
<div className="gs-cartview-normal-rightpane-label">Log In to Print Stickers</div> | ||
<div className="gs-cartview-normal-rightpane-submitcontainer"> | ||
<a className="gs-cartview-normal-rightpane-submit" href="/users/auth?p=B2C_1_SignInAndSignUp">Log In</a> | ||
</div> | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are spaces at the end of this line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
} | ||
|
||
return ( | ||
<div className="gs-cartview-normal"> | ||
|
||
|
@@ -103,25 +155,7 @@ export default React.createClass({ | |
<input type="hidden" name="token" value={token} /> | ||
</div> | ||
|
||
<div className="gs-cartview-normal-rightpane"> | ||
<div className="gs-cartview-normal-rightpane-label">Name</div> | ||
<input placeholder="required" | ||
value={fullName} | ||
className="gs-cartview-normal-rightpane-input" name="checkout-name" min="1"/> | ||
<div className="gs-cartview-normal-rightpane-label">Email Address</div> | ||
<input placeholder="required" | ||
value={email} | ||
className="gs-cartview-normal-rightpane-input" name="checkout-email" type="email" min="1"/> | ||
<div className="gs-cartview-normal-rightpane-disclaimer"> | ||
*You will be able to pick up your stickers right after the order is processed. No physical address is required. | ||
</div> | ||
<div className="gs-cartview-normal-rightpane-submitcontainer"> | ||
<button type="submit" className="gs-cartview-normal-rightpane-submit"> | ||
<Icon className="gs-cartview-normal-rightpane-submit-icon" name="lock" size="lg" /> | ||
<div>Print my stickers</div> | ||
</button> | ||
</div> | ||
</div> | ||
{rightPane} | ||
</form> | ||
|
||
</div> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is all spaces.