Skip to content

Commit

Permalink
Merge pull request #5241 from swaponline/fix-qr-code-generation
Browse files Browse the repository at this point in the history
Fix: correct QR generation in deposit
  • Loading branch information
noxonsu authored May 7, 2024
2 parents 3bea301 + 05ad1b2 commit 1d8b847
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# editors

.idea
.vscode
.DS_Store
.eslintcache
*-lock.*
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
"graphql-request": "^3.4.0",
"history": "^4.9.0",
"human-standard-token-abi": "^2.0.0",
"ip": "^2.0.1",
"is-local-ip": "^1.1.0",
"jdenticon": "^3.1.0",
"json-stringify-safe": "^5.0.1",
Expand Down Expand Up @@ -272,6 +273,7 @@
"react-items-carousel": "^2.8.0",
"react-joyride": "^2.3.0",
"react-loading-skeleton": "^3.0.1",
"react-qr-code": "^2.0.12",
"react-redux": "^7.2.2",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
Expand Down
47 changes: 12 additions & 35 deletions src/front/shared/components/QR/QR.tsx
Original file line number Diff line number Diff line change
@@ -1,57 +1,34 @@
import React, { Component } from 'react'
import CSSModules from 'react-css-modules'
import animateFetching from 'components/loaders/ContentLoader/ElementLoading.scss'
import QRCode from "react-qr-code"

import styles from './QR.scss'

type ComponentProps = {
address: string
}

type ComponentState = {
qrIsLoaded: boolean
}

@CSSModules({ ...styles, ...animateFetching }, { allowMultiple: true })
export default class QR extends Component<ComponentProps, ComponentState> {
@CSSModules({ ...styles }, { allowMultiple: true })
export default class QR extends Component<ComponentProps, any> {

constructor(props) {
super(props)

this.state = {
qrIsLoaded: false,
}
}

setSuccessLoading = () => {
const { qrIsLoaded } = this.state

if (!qrIsLoaded) {
this.setState(() => ({
qrIsLoaded: true
}))
}
}

render() {
const { address } = this.props
const { qrIsLoaded } = this.state
const size = 270

return (
<>
<div className={styles.relativeWrapper}>
<div className={styles.imageWrapper}>
<img
styleName={`${qrIsLoaded ? '' : 'hiddenEl'}`}
src={`https://chart.googleapis.com/chart?chs=${size}x${size}&cht=qr&chl=${address}`}
onLoad={this.setSuccessLoading}
alt={address}
/>
<span styleName={`imageLoader ${qrIsLoaded ? 'hiddenEl' : 'animate-fetching'}`} />
</div>
<div className={styles.relativeWrapper}>
<div className={styles.imageWrapper}>
<QRCode
size={270}
value={address}
bgColor="var(--color-background)"
fgColor="var(--color)"
/>
</div>
</>
</div>
)
}
}

0 comments on commit 1d8b847

Please sign in to comment.