'use strict';
import React from 'react';
import Button from 'react-bootstrap/lib/Button';
import Form from './form';
import Property from './property';
import InputTextAreaToggable from './input_textarea_toggable';
import InputDate from './input_date';
import InputCheckbox from './input_checkbox';
import LoanContractStore from '../../stores/loan_contract_store';
import LoanContractActions from '../../actions/loan_contract_actions';
import AppConstants from '../../constants/application_constants';
import { getLangText } from '../../utils/lang_utils';
let LoanForm = React.createClass({
propTypes: {
url: React.PropTypes.string,
id: React.PropTypes.object,
message: React.PropTypes.string,
handleSuccess: React.PropTypes.func
},
getInitialState() {
return LoanContractStore.getState();
},
componentDidMount() {
LoanContractStore.listen(this.onChange);
LoanContractActions.flushLoanContract();
},
componentWillUnmount() {
LoanContractStore.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
},
getFormData(){
return this.props.id;
},
handleOnBlur(event) {
LoanContractActions.fetchLoanContract(event.target.value);
},
getContractCheckbox() {
if(this.state.contractKey && this.state.contractUrl) {
// we need to define a key on the InputCheckboxes as otherwise
// react is not rerendering them on a store switch and is keeping
// the default value of the component (which is in that case true)
return (