metamaps--metamaps/src/components/LightBoxes/Invite.js

56 lines
1.9 KiB
JavaScript
Raw Normal View History

2018-03-08 07:26:04 -05:00
import React, { Component } from 'react'
2018-03-08 10:08:38 -05:00
import clipboard from 'clipboard-js'
2018-03-08 07:26:04 -05:00
class Invite extends Component {
2018-03-08 10:08:38 -05:00
constructor(props) {
super(props)
this.state = {
copied: false,
unable: false
}
}
inviteLink = () => {
const { host, protocol } = window ? window.location : {}
const inviteLink = `${protocol}//${host}/join?code=${this.props.inviteCode}`
return inviteLink
}
shareInvite = () => {
const inviteLink = this.inviteLink()
clipboard.copy({
'text/plain': inviteLink
}).then(() => {
this.setState({ copied: true })
window.setTimeout(() => this.setState({ copied: false }), 1500)
}, () => {
this.setState({ unable: true })
window.setTimeout(() => this.setState({ unable: false }), 1500)
})
}
2018-03-08 07:26:04 -05:00
render = () => {
2018-03-08 10:08:38 -05:00
const inviteLink = this.inviteLink()
2018-03-08 07:26:04 -05:00
return (
<div className="lightboxContent" id="invite">
<h3>SHARE INVITE</h3>
<div className="leaveSpace"></div>
<p>The Metamaps platform is currently in an invite-only beta with the express purpose of creating a high value knowledge ecosystem, a diverse community of contributors and a culture of collaboration and curiosity.</p>
<p>As a valued beta tester, you have the ability to invite your peers, colleagues and collaborators onto the platform.</p>
<p>Below is a personal invite link containing your unique access code, which can be used multiple times.</p>
<div id="joinCodesBox">
<p className="joinCodes">
2018-03-08 10:08:38 -05:00
{inviteLink}
<button className="button" onClick={this.shareInvite}>COPY INVITE LINK!</button>
</p>
<p className="popup" style={{textAlign: 'center'}}>
{this.state.copied && 'Copied!'}
{this.state.unable && "Your browser doesn't support copying, please copy manually."}
2018-03-08 07:26:04 -05:00
</p>
</div>
</div>
)
}
}
export default Invite