import { useEffect, useState } from "react"; import { Typography, Spin, Flex } from "antd"; import { LoadingOutlined } from "@ant-design/icons"; import type { PageProps } from "keycloakify/login/pages/PageProps"; import type { KcContext } from "../KcContext"; import type { I18n } from "../i18n"; const { Text } = Typography; export default function SamlPostForm(props: PageProps, I18n>) { const { kcContext, i18n, doUseDefaultCss, Template, classes } = props; const { msgStr, msg } = i18n; const { samlPost } = kcContext; const [htmlFormElement, setHtmlFormElement] = useState(null); // Custom spinner icon const antIcon = ; // Handle form submission useEffect(() => { if (htmlFormElement === null) { return; } // Storybook if (samlPost.url === "#") { alert("In a real Keycloak the user would be redirected immediately"); return; } // Submit the form after a brief delay to show the loading animation const timeoutId = setTimeout(() => { htmlFormElement.submit(); }, 1500); return () => clearTimeout(timeoutId); }, [htmlFormElement, samlPost.url]); return ( ); }