import React, { useEffect, memo } from "react"; import Template 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 { useCssAndCx } from "../tools/useCssAndCx"; import type { I18n } from "../i18n"; const LoginOtp = memo( ({ kcContext, i18n, doFetchDefaultThemeResources = true, ...props }: { kcContext: KcContextBase.LoginOtp; i18n: I18n; doFetchDefaultThemeResources?: boolean } & KcProps) => { const { otpLogin, url } = kcContext; const { cx } = useCssAndCx(); 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 (