This repository has been archived by the owner on Feb 26, 2023. It is now read-only.
/
KcApp.tsx
72 lines (65 loc) · 2.45 KB
/
KcApp.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import "./KcApp.css";
import type { KcContext } from "./kcContext";
import KcAppBase, { defaultKcProps, useDownloadTerms, useI18n } from "keycloakify";
import tos_en_url from "./tos_en.md";
import tos_fr_url from "./tos_fr.md";
export type Props = {
kcContext: KcContext;
};
export default function KcApp(props: Props) {
const { kcContext } = props;
useDownloadTerms({
kcContext,
"downloadTermMarkdown": async ({ currentLanguageTag }) => {
const markdownString = await fetch(
(() => {
switch (currentLanguageTag) {
case "fr":
return tos_fr_url;
default:
return tos_en_url;
}
})(),
).then(response => response.text());
return markdownString;
},
});
const i18n = useI18n({
kcContext,
// NOTE: Here you can override the default i18n messages
// or define new ones that, for example, you would have
// defined in the Keycloak admin UI for UserProfile
// https://user-images.githubusercontent.com/6702424/182050652-522b6fe6-8ee5-49df-aca3-dba2d33f24a5.png
"extraMessages": {
"en": {
"foo": "foo in English",
// Here we overwrite the default english value for the message "doForgotPassword"
// that is "Forgot Password?" see: https://github.com/InseeFrLab/keycloakify/blob/f0ae5ea908e0aa42391af323b6d5e2fd371af851/src/lib/i18n/generated_messages/18.0.1/login/en.ts#L17
"doForgotPassword": "I forgot my password"
},
"fr": {
/* spell-checker: disable */
"foo": "foo en Francais",
"doForgotPassword": "J'ai oublié mon mot de passe"
/* spell-checker: enable */
},
},
});
//NOTE: Locale not yet downloaded
if (i18n === null) {
return null;
}
return (
<KcAppBase
kcContext={kcContext}
i18n={i18n}
{...{
...defaultKcProps,
// NOTE: The classes are defined in ./KcApp.css
"kcHeaderWrapperClass": "my-color my-font",
}}
//Uncomment the following line if you want to prevent the default .css to be downloaded
//doFetchDefaultThemeResources={false}
/>
);
}