'use strict'; import React from 'react'; import ContractListActions from '../../actions/contract_list_actions'; import ContractListStore from '../../stores/contract_list_store'; import GlobalNotificationModel from '../../models/global_notification_model'; import GlobalNotificationActions from '../../actions/global_notification_actions'; import Form from './form'; import Property from './property'; import PropertyCollapsible from './property_collapsible'; import InputTextAreaToggable from './input_textarea_toggable'; import ApiUrls from '../../constants/api_urls'; import { getLangText } from '../../utils/lang_utils'; import { mergeOptions } from '../../utils/general_utils'; let ContractAgreementForm = React.createClass({ propTypes: { handleSuccess: React.PropTypes.func }, getInitialState() { return mergeOptions( ContractListStore.getState(), { selectedContract: 0 } ); }, componentDidMount() { ContractListStore.listen(this.onChange); ContractListActions.fetchContractList(true, false); }, componentWillUnmount() { ContractListStore.unlisten(this.onChange); }, onChange(state) { this.setState(state); }, onContractChange(event){ this.setState({selectedContract: event.target.selectedIndex}); }, handleSubmitSuccess() { let notification = 'Contract agreement send'; notification = new GlobalNotificationModel(notification, 'success', 10000); GlobalNotificationActions.appendGlobalNotification(notification); this.refs.form.reset(); }, getFormData(){ return {'appendix': {'default': this.refs.form.refs.appendix.state.value}}; }, getContracts() { if (this.state.contractList && this.state.contractList.length > 0) { let contractList = this.state.contractList; return ( {getLangText('Learn more')} }> ); } return null; }, render() { if (this.state.contractList && this.state.contractList.length > 0) { return (
{getLangText('Send loan request')} } spinner={ }>

{getLangText('Contract form')}

{this.getContracts()} {getLangText('Appendix')}
); } return (

{getLangText('No private contracts found, please go to the ')} {getLangText('settings page')} {getLangText(' and create them.')}

); } }); export default ContractAgreementForm;