Move the entrypoint into kc.gen.tsx

This commit is contained in:
Joseph Garrone
2024-07-27 17:11:30 +02:00
parent c66236e414
commit a2d7634fe5
3 changed files with 60 additions and 26 deletions

View File

@ -1,6 +1,7 @@
/* eslint-disable react-refresh/only-export-components */
import { createRoot } from "react-dom/client";
import { StrictMode, lazy, Suspense } from "react";
import { StrictMode } from "react";
import { KcPage } from "./kc.gen";
// 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
@ -15,29 +16,12 @@ if (import.meta.env.DEV) {
}
*/
const KcLoginThemePage = lazy(() => import("./login/KcPage"));
//const KcAccountThemePage = lazy(() => import("./account/KcPage"));
createRoot(document.getElementById("root")!).render(
<StrictMode>
<Suspense>
{(() => {
switch (window.kcContext?.themeType) {
case "login":
return <KcLoginThemePage kcContext={window.kcContext} />;
//case "account":
// return <KcAccountThemePage kcContext={window.kcContext} />;
}
return <h1>No Keycloak Context</h1>;
})()}
</Suspense>
{!window.kcContext ? (
<h1>No Keycloak Context</h1>
) : (
<KcPage kcContext={window.kcContext} />
)}
</StrictMode>
);
declare global {
interface Window {
kcContext?:
| import("./login/KcContext").KcContext
//| import("./account/KcContext").KcContext;
}
}