import { useEffect, useRef, useState } from "react"; import type { PageProps } from "keycloakify/login/pages/PageProps"; import type { KcContext } from "../KcContext"; import type { I18n } from "../i18n"; import { Button } from "@/components/ui/button"; export default function QrLoginScan(props: PageProps, I18n>) { const { kcContext, i18n, doUseDefaultCss, Template, classes } = props; const { url, QRauthImage, QRauthExecId, QRauthToken, tabId, alignment, ShortCode, ShortCodeLink, refreshRate = 15 } = kcContext; const { msg, msgStr } = i18n; const formRef = useRef(null); const [showShortCode, setShowShortCode] = useState(false); useEffect(() => { const timer = setTimeout(() => { formRef.current?.requestSubmit(); }, refreshRate * 1000); return () => clearTimeout(timer); }, [refreshRate]); useEffect(() => { const params = new URLSearchParams(window.location.search); if (params.get("qr_code_originated") === "true") { const el = document.getElementById("com-hadleyso-qr-auth"); if (el) el.style.display = "none"; } }, []); const qrContainerStyle: React.CSSProperties = { width: "45%", marginLeft: alignment === "Center" ? "auto" : alignment === "Right" ? "auto" : undefined, marginRight: alignment === "Center" || alignment === "Left" ? "auto" : undefined }; return ( ); }