Files
keycloak_theme/stories/login/KcApp.tsx

55 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-06-05 06:10:11 +02:00
import React from "react";
2024-06-05 18:50:00 +02:00
import Fallback from "../../dist/login/Fallback";
2024-06-05 22:48:13 +02:00
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,
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;
}
const termsMarkdown = await fetch(`/terms/${termsFileName}`).then(response => response.text());
return { termsMarkdown, termsLanguageTag };
2023-04-20 05:41:34 +02:00
}
});
if (i18n === null) {
return null;
}
return (
2024-06-05 06:10:11 +02:00
<Fallback
{...{
kcContext,
i18n,
Template,
UserProfileFormFields
}}
doUseDefaultCss={true}
/>
);
}