accounts-frontend/src/pages/rules/RulesPage.jsx

134 lines
4.7 KiB
React
Raw Normal View History

import React, { Component, PropTypes } from 'react';
2016-05-22 21:26:52 +05:30
import { Link, browserHistory } from 'react-router';
import { FormattedMessage as Message } from 'react-intl';
import { FooterMenu } from 'components/footerMenu';
2016-05-22 21:26:52 +05:30
import styles from './rules.scss';
import messages from './RulesPage.intl.json';
import appInfo from 'components/auth/appInfo/AppInfo.intl.json';
const projectName = <Message {...appInfo.appName} />;
import classNames from 'classnames';
2016-05-22 21:26:52 +05:30
const rules = [
{
title: <Message {...messages.mainProvisions} />,
2016-05-22 21:26:52 +05:30
items: [
<Message {...messages.mainProvision1} values={{
name: (<b>{projectName}</b>)
}} />,
<Message {...messages.mainProvision2} />,
<Message {...messages.mainProvision3} />,
<Message {...messages.mainProvision4} values={{
link: (<Link to={'/register'}>https://account.ely.by/register</Link>)
}} />
2016-05-22 21:26:52 +05:30
]
},
{
title: <Message {...messages.emailAndNickname} />,
2016-05-22 21:26:52 +05:30
items: [
<Message {...messages.emailAndNickname1} />,
<Message {...messages.emailAndNickname2} />,
<Message {...messages.emailAndNickname3} />,
<Message {...messages.emailAndNickname4} />,
<Message {...messages.emailAndNickname5} />,
<Message {...messages.emailAndNickname6} />,
<Message {...messages.emailAndNickname7} />
2016-05-22 21:26:52 +05:30
]
},
{
title: <Message {...messages.elyAccountsAsService} values={{
name: projectName
}} />,
description: (<div>
<p><Message {...messages.elyAccountsAsServiceDesc1} values={{
name: (<b>{projectName}</b>)
}} /></p>
<p><Message {...messages.elyAccountsAsServiceDesc2} /></p>
</div>),
2016-05-22 21:26:52 +05:30
items: [
<Message {...messages.elyAccountsAsService1} />,
<Message {...messages.elyAccountsAsService2} />
2016-05-22 21:26:52 +05:30
]
}
];
export default class RulesPage extends Component {
static propTypes = {
location: PropTypes.shape({
hash: PropTypes.string
})
};
render() {
let {hash} = this.props.location;
if (hash) {
hash = hash.substring(1);
}
return (
<div>
<div className={styles.rules}>
{rules.map((block, sectionIndex) => (
<div className={styles.rulesSection} key={sectionIndex}>
<h2
className={classNames(styles.rulesSectionTitle, {
[styles.target]: this.getTitleHash(sectionIndex) === hash
})}
id={this.getTitleHash(sectionIndex)}
>
{block.title}
</h2>
2016-05-22 21:26:52 +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, {
[styles.target]: this.getRuleHash(sectionIndex, ruleIndex) === hash
})}
key={ruleIndex}
id={this.getRuleHash(sectionIndex, ruleIndex)}
onClick={this.onRuleClick}
>
{item}
</li>
))}
</ol>
</div>
</div>
))}
</div>
<div className={styles.footer}>
<FooterMenu />
</div>
</div>
);
}
onRuleClick(event) {
const id = event.currentTarget.id;
const newLocation = browserHistory.createLocation({...location, hash: `#${id}`});
browserHistory.replace(newLocation);
}
getTitleHash(sectionIndex) {
return `rule-${sectionIndex + 1}`;
}
getRuleHash(sectionIndex, ruleIndex) {
return `rule-${sectionIndex + 1}-${ruleIndex + 1}`;
}
2016-05-22 21:26:52 +05:30
}
RulesPage.displayName = 'RulesPage';