keycloakify-custom/src/main.tsx
Joseph Garrone f3036ec2c3 update
2024-06-06 07:46:48 +02:00

37 lines
1.2 KiB
TypeScript

/* eslint-disable react-refresh/only-export-components */
import { createRoot } from "react-dom/client";
import { StrictMode, lazy, Suspense } from "react";
// The following block can be uncommented to test a specific page with `yarn dev`
// Don't forget to comment back or your bundle size will increase
/*
import { getKcContextMock } from "./login/PageStory";
if (import.meta.env.DEV) {
window.kcContext = getKcContextMock({
pageId: "register.ftl"
});
}
*/
const KcLoginThemeApp = lazy(() => import("./login/KcApp"));
const KcAccountThemeApp = lazy(() => import("./account/KcApp"));
createRoot(document.getElementById("root")!).render(
<StrictMode>
<Suspense>
{(() => {
switch (window.kcContext?.themeType) {
case "login":
return <KcLoginThemeApp kcContext={window.kcContext} />;
case "account":
return <KcAccountThemeApp kcContext={window.kcContext} />;
case undefined:
return <h1>No Keycloak Context</h1>;
}
})()}
</Suspense>
</StrictMode>
);