<commit_before>import React from 'react'
import PropTypes from 'prop-types'
import _ from 'lodash'
import i18n from '../../../i18n'
import { featurePropType } from '../../../common/geoJsonUtils'

const Products = ({ products, category }) => {
  if (products && products.length > 0) {
    return (
      <div>
        <h4>{i18n.t(`productcategories.${category}`)}</h4>
        <ul>
          {products.map(({ name }) => (
            <li key={name}>{i18n.t(`products.${name}`)}</li>
          ))}
        </ul>
      </div>
    )
  }
  return null
}

const AdditionalInfo = ({ feature }) => {
  if (feature.additionalProductInformation) {
    return (
      <div>
        <h4>Zusätzliche Informationen zum Lebensmittelangebot</h4>
        <p>{feature.additionalProductInformation}</p>
      </div>
    )
  }
  return null
}

const EcologicalBehavior = ({ feature }) => {
  const {properties: {actsEcological, economicalBehavior}} = feature
  if (actsEcological || economicalBehavior) {
    const actsEcologicalText = actsEcological ? (
      <li>Dieser Hof wirtschaftet ökologisch.</li>
    ) : (
      ''
    )
    const ecologicalBehaviorText = economicalBehavior ? (
      <li>{economicalBehavior}</li>
    ) : (
      ''
    )
    return (
      <div>
        <h4>Wirtschaftsweise</h4>
        <ul>
          {actsEcologicalText}
          {ecologicalBehaviorText}
        </ul>
      </div>
    )
  }
  return null
}

const AssociatedPlaces = ({ features }) =>
  (features && features.length > 0) ? (
    <div>
      <h4>{i18n.t('details.connected_depots')}</h4>
      <ul>
        {features.map(({ properties: { id, type, name } }) => (
          <li key={id} className={type.toLowerCase()}>
            <a href={`#depots/${id}`} title={name}>
              {name}
            </a>
          </li>
        ))}
      </ul>
    </div>
  ) : null

const Participation = participation => (
  <div>
    <h4>Mitgliederbeteiligung</h4>
    <p>{participation}</p>
  </div>
)

const MaxMembers = members => (
  <div>
    <b>Maximale Mitgliederzahl:</b> {members}
  </div>
)

const FarmDescription = ({ feature }) => {
  const {properties: {products, depots, participation, maximumMembers}} = feature
  return (
    <div>
      {_.map(_.groupBy(products, p => p.category), (p, c) => (
        <Products products={p} category={c}/>
      ))}
      <AdditionalInfo feature={feature}/>
      <EcologicalBehavior feature={feature}/>
      <AssociatedPlaces features={depots}/>

      {participation && Participation(participation)}
      {maximumMembers && MaxMembers(maximumMembers)}
    </div>
  )
}

AdditionalInfo.propTypes = {
  feature: PropTypes.shape({
    additionalProductInformation: PropTypes.string
  }).isRequired
}
<commit_msg>Review: Fix farm depot links.<commit_after>import React from 'react'
import PropTypes from 'prop-types'
import _ from 'lodash'
import i18n from '../../../i18n'
import { featurePropType } from '../../../common/geoJsonUtils'

const Products = ({ products, category }) => {
  if (products && products.length > 0) {
    return (
      <div>
        <h4>{i18n.t(`productcategories.${category}`)}</h4>
        <ul>
          {products.map(({ name }) => (
            <li key={name}>{i18n.t(`products.${name}`)}</li>
          ))}
        </ul>
      </div>
    )
  }
  return null
}

const AdditionalInfo = ({ feature }) => {
  if (feature.additionalProductInformation) {
    return (
      <div>
        <h4>Zusätzliche Informationen zum Lebensmittelangebot</h4>
        <p>{feature.additionalProductInformation}</p>
      </div>
    )
  }
  return null
}

const EcologicalBehavior = ({ feature }) => {
  const {properties: {actsEcological, economicalBehavior}} = feature
  if (actsEcological || economicalBehavior) {
    const actsEcologicalText = actsEcological ? (
      <li>Dieser Hof wirtschaftet ökologisch.</li>
    ) : (
      ''
    )
    const ecologicalBehaviorText = economicalBehavior ? (
      <li>{economicalBehavior}</li>
    ) : (
      ''
    )
    return (
      <div>
        <h4>Wirtschaftsweise</h4>
        <ul>
          {actsEcologicalText}
          {ecologicalBehaviorText}
        </ul>
      </div>
    )
  }
  return null
}

const AssociatedPlaces = ({ featureCollection }) => {
  debugger
  return (featureCollection && featureCollection.features.length > 0) ? (
    <div>
      <h4>{i18n.t('details.connected_depots')}</h4>
      <ul>
        {featureCollection.features.map(({ properties: { id, type, name } }) => (
          <li key={id} className={type.toLowerCase()}>
            <a href={`#depots/${id}`} title={name}>
              {name}
            </a>
          </li>
        ))}
      </ul>
    </div>
  ) : null
}

const Participation = participation => (
  <div>
    <h4>Mitgliederbeteiligung</h4>
    <p>{participation}</p>
  </div>
)

const MaxMembers = members => (
  <div>
    <b>Maximale Mitgliederzahl:</b> {members}
  </div>
)

const FarmDescription = ({ feature }) => {
  const {properties: {products, depots, participation, maximumMembers}} = feature
  debugger
  return (
    <div>
      {_.map(_.groupBy(products, p => p.category), (p, c) => (
        <Products products={p} category={c}/>
      ))}
      <AdditionalInfo feature={feature}/>
      <EcologicalBehavior feature={feature}/>
      <AssociatedPlaces featureCollection={depots}/>

      {participation && Participation(participation)}
      {maximumMembers && MaxMembers(maximumMembers)}
    </div>
  )
}

AdditionalInfo.propTypes = {
  feature: PropTypes.shape({
    additionalProductInformation: PropTypes.string
  }).isRequired
}

{'fraction_non_alphanumeric': 0.16242380781642166, 'fraction_numerical': 0.007888131946934385, 'mean_word_length': 2.53324889170361, 'pattern_counts': {'":': 0, '<': 103, '<?xml version=': 0, '>': 129, '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': '4666591', 'n_tokens_mistral': 1816, 'n_tokens_neox': 1789, 'n_words': 335}