Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

People: Invites: Redirect to /posts/%site% #1185

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions client/my-sites/invites/invite-accept-logged-in/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import React from 'react';
import classNames from 'classnames';
import page from 'page';

/**
* Internal dependencies
Expand All @@ -13,14 +14,22 @@ import Button from 'components/button';
import config from 'config';
import userModule from 'lib/user';
import InviteFormHeader from 'my-sites/invites/invite-form-header';
import { acceptInvite } from 'lib/invites/actions';
import { acceptInvite, displayInviteAccepted } from 'lib/invites/actions';

const user = userModule();

export default React.createClass( {

displayName: 'InviteAcceptLoggedIn',

acceptInvite() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps change this method name to simply accept
seeing acceptInvite written so close together feels a little confusing.

const { invite } = this.props;
acceptInvite( invite, () => {
page( this.props.redirectTo );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like we're doing any error handling here. I understand it's probably more edge case to handle errors here (since we validate an invite before showing the user this UI), but it is possible that a user is mobile and lost connection or somehow opened another tab and took an action which invalidated an invite.

In this case, we shouldn't redirect the user and tell him/her that it was successful.

displayInviteAccepted( invite.blog_id );
} );
},

render() {
let userObject = user.get(),
signInLink = config( 'login_url' ) + '?redirect_to=' + encodeURIComponent( window.location.href );
Expand All @@ -46,7 +55,7 @@ export default React.createClass( {
<Button href={ window.location.origin + '?invite_declined' }>
{ this.translate( 'Decline', { context: 'button' } ) }
</Button>
<Button primary onClick={ () => acceptInvite( this.props.invite ) } href={ this.props.redirectTo } >
<Button primary onClick={ this.acceptInvite }>
{ this.translate( 'Join', { context: 'button' } ) }
</Button>
</div>
Expand Down