You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mvfront-react/src/components/views/CreateSuccess.jsx

114 lines
3.4 KiB

4 years ago
import React, {Component} from 'react';
4 years ago
import {Col, Container, Row} from 'reactstrap';
4 years ago
import {Link} from 'react-router-dom';
import {withTranslation, Trans} from 'react-i18next';
import {faCopy, faUsers, faExclamationTriangle} from '@fortawesome/free-solid-svg-icons';
4 years ago
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import logoLine from '../../logos/logo-line-white.svg';
import {AppContext} from '../../AppContext';
import CopyField from '../CopyField';
class CreateSuccess extends Component {
static contextType = AppContext;
4 years ago
constructor(props) {
super(props);
const electionSlug = this.props.match.params.slug;
4 years ago
this.state = {
urlOfVote:
window.location.origin + '/vote/' + electionSlug,
4 years ago
urlOfResult:
window.location.origin + '/result/' + electionSlug,
};
4 years ago
this.urlVoteField = React.createRef();
this.urlResultField = React.createRef();
}
handleClickOnCopyResult = event => {
const input = this.urlResultField.current;
input.focus();
input.select();
4 years ago
document.execCommand('copy');
4 years ago
};
render() {
4 years ago
const {t} = this.props;
const electionLink = this.props.invitationOnly ? (
<>
<p className="mt-4 mb-1">
{t('Voters received a link to vote by email. Each link can be used only once!')}
</p>
</>
) : (
<>
<p className="mt-4 mb-1">
{t('You can now share the election link to participants:')}
</p>
<CopyField
value={this.state.urlOfVote}
icon={faCopy}
t={t}
/>
</>
);
4 years ago
return (
<Container>
<Row>
<Link to="/" className="d-block ml-auto mr-auto mb-4">
<img src={logoLine} alt="logo" height="128" />
</Link>
</Row>
<Row className="mt-4">
<Col className="text-center offset-lg-3" lg="6">
4 years ago
<h2>{t('Successful election creation!')}</h2>
4 years ago
{electionLink}
4 years ago
<p className="mt-4 mb-1">
4 years ago
{t('Here is the link for the results in real time:')}
4 years ago
</p>
<CopyField
value={this.state.urlOfResult}
icon={faCopy}
t={t}
/>
4 years ago
</Col>
</Row>
<Row className="mt-4 mb-4">
<Col className="text-center offset-lg-3" lg="6">
<div className=" bg-danger text-white p-2 ">
<h4 className="m-0 p-0 text-center">
<FontAwesomeIcon icon={faExclamationTriangle} className="mr-2" />
{t('Keep these links carefully')}
</h4>
4 years ago
<p className="small m-2 p-0">
<Trans i18nKey="t">
4 years ago
<b>Warning</b>: you will have no other choices to recover the
links, and we will not be able to share them with you. For
example, you can bookmark them in your browser.
</Trans>
4 years ago
</p>
</div>
</Col>
</Row>
<Row className="mt-4 mb-4">
<Col className="text-center">
4 years ago
<Link
to={'/vote/' + this.props.match.params.slug}
className="btn btn-success">
4 years ago
<FontAwesomeIcon icon={faUsers} className="mr-2" />
{t('Participate now!')}
4 years ago
</Link>
</Col>
</Row>
</Container>
);
}
}
4 years ago
export default withTranslation()(CreateSuccess);