Simplify the QR code component (#9828)

feature/default_network_editable
David Walsh 4 years ago committed by GitHub
parent e72f943951
commit 974ba4f691
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      ui/app/components/ui/qr-code/qr-code.js

@ -9,15 +9,17 @@ import { checksumAddress } from '../../../helpers/utils/util'
export default connect(mapStateToProps)(QrCodeView) export default connect(mapStateToProps)(QrCodeView)
function mapStateToProps(state) { function mapStateToProps(state) {
const { buyView, warning } = state.appState
return { return {
// Qr code is not fetched from state. 'message' and 'data' props are passed instead. // Qr code is not fetched from state. 'message' and 'data' props are passed instead.
buyView: state.appState.buyView, buyView,
warning: state.appState.warning, warning,
} }
} }
function QrCodeView(props) { function QrCodeView(props) {
const { message, data } = props.Qr const { Qr, warning } = props
const { message, data } = Qr
const address = `${isHexPrefixed(data) ? 'ethereum:' : ''}${checksumAddress( const address = `${isHexPrefixed(data) ? 'ethereum:' : ''}${checksumAddress(
data, data,
)}` )}`
@ -29,7 +31,7 @@ function QrCodeView(props) {
<div className="qr-code"> <div className="qr-code">
{Array.isArray(message) ? ( {Array.isArray(message) ? (
<div className="qr-code__message-container"> <div className="qr-code__message-container">
{props.Qr.message.map((msg, index) => ( {message.map((msg, index) => (
<div className="qr_code__message" key={index}> <div className="qr_code__message" key={index}>
{msg} {msg}
</div> </div>
@ -38,11 +40,7 @@ function QrCodeView(props) {
) : ( ) : (
message && <div className="qr-code__header">{message}</div> message && <div className="qr-code__header">{message}</div>
)} )}
{props.warning {warning && <span className="qr_code__error">{warning}</span>}
? props.warning && (
<span className="qr_code__error">{props.warning}</span>
)
: null}
<div <div
className="qr-code__wrapper" className="qr-code__wrapper"
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{

Loading…
Cancel
Save