From f9c1cf4f741f97de4e9dc05481dcd267e71f88fc Mon Sep 17 00:00:00 2001 From: JC Date: Sat, 3 Aug 2024 16:51:04 -0600 Subject: [PATCH] fix: exporting QR codes as a PNG images --- .../receive/components/AddressBlock.tsx | 77 +++++-------------- 1 file changed, 21 insertions(+), 56 deletions(-) diff --git a/src/components/receive/components/AddressBlock.tsx b/src/components/receive/components/AddressBlock.tsx index 2acc138..0dfbfad 100644 --- a/src/components/receive/components/AddressBlock.tsx +++ b/src/components/receive/components/AddressBlock.tsx @@ -52,7 +52,6 @@ const AddressBlock: React.FC = ({ const [shieldFee, setShieldFee] = useState(0); const [anyPending, setAnyPending] = useState(false); - useEffect(() => { return () => { if (timerID) { @@ -136,6 +135,24 @@ const AddressBlock: React.FC = ({ }, 10); }; + const handleQRCodeClick = async () => { + console.log('____________ click processed'); + const canvas: HTMLCanvasElement | null = document.querySelector("canvas"); + if (canvas) { + const pngUrl = canvas + .toDataURL("image/png") + .replace("image/png", "image/octet-stream"); + let downloadLink = document.createElement("a"); + downloadLink.href = pngUrl; + downloadLink.download = "QR_" + + (type === AddressType.unified ? 'UA' : type === AddressType.sapling ? 'Z' : 'T') + + "_Zingo_PC.png"; + document.body.appendChild(downloadLink); + downloadLink.click(); + document.body.removeChild(downloadLink); + } + } + return ( @@ -179,40 +196,6 @@ const AddressBlock: React.FC = ({
{Utils.getZecToUsdString(zecPrice, balance)}
-
- {privateKey && ( -
-
Private Key
-
- {/* - // @ts-ignore */} - -
{privateKey}
-
-
- )} -
- -
- {viewKey && ( -
-
Viewing Key
-
- {/* - // @ts-ignore */} - -
{viewKey}
-
-
- )} -
-
- {/* {type === addressType.sapling && !privateKey && ( - - )} - - {type === addressType.sapling && !viewKey && ( - - )} */}
{/* - // @ts-ignore */} - + // @ts-ignore */} + +
{'Click to download'}