add pix qr code to deposit order

This commit is contained in:
João Geonizeli
2021-09-06 00:38:48 -03:00
parent c7a799af1e
commit 3529773c61
23 changed files with 843 additions and 221 deletions

View File

@@ -0,0 +1,33 @@
import { useEffect, useState } from "react";
import { QrCodePix } from "qrcode-pix";
type Props = {
value: number;
transactionId: string;
};
export const usePixQr = ({ value, transactionId }: Props) => {
const [qr, setQr] = useState<string>();
const qrCodePix = QrCodePix({
version: "01",
key: "joao.geonizeli@gmail.com",
name: "X Stake",
city: "TERESOPOLIS",
transactionId,
value,
notRepeatPayment: true,
});
useEffect(() => {
qrCodePix.base64().then((result) => {
setQr(result);
});
}, []);
return {
payload: qrCodePix.payload(),
loading: !qr,
qr,
};
};