import fetch from 'isomorphic-fetch'; import AppConstants from '../../constants/application_constants'; import FetchApiUtils from '../../utils/fetch_api_utils'; import React from 'react'; import Modal from 'react-bootstrap/lib/Modal'; import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger'; import ModalTrigger from 'react-bootstrap/lib/ModalTrigger'; import Tooltip from 'react-bootstrap/lib/Tooltip'; let ShareModalButton = React.createClass({ render() { return ( Share the artwork}> }>
) } }); let ShareModal = React.createClass({ render() { return (
) } }); let ShareForm = React.createClass({ getInitialState(){ return {errors: []} }, submit(e) { e.preventDefault(); let url = "http://localhost:8000/api/ownership/shares/mail/"; fetch(url, { method: 'post', headers: { 'Authorization': 'Basic ' + AppConstants.debugCredentialBase64, 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify(this.getFormData()) }) .then((response) => { if (response.status >= 200 && response.status < 300) return response response.json().then((response) => this.setState({errors: response.errors})) } ); //.then(FetchApiUtils.status) }, getFormData() { return { bitcoin_id: this.props.edition.bitcoin_id, share_emails: this.refs.share_emails.getDOMNode().value, share_message: this.refs.share_message.getDOMNode().value } }, renderTextInput(id, placeHolder, required){ return(
) }, renderTextArea(id, placeHolder, required){ return(
) }, render() { let content = "Hi,\n\nI am sharing \"" + this.props.edition.title + "\" with you.\n\nTruly yours,\n" + this.props.currentUser.username; return (
{this.renderTextInput("share_emails", "Comma separated emails", "required")} {this.renderTextArea("share_message", content, "")}
); } }); export default ShareModalButton;