Adjustments on the main.tsx

This commit is contained in:
Joseph Garrone 2024-06-06 06:02:50 +02:00
parent 59008f5b87
commit aad1e69855

View File

@ -5,12 +5,11 @@ import { StrictMode, lazy, Suspense } from "react";
const KcLoginThemeApp = lazy(() => import("./login/KcApp"));
const KcAccountThemeApp = lazy(() => import("./account/KcApp"));
let { kcContext } = window;
// NOTE: This is just to test a specific page when you run `yarn dev`
// however the recommended way to develope is to use the Storybook
if (kcContext === undefined) {
kcContext = (await import("./login/PageStory")).getKcContextMock({
if (window.kcContext === undefined) {
window.kcContext = (await import("./login/PageStory")).getKcContextMock({
pageId: "register.ftl"
});
}
@ -19,11 +18,11 @@ createRoot(document.getElementById("root")!).render(
<StrictMode>
<Suspense>
{(() => {
switch (kcContext?.themeType) {
switch (window.kcContext?.themeType) {
case "login":
return <KcLoginThemeApp kcContext={kcContext} />;
return <KcLoginThemeApp kcContext={window.kcContext} />;
case "account":
return <KcAccountThemeApp kcContext={kcContext} />;
return <KcAccountThemeApp kcContext={window.kcContext} />;
case undefined:
return <h1>No Keycloak Context</h1>;
}