2017-08-23 00:19:50 +05:30
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React, { Component } from 'react';
|
2016-03-04 02:57:33 +05:30
|
|
|
|
2016-03-15 11:10:18 +05:30
|
|
|
import { connect } from 'react-redux';
|
2016-03-04 02:57:33 +05:30
|
|
|
import { FormattedMessage as Message } from 'react-intl';
|
2016-03-16 10:16:44 +05:30
|
|
|
import Helmet from 'react-helmet';
|
2016-03-04 02:57:33 +05:30
|
|
|
|
2016-05-14 16:56:17 +05:30
|
|
|
import { Button } from 'components/ui/form';
|
2018-03-26 00:46:45 +05:30
|
|
|
import copy from 'services/copy';
|
2016-03-04 02:57:33 +05:30
|
|
|
|
2016-05-14 16:56:17 +05:30
|
|
|
import messages from './Finish.intl.json';
|
2016-03-04 02:57:33 +05:30
|
|
|
import styles from './finish.scss';
|
|
|
|
|
2016-03-15 11:10:18 +05:30
|
|
|
class Finish extends Component {
|
|
|
|
static displayName = 'Finish';
|
2016-03-04 02:57:33 +05:30
|
|
|
|
2016-03-15 11:10:18 +05:30
|
|
|
static propTypes = {
|
|
|
|
appName: PropTypes.string.isRequired,
|
|
|
|
code: PropTypes.string.isRequired,
|
2017-08-23 00:27:35 +05:30
|
|
|
state: PropTypes.string.isRequired,
|
2016-03-15 11:10:18 +05:30
|
|
|
displayCode: PropTypes.bool,
|
|
|
|
success: PropTypes.bool
|
2016-03-04 02:57:33 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2016-03-16 10:16:44 +05:30
|
|
|
const {appName, code, state, displayCode, success} = this.props;
|
|
|
|
const authData = JSON.stringify({
|
2017-08-23 00:27:35 +05:30
|
|
|
auth_code: code, // eslint-disable-line
|
|
|
|
state
|
2016-03-16 10:16:44 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
history.pushState(null, null, `#${authData}`);
|
2016-03-04 02:57:33 +05:30
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles.finishPage}>
|
2016-03-16 10:16:44 +05:30
|
|
|
<Helmet title={authData} />
|
|
|
|
|
2016-03-04 02:57:33 +05:30
|
|
|
{success ? (
|
|
|
|
<div>
|
2017-08-23 00:27:35 +05:30
|
|
|
<div className={styles.successBackground} />
|
2016-03-04 02:57:33 +05:30
|
|
|
<div className={styles.greenTitle}>
|
|
|
|
<Message {...messages.authForAppSuccessful} values={{
|
|
|
|
appName: (<span className={styles.appName}>{appName}</span>)
|
|
|
|
}} />
|
|
|
|
</div>
|
2016-03-15 11:10:18 +05:30
|
|
|
{displayCode ? (
|
2016-03-04 02:57:33 +05:30
|
|
|
<div>
|
|
|
|
<div className={styles.description}>
|
|
|
|
<Message {...messages.passCodeToApp} values={{appName}} />
|
|
|
|
</div>
|
2016-03-15 11:10:18 +05:30
|
|
|
<div className={styles.codeContainer}>
|
2018-03-26 00:46:45 +05:30
|
|
|
<div className={styles.code}>
|
|
|
|
{code}
|
|
|
|
</div>
|
2016-03-15 11:10:18 +05:30
|
|
|
</div>
|
2018-03-26 00:46:45 +05:30
|
|
|
<Button
|
|
|
|
color="green"
|
|
|
|
small
|
|
|
|
label={messages.copy}
|
|
|
|
onClick={this.onCopyClick}
|
|
|
|
/>
|
2016-03-04 02:57:33 +05:30
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div className={styles.description}>
|
|
|
|
<Message {...messages.waitAppReaction} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div>
|
2017-08-23 00:27:35 +05:30
|
|
|
<div className={styles.failBackground} />
|
2016-03-04 02:57:33 +05:30
|
|
|
<div className={styles.redTitle}>
|
|
|
|
<Message {...messages.authForAppFailed} values={{
|
|
|
|
appName: (<span className={styles.appName}>{appName}</span>)
|
|
|
|
}} />
|
|
|
|
</div>
|
|
|
|
<div className={styles.description}>
|
|
|
|
<Message {...messages.waitAppReaction} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2016-03-16 10:16:44 +05:30
|
|
|
|
2017-08-23 00:27:35 +05:30
|
|
|
onCopyClick = (event) => {
|
2016-03-16 10:16:44 +05:30
|
|
|
event.preventDefault();
|
2018-03-26 00:46:45 +05:30
|
|
|
copy(this.props.code);
|
2016-03-16 10:16:44 +05:30
|
|
|
};
|
2016-03-04 02:57:33 +05:30
|
|
|
}
|
2016-03-15 11:10:18 +05:30
|
|
|
|
2016-03-15 12:06:13 +05:30
|
|
|
export default connect(({auth}) => ({
|
|
|
|
appName: auth.client.name,
|
|
|
|
code: auth.oauth.code,
|
|
|
|
displayCode: auth.oauth.displayCode,
|
2016-03-16 10:16:44 +05:30
|
|
|
state: auth.oauth.state,
|
2016-03-15 12:06:13 +05:30
|
|
|
success: auth.oauth.success
|
2016-03-15 11:10:18 +05:30
|
|
|
}))(Finish);
|