import React from 'react' class SMS extends React.Component { constructor() { super() this.handleChange = this.handleChange.bind(this) this.addRecipient = this.addRecipient.bind(this) this.submitForm = this.submitForm.bind(this) } handleChange (event) { event.preventDefault() this.props.smsActions.changeForm({ sender: this.sender.value, body: this.body.value, newRecipient: this.newRecipient.value }) } submitForm (event) { event.preventDefault() const state = this.props.sms this.props.smsActions.sendSMSRequest(state) } addRecipient (event) { event.preventDefault() this.props.smsActions.addRecipient(this.newRecipient.value) } removeRecipient (key, event) { event.preventDefault() this.props.smsActions.removeRecipient(key) } setRecipients (value, event) { event.preventDefault() this.props.smsActions.setRecipients(value) } render () { const state = this.props.sms const { sender, body, newRecipient } = state return (
Guthaben: {state.credit}
{state.recipients.filter(recipient => (typeof recipient === 'string') || recipient.phone).length} von {state.recipients.length} mit Telefonnummer
{state.recipients.length ?{this.setRecipients([], event)}}>{'\u2716'} Alle löschen
: null}