blob: 99134a466c5a218fe24d984d0280432e8a8420c8 (
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/send-row-error-message.container'
export default class SendRowWrapper extends Component {
static propTypes = {
label: PropTypes.string,
showError: PropTypes.bool,
children: PropTypes.node,
errorType: PropTypes.string,
};
render () {
const {
label,
errorType = '',
showError = false,
children,
} = this.props
let formField = Array.isArray(children) ? children[1] || children[0] : children
let 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,
}
|