2018-04-07 00:29:51 +02:00
|
|
|
import React, { Component } from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import SendRowErrorMessage from './send-row-error-message/send-row-error-message.container'
|
|
|
|
|
|
|
|
export default class SendRowWrapper extends Component {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
children: PropTypes.node,
|
|
|
|
errorType: PropTypes.string,
|
2018-04-27 02:38:14 +02:00
|
|
|
label: PropTypes.string,
|
|
|
|
showError: PropTypes.bool,
|
2018-04-07 00:29:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const {
|
2018-04-27 02:38:14 +02:00
|
|
|
children,
|
|
|
|
errorType = '',
|
|
|
|
label,
|
|
|
|
showError = false,
|
2018-04-07 00:29:51 +02:00
|
|
|
} = this.props
|
|
|
|
|
2018-04-27 02:38:14 +02:00
|
|
|
const formField = Array.isArray(children) ? children[1] || children[0] : children
|
2018-04-30 18:03:49 +02:00
|
|
|
const customLabelContent = children.length > 1 ? children[0] : null
|
2018-04-11 16:21:54 +02:00
|
|
|
|
2018-04-07 00:29:51 +02:00
|
|
|
return (
|
|
|
|
<div className="send-v2__form-row">
|
|
|
|
<div className="send-v2__form-label">
|
|
|
|
{label}
|
2018-04-26 18:38:38 +02:00
|
|
|
{showError && <SendRowErrorMessage errorType={errorType}/>}
|
2018-04-11 16:21:54 +02:00
|
|
|
{customLabelContent}
|
2018-04-07 00:29:51 +02:00
|
|
|
</div>
|
|
|
|
<div className="send-v2__form-field">
|
2018-04-11 16:21:54 +02:00
|
|
|
{formField}
|
2018-04-07 00:29:51 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-04-27 02:38:14 +02:00
|
|
|
)
|
2018-04-07 00:29:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SendRowWrapper.contextTypes = {
|
|
|
|
t: PropTypes.func,
|
|
|
|
}
|