<commit_before>import _ from 'lodash';
// We have to remove node_modules/react to avoid having multiple copies loaded.
// eslint-disable-next-line import/no-unresolved
import React, { Component, PropTypes } from 'react';
import Paneset from '@folio/stripes-components/lib/Paneset';
import Pane from '@folio/stripes-components/lib/Pane';
import PaneMenu from '@folio/stripes-components/lib/PaneMenu';
import MultiColumnList from '@folio/stripes-components/lib/MultiColumnList';

class LoansHistory extends Component {

  static propTypes = {
    data: PropTypes.shape({
      loansHistory: PropTypes.arrayOf(PropTypes.object),
      userid: PropTypes.object.required,
    }),
    mutator: PropTypes.shape({
      users: React.PropTypes.shape({
        PUT: React.PropTypes.func.isRequired,
      }),
      userid: PropTypes.shape({
        replace: PropTypes.func,
      }),
    }),
    userid: PropTypes.object.isRequired,
    onCancel: PropTypes.func.isRequired,
  };

  static manifest = Object.freeze({
    loansHistory: {
      type: 'okapi',
      records: 'loans',
      GET: {
        path: 'circulation/loans?query=(userId=${userid})',
      },
    },
    userid: {},
  });

  constructor(props) {
    super(props);
    props.mutator.userid.replace(props.userid);
  }

  componentWillReceiveProps(nextProps) {
    this.props.mutator.userid.replace(nextProps.userid);
  }

  render() {
    const { data: { loansHistory } } = this.props;

    if (!loansHistory) return <div />;

    const historyFirstMenu = <PaneMenu><button onClick={this.props.onCancel} title="close" aria-label="Close Loans History"><span style={{ fontSize: '30px', color: '#999', lineHeight: '18px' }} >&times;</span></button></PaneMenu>;

    const loansFormatter = {
      title: loan => `${_.get(loan, ['item', 'title'], '')}`,
      barcode: loan => `${_.get(loan, ['item', 'barcode'], '')}`,
      status: loan => `${_.get(loan, ['status', 'name'], '')}`,
      loanDate: loan => loan.loanDate.substr(0, 10),
    };

    return (
      <Paneset>
        <Pane defaultWidth="100%" firstMenu={historyFirstMenu} paneTitle={'Loans History'}>
          <MultiColumnList
            fullWidth
            formatter={loansFormatter}
            visibleColumns={['title', 'barcode', 'loanDate', 'status']}
            contentData={loansHistory}
          />
        </Pane>
      </Paneset>);
  }
}

export default LoansHistory;<commit_msg>Add return date to loan history display<commit_after>import _ from 'lodash';
// We have to remove node_modules/react to avoid having multiple copies loaded.
// eslint-disable-next-line import/no-unresolved
import React, { Component, PropTypes } from 'react';
import Paneset from '@folio/stripes-components/lib/Paneset';
import Pane from '@folio/stripes-components/lib/Pane';
import PaneMenu from '@folio/stripes-components/lib/PaneMenu';
import MultiColumnList from '@folio/stripes-components/lib/MultiColumnList';

class LoansHistory extends Component {

  static propTypes = {
    data: PropTypes.shape({
      loansHistory: PropTypes.arrayOf(PropTypes.object),
      userid: PropTypes.object.required,
    }),
    mutator: PropTypes.shape({
      users: React.PropTypes.shape({
        PUT: React.PropTypes.func.isRequired,
      }),
      userid: PropTypes.shape({
        replace: PropTypes.func,
      }),
    }),
    userid: PropTypes.object.isRequired,
    onCancel: PropTypes.func.isRequired,
  };

  static manifest = Object.freeze({
    loansHistory: {
      type: 'okapi',
      records: 'loans',
      GET: {
        path: 'circulation/loans?query=(userId=${userid})',
      },
    },
    userid: {},
  });

  constructor(props) {
    super(props);
    props.mutator.userid.replace(props.userid);
  }

  componentWillReceiveProps(nextProps) {
    this.props.mutator.userid.replace(nextProps.userid);
  }

  render() {
    const { data: { loansHistory } } = this.props;

    if (!loansHistory) return <div />;

    const historyFirstMenu = <PaneMenu><button onClick={this.props.onCancel} title="close" aria-label="Close Loans History"><span style={{ fontSize: '30px', color: '#999', lineHeight: '18px' }} >&times;</span></button></PaneMenu>;

    const loansFormatter = {
      title: loan => `${_.get(loan, ['item', 'title'], '')}`,
      barcode: loan => `${_.get(loan, ['item', 'barcode'], '')}`,
      status: loan => `${_.get(loan, ['status', 'name'], '')}`,
      loanDate: loan => loan.loanDate.substr(0, 10),
      returnDate: loan => (loan.returnDate ? loan.returnDate.substr(0, 10) : ''),
    };

    return (
      <Paneset>
        <Pane defaultWidth="100%" firstMenu={historyFirstMenu} paneTitle={'Loans History'}>
          <MultiColumnList
            fullWidth
            formatter={loansFormatter}
            visibleColumns={['title', 'barcode', 'loanDate', 'returnDate', 'status']}
            contentData={loansHistory}
          />
        </Pane>
      </Paneset>);
  }
}

export default LoansHistory;
{'fraction_non_alphanumeric': 0.15858585858585858, 'fraction_numerical': 0.005858585858585859, 'mean_word_length': 3.2388698630136985, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 36, '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': '56942', 'n_tokens_mistral': 1543, 'n_tokens_neox': 1514, 'n_words': 305}