'use strict'; import React from 'react'; import classnames from 'classnames'; import Button from 'react-bootstrap/lib/Button'; import ContractAgreementListStore from '../../stores/contract_agreement_list_store'; import Form from './form'; import Property from './property'; import InputDate from './input_date'; import InputTextAreaToggable from './input_textarea_toggable'; import InputContractAgreementCheckbox from './input_contract_agreement_checkbox'; import AscribeSpinner from '../ascribe_spinner'; import AclInformation from '../ascribe_buttons/acl_information'; import { getLangText } from '../../utils/lang_utils'; import { mergeOptions } from '../../utils/general_utils'; let LoanForm = React.createClass({ propTypes: { loanHeading: React.PropTypes.string, buttons: React.PropTypes.element, email: React.PropTypes.string, gallery: React.PropTypes.string, startDate: React.PropTypes.object, endDate: React.PropTypes.object, showPersonalMessage: React.PropTypes.bool, showEndDate: React.PropTypes.bool, showStartDate: React.PropTypes.bool, showPassword: React.PropTypes.bool, url: React.PropTypes.string, id: React.PropTypes.object, message: React.PropTypes.string, createPublicContractAgreement: React.PropTypes.bool, handleSuccess: React.PropTypes.func, children: React.PropTypes.oneOfType([ React.PropTypes.object, React.PropTypes.array ]) }, getDefaultProps() { return { loanHeading: '', showPersonalMessage: true, showEndDate: true, showStartDate: true, showPassword: true }; }, getInitialState() { return { email: this.props.email || '' }; }, componentWillReceiveProps(nextProps) { if (this.props.email !== nextProps.email) { this.setState({ email: nextProps.email }); } }, onChange(state) { this.setState(state); }, handleEmailOnChange(event) { // event.target.value is the submitted email of the loanee this.setState({ email: event && event.target && event.target.value || '' }); }, handleReset() { this.handleEmailOnChange(); }, getFormData() { return this.props.id; }, getButtons() { const { buttons, loanHeading } = this.props; if (buttons) { return buttons; } else if (loanHeading) { return ( ); } else { return (

); } }, render() { const { email } = this.state; const { children, createPublicContractAgreement, email: defaultEmail, handleSuccess, gallery, loanHeading, message, showPersonalMessage, endDate, startDate, showEndDate, showStartDate, showPassword, url } = this.props; return (

}>

{loanHeading}

{children} ); } }); export default LoanForm;