text: /* eslint max-len: 0 */
  /* eslint no-unused-vars: 0 */
  import React from 'react';
  import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';
  
  
  const jobs = [];
  const jobTypes = [ 'A', 'B', 'C', 'D' ];
  
  function addJobs(quantity) {
    const startId = jobs.length;
    for (let i = 0; i < quantity; i++) {
      const id = startId + i;
      jobs.push({
        id: id,
        status: '200',
        name: 'Item name ' + id,
        type: 'B',
        active: i % 2 === 0 ? 'Y' : 'N'
      });
    }
  }
  
  addJobs(5);
  
  const cellEditProp = {
    mode: 'click',
    blurToSave: true
  };
  
  // validator function pass the user input value and row object. In addition, a bool return value is expected
  function jobNameValidator(value, row) {
    const response = { isValid: true, notification: { type: 'success', msg: '', title: '' } };
    if (!value) {
      response.isValid = false;
      response.notification.type = 'error';
      response.notification.msg = 'Value must be inserted';
      response.notification.title = 'Requested Value';
    } else if (value.length < 10) {
      response.isValid = false;
      response.notification.type = 'error';
      response.notification.msg = 'Value must have 10+ characters';
      response.notification.title = 'Invalid Value';
    }
    return response;
  }
  
  function jobStatusValidator(value, row) {
    const nan = isNaN(parseInt(value, 10));
    if (nan) {
      return 'Job Status must be a integer!';
    }
    return true;
  }
  
  export default class EditTypeTable extends React.Component {
    render() {
      return (
        <BootstrapTable data={ jobs } cellEdit={ cellEditProp } insertRow={ true }>
            <TableHeaderColumn dataField='id' isKey={ true }>Job ID</TableHeaderColumn>
            <TableHeaderColumn dataField='status' editable={ { validator: jobStatusValidator } }>Job Status</TableHeaderColumn>
            <TableHeaderColumn dataField='name' editable={ { type: 'textarea', validator: jobNameValidator } }>Job Name</TableHeaderColumn>
            <TableHeaderColumn dataField='type' editable={ { type: 'select', options: { values: jobTypes } } }>Job Type</TableHeaderColumn>
            <TableHeaderColumn dataField='active' editable={ { type: 'checkbox', options: { values: 'Y:N' } } }>Active</TableHeaderColumn>
        </BootstrapTable>
      );
    }
  }
  