1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-12 20:57:12 +01:00
metamask-extension/ui/app/components/send/send-content/send-row-wrapper/send-row-wrapper.component.js

44 lines
1.0 KiB
JavaScript
Raw Normal View History

2018-04-07 00:29:51 +02:00
import React, { Component } from 'react'
import PropTypes from 'prop-types'
2018-05-15 14:29:23 +02:00
import SendRowErrorMessage from './send-row-error-message/'
2018-04-07 00:29:51 +02:00
export default class SendRowWrapper extends Component {
static propTypes = {
children: PropTypes.node,
errorType: PropTypes.string,
label: PropTypes.string,
showError: PropTypes.bool,
2018-04-07 00:29:51 +02:00
};
static contextTypes = {
t: PropTypes.func,
};
2018-04-07 00:29:51 +02:00
render () {
const {
children,
errorType = '',
label,
showError = false,
2018-04-07 00:29:51 +02:00
} = this.props
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-07 00:29:51 +02:00
}
}