2024-06-06 01:44:57 +02:00
|
|
|
import { Suspense, lazy } from "react";
|
2024-06-06 05:26:06 +02:00
|
|
|
import type { PageProps } from "keycloakify/login";
|
2024-06-06 01:44:57 +02:00
|
|
|
import type { KcContext } from "./KcContext";
|
|
|
|
|
import { useI18n } from "./i18n";
|
|
|
|
|
import { useDownloadTerms } from "keycloakify/login";
|
2024-06-06 05:26:06 +02:00
|
|
|
import Template from "keycloakify/login/Template";
|
2024-06-06 01:44:57 +02:00
|
|
|
const Fallback = lazy(() => import("keycloakify/login/Fallback"));
|
2024-06-06 05:26:06 +02:00
|
|
|
const UserProfileFormFields = lazy(() => import("keycloakify/login/UserProfileFormFields"));
|
|
|
|
|
|
|
|
|
|
const classes = {} satisfies PageProps["classes"];
|
2024-06-06 01:44:57 +02:00
|
|
|
|
|
|
|
|
export default function KcApp(props: { kcContext: KcContext }) {
|
|
|
|
|
const { kcContext } = props;
|
|
|
|
|
|
|
|
|
|
const i18n = useI18n({ kcContext });
|
|
|
|
|
|
|
|
|
|
useDownloadTerms({
|
|
|
|
|
kcContext,
|
|
|
|
|
downloadTermMarkdown: async ({ currentLanguageTag }) => {
|
|
|
|
|
const termsFileName = (() => {
|
|
|
|
|
switch (currentLanguageTag) {
|
2024-06-06 05:26:06 +02:00
|
|
|
case "fr":
|
|
|
|
|
return "fr.md";
|
|
|
|
|
case "es":
|
|
|
|
|
return "es.md";
|
|
|
|
|
default:
|
|
|
|
|
return "en.md";
|
2024-06-06 01:44:57 +02:00
|
|
|
}
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
// The files are in the public directory.
|
|
|
|
|
const response = await fetch(`${import.meta.env}terms/${termsFileName}`);
|
|
|
|
|
|
|
|
|
|
return response.text();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (i18n === null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Suspense>
|
|
|
|
|
{(() => {
|
|
|
|
|
switch (kcContext.pageId) {
|
|
|
|
|
default:
|
2024-06-06 05:26:06 +02:00
|
|
|
return (
|
|
|
|
|
<Fallback
|
|
|
|
|
{...{
|
|
|
|
|
kcContext,
|
|
|
|
|
i18n,
|
|
|
|
|
classes,
|
|
|
|
|
Template,
|
|
|
|
|
UserProfileFormFields
|
|
|
|
|
}}
|
|
|
|
|
doUseDefaultCss={true}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2024-06-06 01:44:57 +02:00
|
|
|
}
|
|
|
|
|
})()}
|
|
|
|
|
</Suspense>
|
|
|
|
|
);
|
|
|
|
|
}
|