mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Simplify the QR code component (#9828)
This commit is contained in:
parent
e72f943951
commit
974ba4f691
@ -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…
x
Reference in New Issue
Block a user