@@ -16,7 +16,7 @@ import ReactSVGComponents from '../components/ReactSVGComponents'
16import KeysAndMetadata from './Point/KeysAndMetadata'
16import KeysAndMetadata from './Point/KeysAndMetadata'
17import Actions from './Point/Actions'
17import Actions from './Point/Actions'
18import { BRIDGE_ERROR } from '../lib/error'
18import { BRIDGE_ERROR } from '../lib/error'
19−import { sendMail } from '../lib/inviteMail'
19+import { hasReceived, sendMail } from '../lib/inviteMail'
20import { Row, Col, Warning, Button, H1, H3,
20import { Row, Col, Warning, Button, H1, H3,
21 Input, InnerLabel
21 Input, InnerLabel
22} from '../components/Base'
22} from '../components/Base'
@@ -46,7 +46,8 @@ class InvitesSend extends React.Component {
46 haveInvited: Nothing(),
46 haveInvited: Nothing(),
47 randomPlanet: Nothing(),
47 randomPlanet: Nothing(),
48 inviteWallet: Nothing(),
48 inviteWallet: Nothing(),
49− targetEmail: ''
49+ targetEmail: '',
50+ targetHasReceived: Nothing()
52 this.findInvited = this.findInvited.bind(this);
53 this.findInvited = this.findInvited.bind(this);
@@ -126,19 +127,33 @@ class InvitesSend extends React.Component {
128 handleEmailInput(email) {
129 handleEmailInput(email) {
129− //TODO simple .*@.*\..* email validation
130+ let newState = { targetEmail: email };
130− this.setState({ targetEmail: email });
131+ if (email.match(/.*@.*\...+/)) {
134+ console.log('hasReceived', res);
135+ this.setState({ targetHasReceived: Just(res) });
138+ newState.targetHasReceived = Nothing();
140+ this.setState(newState);
133 canGenerate() {
143 canGenerate() {
134 //TODO and canSend()
144 //TODO and canSend()
135− let res = this.state.invitesAvailable.matchWith({
145+ let invites = this.state.invitesAvailable.matchWith({
136 Nothing: () => false,
146 Nothing: () => false,
137− Just: invites => ((invites.value > 0)
147+ Just: invites => (invites.value > 0)
138− && Just.hasInstance(this.state.randomPlanet)
139− && Just.hasInstance(this.state.inviteWallet))
149+ let alreadyGotInvited = this.state.targetHasReceived.matchWith({
150+ Nothing: () => false,
151+ Just: has => has.value
141− return res;
153+ return invites
154+ && !alreadyGotInvited
155+ && Just.hasInstance(this.state.randomPlanet)
156+ && Just.hasInstance(this.state.inviteWallet);
144 createUnsignedTxn() {
159 createUnsignedTxn() {
@@ -188,6 +203,19 @@ class InvitesSend extends React.Component {
206+ const recipientWarning = this.state.targetHasReceived.matchWith({
207+ Nothing: () => null,
208+ Just: hasReceived => {
209+ if (!hasReceived.value) return null;
212+ <h3 className={'mb-2'}>{'Warning'}</h3>
213+ { 'That email address has already received an invite!' }
@@ -206,6 +234,8 @@ class InvitesSend extends React.Component {
206 </InnerLabel>
234 </InnerLabel>
237+ { recipientWarning }
209 <StatelessTransaction
239 <StatelessTransaction
210 // Upper scope
240 // Upper scope
211 web3={this.props.web3}
241 web3={this.props.web3}