import { useState, memo } from "react"; import { Template } from "./Template"; import type { KcPagesProperties } from "./KcProperties"; import { defaultKcPagesProperties } from "./KcProperties"; import { assert } from "../tools/assert"; import { kcContext } from "../kcContext"; import { useKcTranslation } from "../i18n/useKcTranslation"; import { cx } from "tss-react"; import { useConstCallback } from "powerhooks"; export type LoginProps = { kcProperties?: KcPagesProperties; }; export const Login = memo((props: LoginProps) => { const { kcProperties = {} } = props; const { t, tStr } = useKcTranslation(); Object.assign(kcProperties, defaultKcPagesProperties); const [{ social, realm, url, usernameEditDisabled, login, auth, registrationDisabled }] = useState(() => { assert( kcContext !== undefined && kcContext.pageBasename === "login.ftl" ); console.log(kcContext); return kcContext; }); const [isLoginButtonDisabled, setIsLoginButtonDisabled] = useState(false); const onSubmit = useConstCallback(() => (setIsLoginButtonDisabled(true), true) ); const [ usernameInputValue, setUsernameInputValue ] = useState(login.username ?? ''); const onUsernameChange = useConstCallback( (event: React.ChangeEvent)=> setUsernameInputValue(event.target.value) ); return (