import React, { Component } from 'react' import PropTypes from 'prop-types' import actions from '../../actions' import MissionSelect2 from './select2s/MissionSelect2' import CompanySelect2 from './select2s/CompanySelect2' import CustomFieldsInputs from '../../../helpers/CustomFieldsInputs' export default class CreateModal extends Component { constructor(props) { super(props) this.custom_fields = _.assign({}, this.props.custom_fields) _.map(this.custom_fields, (cf, k)=>{ if(cf.options && cf.options.default){ this.custom_fields[k]["value"] = cf.options.default } }) } handleSubmit() { if(!this.props.modal.modalProps.selectedJPModal){ let field = $('#NewVehicleJourneyModal').find(".vjCreateSelectJP") field.parent().parent().addClass('has-error') field.parent().children('.help-block').remove() field.parent().append("" + I18n.t("simple_form.required.text") + "") return } if (actions.validateFields(...this.refs, $('.vjCreateSelectJP')[0])) { this.props.onAddVehicleJourney(_.assign({}, this.refs, {custom_fields: this.custom_fields}), this.props.modal.modalProps.selectedJPModal, this.props.stopPointsList, this.props.modal.modalProps.vehicleJourney && this.props.modal.modalProps.vehicleJourney.company) this.props.onModalClose() $('#NewVehicleJourneyModal').modal('hide') } } render() { if(this.props.status.isFetching == true) { return false } if(this.props.status.fetchSuccess == true) { return (