2017-06-08 01:39:11 +05:30
|
|
|
// @flow
|
|
|
|
import React, { Component } from 'react';
|
2016-05-22 21:26:52 +05:30
|
|
|
|
2017-05-26 00:41:57 +05:30
|
|
|
import { Link } from 'react-router-dom';
|
2016-05-26 15:53:58 +05:30
|
|
|
import { FormattedMessage as Message } from 'react-intl';
|
2016-06-01 14:42:41 +05:30
|
|
|
import Helmet from 'react-helmet';
|
2016-05-23 23:22:05 +05:30
|
|
|
|
|
|
|
import { FooterMenu } from 'components/footerMenu';
|
|
|
|
|
2016-05-22 21:26:52 +05:30
|
|
|
import styles from './rules.scss';
|
|
|
|
|
2016-05-26 15:53:58 +05:30
|
|
|
import messages from './RulesPage.intl.json';
|
|
|
|
import appInfo from 'components/auth/appInfo/AppInfo.intl.json';
|
|
|
|
|
|
|
|
const projectName = <Message {...appInfo.appName} />;
|
|
|
|
|
2016-05-31 15:00:41 +05:30
|
|
|
import classNames from 'classnames';
|
|
|
|
|
2016-05-22 21:26:52 +05:30
|
|
|
const rules = [
|
|
|
|
{
|
2016-05-26 15:53:58 +05:30
|
|
|
title: <Message {...messages.mainProvisions} />,
|
2016-05-22 21:26:52 +05:30
|
|
|
items: [
|
2017-06-08 01:39:11 +05:30
|
|
|
<Message key="0" {...messages.mainProvision1} values={{
|
2016-05-26 15:53:58 +05:30
|
|
|
name: (<b>{projectName}</b>)
|
2016-05-31 15:00:41 +05:30
|
|
|
}} />,
|
2017-06-08 01:39:11 +05:30
|
|
|
<Message key="1" {...messages.mainProvision2} />,
|
|
|
|
<Message key="2" {...messages.mainProvision3} />,
|
|
|
|
<Message key="3" {...messages.mainProvision4} values={{
|
2016-06-28 15:37:28 +05:30
|
|
|
link: (<Link to="/register">https://account.ely.by/register</Link>)
|
2016-05-31 15:00:41 +05:30
|
|
|
}} />
|
2016-05-22 21:26:52 +05:30
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
2016-05-26 15:53:58 +05:30
|
|
|
title: <Message {...messages.emailAndNickname} />,
|
2016-05-22 21:26:52 +05:30
|
|
|
items: [
|
2017-06-08 01:39:11 +05:30
|
|
|
<Message key="0" {...messages.emailAndNickname1} />,
|
|
|
|
<Message key="1" {...messages.emailAndNickname2} />,
|
|
|
|
<Message key="2" {...messages.emailAndNickname3} />,
|
|
|
|
<Message key="3" {...messages.emailAndNickname4} />,
|
|
|
|
<Message key="4" {...messages.emailAndNickname5} />,
|
|
|
|
<Message key="5" {...messages.emailAndNickname6} />,
|
|
|
|
<Message key="6" {...messages.emailAndNickname7} />
|
2016-05-22 21:26:52 +05:30
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
2016-05-26 15:53:58 +05:30
|
|
|
title: <Message {...messages.elyAccountsAsService} values={{
|
|
|
|
name: projectName
|
|
|
|
}} />,
|
2016-05-23 23:22:05 +05:30
|
|
|
description: (<div>
|
2016-05-26 15:53:58 +05:30
|
|
|
<p><Message {...messages.elyAccountsAsServiceDesc1} values={{
|
|
|
|
name: (<b>{projectName}</b>)
|
|
|
|
}} /></p>
|
|
|
|
<p><Message {...messages.elyAccountsAsServiceDesc2} /></p>
|
2016-05-23 23:22:05 +05:30
|
|
|
</div>),
|
2016-05-22 21:26:52 +05:30
|
|
|
items: [
|
2017-06-08 01:39:11 +05:30
|
|
|
<Message key="0" {...messages.elyAccountsAsService1} />,
|
|
|
|
<Message key="1" {...messages.elyAccountsAsService2} />
|
2016-05-22 21:26:52 +05:30
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2017-08-23 02:01:41 +05:30
|
|
|
export default class RulesPage extends Component<{
|
|
|
|
location: {
|
|
|
|
pathname: string,
|
|
|
|
search: string,
|
|
|
|
hash: string
|
|
|
|
},
|
2016-06-01 14:42:41 +05:30
|
|
|
|
2017-08-23 02:01:41 +05:30
|
|
|
history: {
|
|
|
|
replace: Function
|
|
|
|
}
|
|
|
|
}> {
|
2016-05-31 15:00:41 +05:30
|
|
|
render() {
|
|
|
|
let {hash} = this.props.location;
|
2017-05-26 00:41:57 +05:30
|
|
|
|
2016-05-31 15:00:41 +05:30
|
|
|
if (hash) {
|
|
|
|
hash = hash.substring(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
2016-06-01 14:42:41 +05:30
|
|
|
<Message {...messages.title}>
|
|
|
|
{(pageTitle) => (
|
|
|
|
<Helmet title={pageTitle} />
|
|
|
|
)}
|
|
|
|
</Message>
|
|
|
|
|
2016-05-31 15:00:41 +05:30
|
|
|
<div className={styles.rules}>
|
|
|
|
{rules.map((block, sectionIndex) => (
|
|
|
|
<div className={styles.rulesSection} key={sectionIndex}>
|
|
|
|
<h2
|
|
|
|
className={classNames(styles.rulesSectionTitle, {
|
2016-06-01 14:42:41 +05:30
|
|
|
[styles.target]: RulesPage.getTitleHash(sectionIndex) === hash
|
2016-05-31 15:00:41 +05:30
|
|
|
})}
|
2016-06-01 14:42:41 +05:30
|
|
|
id={RulesPage.getTitleHash(sectionIndex)}
|
2016-05-31 15:00:41 +05:30
|
|
|
>
|
|
|
|
{block.title}
|
|
|
|
</h2>
|
2016-05-22 21:26:52 +05:30
|
|
|
|
2016-05-31 15:00:41 +05:30
|
|
|
<div className={styles.rulesBody}>
|
|
|
|
{block.description ? (
|
|
|
|
<div className={styles.blockDescription}>
|
|
|
|
{block.description}
|
|
|
|
</div>
|
|
|
|
) : ''}
|
|
|
|
<ol className={styles.rulesList}>
|
|
|
|
{block.items.map((item, ruleIndex) => (
|
|
|
|
<li
|
|
|
|
className={classNames(styles.rulesItem, {
|
2016-06-01 14:42:41 +05:30
|
|
|
[styles.target]: RulesPage.getRuleHash(sectionIndex, ruleIndex) === hash
|
2016-05-31 15:00:41 +05:30
|
|
|
})}
|
|
|
|
key={ruleIndex}
|
2016-06-01 14:42:41 +05:30
|
|
|
id={RulesPage.getRuleHash(sectionIndex, ruleIndex)}
|
|
|
|
onClick={this.onRuleClick.bind(this)}
|
2016-05-31 15:00:41 +05:30
|
|
|
>
|
|
|
|
{item}
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ol>
|
|
|
|
</div>
|
2016-05-23 23:22:05 +05:30
|
|
|
</div>
|
2016-05-31 15:00:41 +05:30
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
<div className={styles.footer}>
|
|
|
|
<FooterMenu />
|
|
|
|
</div>
|
2016-05-23 23:22:05 +05:30
|
|
|
</div>
|
2016-05-31 15:00:41 +05:30
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-09-09 19:52:19 +05:30
|
|
|
onRuleClick(event: SyntheticMouseEvent<HTMLElement>) {
|
2017-06-08 01:39:11 +05:30
|
|
|
if (event.defaultPrevented
|
|
|
|
|| !event.currentTarget.id
|
2017-09-09 19:52:19 +05:30
|
|
|
|| event.target instanceof HTMLAnchorElement
|
2017-06-08 01:39:11 +05:30
|
|
|
) {
|
2016-06-28 15:37:28 +05:30
|
|
|
// some-one have already processed this event or it is a link
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-01 14:42:41 +05:30
|
|
|
const {id} = event.currentTarget;
|
2017-05-26 00:41:57 +05:30
|
|
|
const newPath = `${this.props.location.pathname}${this.props.location.search}#${id}`;
|
|
|
|
|
|
|
|
this.props.history.replace(newPath);
|
2016-06-01 03:57:20 +05:30
|
|
|
}
|
|
|
|
|
2018-05-03 10:45:09 +05:30
|
|
|
static getTitleHash(sectionIndex: number) {
|
2016-05-31 15:00:41 +05:30
|
|
|
return `rule-${sectionIndex + 1}`;
|
|
|
|
}
|
|
|
|
|
2018-05-03 10:45:09 +05:30
|
|
|
static getRuleHash(sectionIndex: number, ruleIndex: number) {
|
2016-06-01 14:42:41 +05:30
|
|
|
return `${RulesPage.getTitleHash(sectionIndex)}-${ruleIndex + 1}`;
|
2016-05-31 15:00:41 +05:30
|
|
|
}
|
2016-05-22 21:26:52 +05:30
|
|
|
}
|