<commit_before>import React from 'react'
import PropTypes from 'prop-types'

import withFetch from '../hoc/with-fetch'

import Box from '../box'
import Button from '../button'

class Producers extends React.Component {
  static propTypes = {
    organization: PropTypes.shape({
      id: PropTypes.string.isRequired
    }).isRequired,

    producers: PropTypes.arrayOf(PropTypes.shape({
      _id: PropTypes.string.isRequired,
      associatedTo: PropTypes.string
    })).isRequired,

    organizations: PropTypes.arrayOf(PropTypes.shape({
      _id: PropTypes.string.isRequired
    })).isRequired,

    associateProducer: PropTypes.func.isRequired,
    dissociateProducer: PropTypes.func.isRequired
  }

  associateProducer = producer => () => {
    const { associateProducer } = this.props

    associateProducer(producer)
  }

  dissociateProducer = producer => () => {
    const { dissociateProducer } = this.props

    dissociateProducer(producer)
  }

  render() {
    const { organization, producers, organizations } = this.props

    const linked = []
    const linkedToOthers = []
    const unlinked = []

    producers.forEach(producer => {
      if (!producer.associatedTo) {
        unlinked.push(producer)
      } else if (producer.associatedTo === organization.id) {
        linked.push(producer)
      } else {
        linkedToOthers.push({
          producer,
          organization: organizations.find(org => org._id === producer.associatedTo)
        })<commit_msg>Sort producers by name in publication<commit_after>import React from 'react'
import PropTypes from 'prop-types'

import withFetch from '../hoc/with-fetch'

import Box from '../box'
import Button from '../button'
import { sortBy, deburr } from 'lodash'

class Producers extends React.Component {
  static propTypes = {
    organization: PropTypes.shape({
      id: PropTypes.string.isRequired
    }).isRequired,

    producers: PropTypes.arrayOf(PropTypes.shape({
      _id: PropTypes.string.isRequired,
      associatedTo: PropTypes.string
    })).isRequired,

    organizations: PropTypes.arrayOf(PropTypes.shape({
      _id: PropTypes.string.isRequired
    })).isRequired,

    associateProducer: PropTypes.func.isRequired,
    dissociateProducer: PropTypes.func.isRequired
  }

  associateProducer = producer => () => {
    const { associateProducer } = this.props

    associateProducer(producer)
  }

  dissociateProducer = producer => () => {
    const { dissociateProducer } = this.props

    dissociateProducer(producer)
  }

  render() {
    const { organization, producers, organizations } = this.props

    const linked = []
    const linkedToOthers = []
    const unlinked = []

    const sortedProducers = sortBy(producers, ({ _id }) => deburr(_id))

    sortedProducers.forEach(producer => {
      if (!producer.associatedTo) {
        unlinked.push(producer)
      } else if (producer.associatedTo === organization.id) {
        linked.push(producer)
      } else {
        linkedToOthers.push({
          producer,
          organization: organizations.find(org => org._id === producer.associatedTo)
        })
{'fraction_non_alphanumeric': 0.1154712126085558, 'fraction_numerical': 0.0, 'mean_word_length': 3.1301460823373173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '5267961', 'n_tokens_mistral': 900, 'n_tokens_neox': 892, 'n_words': 189}