Skip to content

Commit

Permalink
[ES-1410] Handled QR-Code click event functionality for Inji login. (m…
Browse files Browse the repository at this point in the history
…osip#848)

Signed-off-by: Gk <76690271+gk-4VII@users.noreply.github.com>
  • Loading branch information
gk-4VII authored Aug 19, 2024
1 parent 453711e commit ef219db
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions oidc-ui/src/components/LoginQRCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export default function LoginQRCode({
const [error, setError] = useState(null);
const [qrCodeTimeOut, setQrCodeTimeout] = useState();
const [errorBanner, setErrorBanner] = useState(null);

const [qrRedirectUrl, setQrRedirectUrl] = useState("");

const linkedTransactionExpireInSec =
openIDConnectService.getEsignetConfiguration(
configurationKeys.linkedTransactionExpireInSecs
Expand Down Expand Up @@ -79,6 +80,8 @@ export default function LoginQRCode({
response.expireDateTime
);

setQrRedirectUrl(text);

const canvas = document.createElement("canvas");
QRCode.toCanvas(
canvas,
Expand Down Expand Up @@ -436,6 +439,11 @@ export default function LoginQRCode({
setErrorBanner(null);
};

const handleQRCode = () => {
window.onbeforeunload = null;
window.location.href = qrRedirectUrl;
};

return (
<>
<div className="grid grid-cols-8 items-center">
Expand Down Expand Up @@ -475,8 +483,8 @@ export default function LoginQRCode({
)}
{qr && (
<div className="w-full flex justify-center">
<div className="border border-4 qrcode-border rounded-3xl p-2">
<img id="wallet-qr-code" src={qr} style={{ height: "186px", width: "186px" }} />
<div className="border border-4 qrcode-border rounded-3xl p-2 hover:cursor-pointer onClick={handleQRCode}">
<img id="wallet-qr-code" src={qr} style={{ height: "186px", width: "186px" }} alt="wallet-qr-code"/>
</div>
</div>
)}
Expand Down

0 comments on commit ef219db

Please sign in to comment.