import { useState } from "react"; import { Form, Input, Checkbox, Button, Divider, Typography, Space, Row, Col, FormProps } from "antd"; import type { PageProps } from "keycloakify/login/pages/PageProps"; import type { KcContext } from "../KcContext"; import type { I18n } from "../i18n"; import { kcSanitize } from "keycloakify/lib/kcSanitize"; import * as FaIcons from "react-icons/fa6"; import type { IconType } from "react-icons"; const { Text, Link } = Typography; export default function LoginUsername(props: PageProps, I18n>) { const { kcContext, i18n, Template } = props; const [isLoading, setIsLoading] = useState(false); const [form] = Form.useForm(); const { social, realm, url, usernameHidden, login, registrationDisabled } = kcContext; const { msg, msgStr } = i18n; // Function to dynamically fetch the correct icon const getIconComponent = (alias: string): IconType | undefined => { const formattedAlias = alias .split("-") .map(word => word.charAt(0).toUpperCase() + word.slice(1)) .join(""); const iconName = `Fa${formattedAlias}`; return (FaIcons as Record)[iconName]; }; type FieldType = { string: string; }; const onFinish: FormProps["onFinish"] = async values => { setIsLoading(true); // Create a new form element const form = document.createElement("form"); form.method = "POST"; form.action = url.loginAction; // Append input fields to the form Object.entries(values).forEach(([key, value]) => { const input = document.createElement("input"); input.type = "hidden"; input.name = key; input.value = value.toString(); form.appendChild(input); }); // Append form to the body and submit document.body.appendChild(form); form.submit(); }; const inputPrefix = realm.registrationEmailAsUsername ? ( ) : ( ); return ( ); }