<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import ArrayForm from '../../../arrayForm';
import SelectForm from '../../../selectForm';
import JustificationField from './justificationField';
import JustificationSummary from './justificationSummary';
import AutocompleteForm from '../../../autoCompleteForm';
import { mapValuesForSelectionField } from '../../../../../store';
import { loadPartnerNamesForAutoComplete } from '../../../../../reducers/partnerNames';

const Partners = (getPartners, readOnly, ...props) => (member, index, fields) => {
  const chosenPartners = fields.getAll().map(field => field.partner);
  const ownPartner = fields.get(index).partner;
  return (<AutocompleteForm
    fieldName={`${member}.partner`}
    label="Partner"
    async
    asyncFunction={getPartners}
    readOnly={readOnly}
    search={'legal_name'}
    {...props}
  />
  );
};

const Justification = (readOnly, ...props) => (member, index, fields) => (
  <div >
    <JustificationField
      name={member}
      disabled={!fields.get(index).partner}
      readOnly={readOnly}
      {...props}
    />
    <JustificationSummary
      name={member}
      disabled={!fields.get(index).partner}
      readOnly={readOnly}
      {...props}
    />

  </div>
);


const PartnersFieldArray = (props) => {
  const { getPartners, readOnly, ...other } = props;
  return (
    <ArrayForm
      label=""
      limit={16}
      fieldName="applications"
      initial
      readOnly={readOnly}
      {...other}
      outerField={Partners(getPartners, readOnly, ...other)}
      innerField={Justification(readOnly, ...other)}
    />
  );
};

PartnersFieldArray.propTypes = {
  getPartners: PropTypes.func,
  readOnly: PropTypes.bool,
};


export default connect(
  null,
  (dispatch, ownProps) => ({
    getPartners: params => dispatch(
      loadPartnerNamesForAutoComplete({ ...params }))
      .then(results => mapValuesForSelectionField(results)),
  }),
)(PartnersFieldArray);<commit_msg>filtering unverified partners for ds<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import ArrayForm from '../../../arrayForm';

import JustificationField from './justificationField';
import JustificationSummary from './justificationSummary';
import AutocompleteForm from '../../../autoCompleteForm';
import { mapValuesForSelectionField } from '../../../../../store';
import { loadPartnerNamesForAutoComplete } from '../../../../../reducers/partnerNames';

const Partners = (getPartners, readOnly, ...props) => member => (<AutocompleteForm
  fieldName={`${member}.partner`}
  label="Partner"
  async
  asyncFunction={getPartners}
  readOnly={readOnly}
  search={'legal_name'}
  {...props}
/>);

const Justification = (readOnly, ...props) => (member, index, fields) => (
  <div >
    <JustificationField
      name={member}
      disabled={!fields.get(index).partner}
      readOnly={readOnly}
      {...props}
    />
    <JustificationSummary
      name={member}
      disabled={!fields.get(index).partner}
      readOnly={readOnly}
      {...props}
    />

  </div>
);


const PartnersFieldArray = (props) => {
  const { getPartners, readOnly, ...other } = props;
  return (
    <ArrayForm
      label=""
      limit={16}
      fieldName="applications"
      initial
      readOnly={readOnly}
      {...other}
      outerField={Partners(getPartners, readOnly, ...other)}
      innerField={Justification(readOnly, ...other)}
    />
  );
};

PartnersFieldArray.propTypes = {
  getPartners: PropTypes.func,
  readOnly: PropTypes.bool,
};


export default connect(
  null,
  dispatch => ({
    getPartners: params => dispatch(
      loadPartnerNamesForAutoComplete({ is_verified: 'verified', ...params }))
      .then(results => mapValuesForSelectionField(results)),
  }),
)(PartnersFieldArray);
{'fraction_non_alphanumeric': 0.16859122401847576, 'fraction_numerical': 0.0010264305876315114, 'mean_word_length': 3.2882288228822882, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 32, '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': '4268199', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1153, 'n_words': 236}