<commit_before>/**
 * News
 *
 * Load and display articles
 */

import React from 'react';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { firestoreConnect, isLoaded, isEmpty } from 'react-redux-firebase';

import Article from 'components/Article';
import LoadingIndicator from 'components/LoadingIndicator';

import './style.scss';

const LegendsPage = ({ legends }) => {
  const legendsList = !isLoaded(legends)
    ? <LoadingIndicator />
    : isEmpty(legends)
      ? ''
      : Object.keys(legends).map(
        (key, id) => (
          <Article
            key={key}
            id={`legend-${key}`}
            title={legends[key].title}
            content={legends[key].content}
          />
        )
      )
  return (
    <div className="legendsPage">
      {legendsList}
    </div>
  )
}

export default compose(
  firestoreConnect(({event}) => [
    {
      collection: "legends",
      // collection: "legends",
    }
  ]),
  connect((state) => ({
    legends: state.firestore.data.legends
  }))
)(LegendsPage);<commit_msg>Dynamic legends<commit_after>/**
 * News
 *
 * Load and display articles
 */

import React from 'react';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { firestoreConnect, isLoaded, isEmpty } from 'react-redux-firebase';

import Article from 'components/Article';
import LoadingIndicator from 'components/LoadingIndicator';
import get from 'lodash/get'

import './style.scss';

const LegendsPage = ({ legends }) => {
  const legendsList = !isLoaded(legends)
    ? <LoadingIndicator />
    : isEmpty(legends)
      ? <Article id="legend-not-found" title='Néni nic!' content='Bohužel nemáme co nabídnout'/>
      : Object.keys(legends).map(
        (key, id) => (
          <Article
            key={key}
            id={`legend-${key}`}
            title={legends[key].title}
            content={legends[key].content}
          />
        )
      )
  return (
    <div className="legendsPage">
      {legendsList}
    </div>
  )
}

export default compose(
  firestoreConnect(({location}) => [
    {
      collection: "legends",
      where: ['event', '==', location.pathname.split('/', 2)[1]],
      storeAs: `legends_${location.pathname.split('/', 2)[1]}`
      // collection: "legends",
    }
  ]),
  connect((state, props) => ({
    legends: get(state.firestore.data, `legends_${props.location.pathname.split('/', 2)[1]}`)
  }))
)(LegendsPage);
{'fraction_non_alphanumeric': 0.1653061224489796, 'fraction_numerical': 0.0024489795918367346, 'mean_word_length': 2.7882534775888717, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1873873', 'n_tokens_mistral': 796, 'n_tokens_neox': 776, 'n_words': 156}