import React from 'react'; import PropTypes from 'prop-types'; import { Input, Button, Modal, NgIf } from './'; import { prompt } from '../helpers/'; import { Popup } from './popup'; import { t } from '../locales/'; export class ModalPrompt extends Popup { constructor(props){ super(props); } componentDidMount(){ prompt.subscribe((text, okCallback, cancelCallback, type) => { this.setState({ appear: true, value: '', error: null, type: type || 'text', text: text || '', fns: {ok: okCallback, cancel: cancelCallback} }); }); } onSubmit(e){ e && e.preventDefault && e.preventDefault(); this.state.fns.ok(this.state.value) .then(() => this.setState({appear: false})) .catch((message) => this.setState({error: message})); } modalContentBody(){ return (
{this.state.text }
this.setState({value: e.target.value})} />
{this.state.error} 
); } modalContentFooter(){ return (
); } }