'use strict'; import React from 'react'; import { History } from 'react-router'; 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 InputTextAreaToggable from './input_textarea_toggable'; import ApiUrls from '../../constants/api_urls'; import AscribeSpinner from '../ascribe_spinner'; import { getLangText } from '../../utils/lang_utils'; import { mergeOptions } from '../../utils/general_utils'; let SendContractAgreementForm = React.createClass({ propTypes: { handleSuccess: React.PropTypes.func }, mixins: [History], 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() { const notification = new GlobalNotificationModel(getLangText('Contract agreement sent'), 'success', 10000); GlobalNotificationActions.appendGlobalNotification(notification); this.history.push('/collection'); }, getFormData() { const appendixValue = this.refs.form.refs.appendix.state.value; if (appendixValue) { return { 'appendix': { 'default': appendixValue } }; } }, getContracts() { if (this.state.contractList && this.state.contractList.length > 0) { let contractList = this.state.contractList; return ( ); } return null; }, render() { if (this.state.contractList && this.state.contractList.length) { return (
{getLangText('Send contract')} } spinner={ }>

{getLangText('Contract form')}

{this.getContracts()} {getLangText('Appendix')} {/* We're using disabled on a form here as PropertyCollapsible currently does not support the disabled + overrideForm functionality */}
); } else { return (

{getLangText('No contracts uploaded yet, please go to the ')} {getLangText('contract settings page')} {getLangText(' and create them.')}

); } } }); export default SendContractAgreementForm;