blob: f484bd8d92d63629e5a77d5931ca28ca4273f298 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import SendRowErrorMessage from './send-row-error-message/'
export default class SendRowWrapper extends Component {
static propTypes = {
children: PropTypes.node,
errorType: PropTypes.string,
label: PropTypes.string,
showError: PropTypes.bool,
};
render () {
const {
children,
errorType = '',
label,
showError = false,
} = this.props
const formField = Array.isArray(children) ? children[1] || children[0] : children
const customLabelContent = children.length > 1 ? children[0] : null
return (
<div className="send-v2__form-row">
<div className="send-v2__form-label">
{label}
{showError && <SendRowErrorMessage errorType={errorType}/>}
{customLabelContent}
</div>
<div className="send-v2__form-field">
{formField}
</div>
</div>
)
}
}
SendRowWrapper.contextTypes = {
t: PropTypes.func,
}
|