import React, { useEffect, memo } from "react"; import DefaultTemplate from "./Template"; import type { TemplateProps } from "./Template"; import type { KcProps } from "./KcProps"; import type { KcContextBase } from "../getKcContext/KcContextBase"; import { headInsert } from "../tools/headInsert"; import { pathJoin } from "../../bin/tools/pathJoin"; import { clsx } from "../tools/clsx"; import type { I18n } from "../i18n"; export type LoginOtpProps = KcProps & { kcContext: KcContextBase.LoginOtp; i18n: I18n; doFetchDefaultThemeResources?: boolean; Template?: (props: TemplateProps) => JSX.Element | null; }; const LoginOtp = memo((props: LoginOtpProps) => { const { kcContext, i18n, doFetchDefaultThemeResources = true, Template = DefaultTemplate, ...kcProps } = props; const { otpLogin, url } = kcContext; const { msg, msgStr } = i18n; useEffect(() => { let isCleanedUp = false; headInsert({ "type": "javascript", "src": pathJoin(kcContext.url.resourcesCommonPath, "node_modules/jquery/dist/jquery.min.js") }).then(() => { if (isCleanedUp) return; evaluateInlineScript(); }); return () => { isCleanedUp = true; }; }, []); return (