import { useEffect, useReducer } from "react"; import { clsx } from "keycloakify/tools/clsx"; import { assert } from "tsafe/assert"; import { useGetClassName } from "keycloakify/login/lib/useGetClassName"; import type { PageProps } from "keycloakify/login/pages/PageProps"; import type { KcContext } from "../KcContext"; import { useI18n, type I18n } from "../i18n"; export default function LoginUpdatePassword(props: PageProps>) { const { kcContext, doUseDefaultCss, Template, classes } = props; const { getClassName } = useGetClassName({ doUseDefaultCss, classes }); const i18n = useI18n({ kcContext }); const { msg, msgStr } = i18n; const { url, messagesPerField, isAppInitiatedAction } = kcContext; return ( ); } function LogoutOtherSessions(props: { getClassName: ReturnType["getClassName"]; i18n: I18n }) { const { getClassName, i18n } = props; const { msg } = i18n; return (
); } function PasswordWrapper(props: { getClassName: ReturnType["getClassName"]; i18n: I18n; passwordInputId: string; children: JSX.Element; }) { const { getClassName, i18n, passwordInputId, children } = props; const { msgStr } = i18n; const [isPasswordRevealed, toggleIsPasswordRevealed] = useReducer((isPasswordRevealed: boolean) => !isPasswordRevealed, false); useEffect(() => { const passwordInputElement = document.getElementById(passwordInputId); assert(passwordInputElement instanceof HTMLInputElement); passwordInputElement.type = isPasswordRevealed ? "text" : "password"; }, [isPasswordRevealed]); return (
{children}
); }