keycloak-theme/src/login/KcApp.tsx

60 lines
2 KiB
TypeScript
Raw Normal View History

2024-06-06 01:44:57 +02:00
import { Suspense, lazy } from "react";
2024-06-08 09:03:17 +02:00
import type { ClassKey } from "keycloakify/login";
2024-06-06 01:44:57 +02:00
import type { KcContext } from "./KcContext";
import { useDownloadTerms } from "keycloakify/login";
2024-06-09 10:24:14 +02:00
import Fallback from "keycloakify/login/Fallback";
2024-06-06 05:26:06 +02:00
import Template from "keycloakify/login/Template";
const UserProfileFormFields = lazy(() => import("keycloakify/login/UserProfileFormFields"));
2024-06-09 10:24:14 +02:00
const doMakeUserConfirmPassword = true;
2024-06-06 01:44:57 +02:00
export default function KcApp(props: { kcContext: KcContext }) {
const { kcContext } = props;
useDownloadTerms({
kcContext,
2024-06-07 05:20:57 +02:00
downloadTermsMarkdown: async ({ currentLanguageTag }) => {
let termsLanguageTag = currentLanguageTag;
let termsFileName: string;
switch (currentLanguageTag) {
case "fr":
termsFileName = "fr.md";
break;
case "es":
termsFileName = "es.md";
break;
default:
termsFileName = "en.md";
termsLanguageTag = "en";
break;
}
2024-06-06 01:44:57 +02:00
2024-06-07 05:20:57 +02:00
const termsMarkdown = await fetch(`${import.meta.env.BASE_URL}terms/${termsFileName}`).then(r => r.text());
2024-06-06 01:44:57 +02:00
2024-06-07 05:20:57 +02:00
return { termsMarkdown, termsLanguageTag };
2024-06-06 01:44:57 +02:00
}
});
return (
<Suspense>
{(() => {
switch (kcContext.pageId) {
default:
2024-06-06 05:26:06 +02:00
return (
<Fallback
2024-06-09 10:24:14 +02:00
kcContext={kcContext}
classes={classes}
Template={Template}
2024-06-06 05:26:06 +02:00
doUseDefaultCss={true}
2024-06-09 10:24:14 +02:00
UserProfileFormFields={UserProfileFormFields}
doMakeUserConfirmPassword={doMakeUserConfirmPassword}
2024-06-06 05:26:06 +02:00
/>
);
2024-06-06 01:44:57 +02:00
}
})()}
</Suspense>
);
}
2024-06-09 10:24:14 +02:00
const classes = {} satisfies { [key in ClassKey]?: string };