-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
183 additions
and
48 deletions.
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
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 |
---|---|---|
@@ -1,14 +1,8 @@ | ||
import sharify from 'sharify'; | ||
|
||
import { mountWithApolloProvider } from 'react/apollo'; | ||
|
||
import withBrowserRouter from 'react/hocs/WithBrowserRouter'; | ||
|
||
import Routes from 'apps/authentication/Routes'; | ||
|
||
const { data: { APOLLO } } = sharify; | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const mountPoint = document.getElementById('apolloMount'); | ||
mountWithApolloProvider(withBrowserRouter(Routes), APOLLO, mountPoint); | ||
}); | ||
document.addEventListener('DOMContentLoaded', () => | ||
mountWithApolloProvider(withBrowserRouter(Routes), {}, document.getElementById('apolloMount'))); |
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
30 changes: 30 additions & 0 deletions
30
react/components/RegistrationForm/mutations/acceptInvitation.js
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import gql from 'graphql-tag'; | ||
|
||
export default gql` | ||
mutation acceptInvitationMutation( | ||
$invitation_token: String! | ||
$first_name: String!, | ||
$last_name: String!, | ||
$email: String!, | ||
$password: String!, | ||
$password_confirmation: String!, | ||
$receive_newsletter: Boolean | ||
$receive_tips_emails: Boolean | ||
) { | ||
accept_invitation(input: { | ||
invitation_token: $invitation_token | ||
first_name: $first_name | ||
last_name: $last_name | ||
email: $email | ||
password: $password | ||
password_confirmation: $password_confirmation | ||
receive_newsletter: $receive_newsletter | ||
receive_tips_emails: $receive_tips_emails | ||
}) { | ||
me { | ||
id | ||
} | ||
} | ||
} | ||
`; |
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import styled from 'styled-components'; | ||
import { display, space, width, alignItems, minHeight } from 'styled-system'; | ||
import { display, space, width, alignItems, minHeight, justifyContent, flexDirection } from 'styled-system'; | ||
|
||
export default styled.div` | ||
${display} | ||
${width} | ||
${minHeight} | ||
${space} | ||
${alignItems} | ||
${minHeight} | ||
${justifyContent} | ||
${flexDirection} | ||
`; |
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
9 changes: 9 additions & 0 deletions
9
react/pages/authentication/AcceptInvitationPage/fragments/invitee.js
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import gql from 'graphql-tag'; | ||
|
||
export default gql` | ||
fragment Invitee on Invitee { | ||
__typename | ||
id | ||
} | ||
`; |
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 |
---|---|---|
@@ -1,14 +1,62 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Query } from 'react-apollo'; | ||
|
||
import inviteeQuery from 'react/pages/authentication/AcceptInvitationPage/queries/invitee'; | ||
|
||
import Icon from 'react/components/UI/Icon'; | ||
import CenteringBox from 'react/components/UI/CenteringBox'; | ||
import Text from 'react/components/UI/Text'; | ||
import RegistrationForm from 'react/components/RegistrationForm'; | ||
|
||
export default class RegistrationPage extends Component { | ||
export default class AcceptInvitationPage extends Component { | ||
static propTypes = { | ||
// `invitation_token` is used to locate the invite | ||
// it is a digest of `raw_invitation_token` and exists on the user record. | ||
invitation_token: PropTypes.string.isRequired, | ||
// `raw_invitation_token` is used to accept the invite | ||
// it is not in the database directly. | ||
// At the moment this is passed as `invite_token` in the | ||
// query string of the URL in the invitation email | ||
raw_invitation_token: PropTypes.string.isRequired, | ||
} | ||
|
||
render() { | ||
const { invitation_token, raw_invitation_token } = this.props; | ||
|
||
return ( | ||
<CenteringBox p={7}> | ||
<RegistrationForm /> | ||
</CenteringBox> | ||
<Query query={inviteeQuery} variables={{ invitation_token }}> | ||
{({ loading, error, data }) => { | ||
if (loading) return <div />; | ||
|
||
if (error) { | ||
return ( | ||
<CenteringBox p={7} flexDirection="column"> | ||
<Icon name="ArenaMark" size={7} mb={9} /> | ||
|
||
<Text f={5} mb={6}> | ||
We cannot find that invitation code. | ||
</Text> | ||
|
||
<Text f={2} underlineLinks> | ||
If you believe this is in error please contact | ||
{' '} | ||
<a href="mailto:[email protected]">[email protected]</a> | ||
</Text> | ||
</CenteringBox> | ||
); | ||
} | ||
|
||
return ( | ||
<CenteringBox p={7}> | ||
<RegistrationForm | ||
email={data.invitee.email} | ||
raw_invitation_token={raw_invitation_token} | ||
/> | ||
</CenteringBox> | ||
); | ||
}} | ||
</Query> | ||
); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
react/pages/authentication/AcceptInvitationPage/queries/invitee.js
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import gql from 'graphql-tag'; | ||
|
||
import inviteeFragment from 'react/pages/authentication/AcceptInvitationPage/fragments/invitee'; | ||
|
||
export default gql` | ||
query Invitee($invitation_token: String!) { | ||
invitee(invitation_token: $invitation_token) { | ||
...Invitee | ||
} | ||
} | ||
${inviteeFragment} | ||
`; |