58 lines
1.7 KiB
TypeScript
Raw Normal View History

import React, { lazy, Suspense } from "react";
import Fallback from "../../dist/login";
import type { KcContext } from "./kcContext";
import { useI18n } from "./i18n";
2023-04-20 05:41:34 +02:00
import { useDownloadTerms } from "../../dist/login/lib/useDownloadTerms";
2024-05-13 04:00:43 +02:00
import Template from "../../dist/login/Template";
import UserProfileFormFields from "../../dist/login/UserProfileFormFields";
export default function KcApp(props: { kcContext: KcContext }) {
const { kcContext } = props;
const i18n = useI18n({ kcContext });
2023-04-20 05:41:34 +02:00
useDownloadTerms({
2024-06-04 04:06:29 +02:00
kcContext,
2024-05-20 15:48:51 +02:00
downloadTermMarkdown: async ({ currentLanguageTag }) => {
2023-04-20 05:41:34 +02:00
const resource = (() => {
switch (currentLanguageTag) {
case "fr":
2024-06-04 04:06:29 +02:00
return "/tos/tos_fr.md";
case "es":
return "/tos/tos_es.md";
2023-04-20 05:41:34 +02:00
default:
2024-06-04 04:06:29 +02:00
return "/tos/tos_en.md";
2023-04-20 05:41:34 +02:00
}
})();
const response = await fetch(resource);
return response.text();
}
});
if (i18n === null) {
return null;
}
return (
<Suspense>
{(() => {
switch (kcContext.pageId) {
default:
2024-05-20 15:48:51 +02:00
return (
<Fallback
{...{
kcContext,
i18n,
Template,
UserProfileFormFields
}}
doUseDefaultCss={true}
/>
);
}
})()}
</Suspense>
);
}