import React, { Component } from 'react'
import { Trans, translate } from 'react-i18next'
import { connect } from 'react-redux'
import { head, path, compose } from 'ramda'
import {
decodeRuleName,
findRulesByName,
findRuleByDottedName
} from 'Engine/rules.js'
import { encodeRuleName } from 'Engine/rules'
import { Link, Redirect } from 'react-router-dom'
import { animateScroll } from 'react-scroll'
import './RulePage.css'
import SearchButton from './SearchButton'
import Namespace from './rule/Namespace'
import Rule from './rule/Rule'
import { setExample } from '../actions'
import {
noUserInputSelector,
flatRulesSelector
} from 'Selectors/analyseSelectors'
@connect(state => ({
themeColours: state.themeColours,
valuesToShow: !noUserInputSelector(state),
flatRules: flatRulesSelector(state)
}))
@translate()
export default class RulePage extends Component {
componentDidMount() {
animateScroll.scrollToTop({ duration: 300 })
}
render() {
let { flatRules } = this.props,
name = path(['match', 'params', 'name'], this.props),
decodedRuleName = decodeRuleName(name)
if (decodedRuleName.includes(' . ')) {
if (!findRuleByDottedName(flatRules, decodedRuleName))
return