2022-07-30 00:42:07 +02:00
|
|
|
import React, { lazy, memo, Suspense } from "react";
|
2021-06-23 08:16:51 +02:00
|
|
|
import type { KcContextBase } from "../getKcContext/KcContextBase";
|
2021-03-06 14:42:56 +01:00
|
|
|
import type { KcProps } from "./KcProps";
|
2022-07-31 22:30:32 +02:00
|
|
|
import { __unsafe_useI18n as useI18n } from "../i18n";
|
|
|
|
import type { I18n } from "../i18n";
|
2021-03-03 00:04:06 +01:00
|
|
|
|
2022-07-29 01:31:55 +02:00
|
|
|
const Login = lazy(() => import("./Login"));
|
|
|
|
const Register = lazy(() => import("./Register"));
|
|
|
|
const RegisterUserProfile = lazy(() => import("./RegisterUserProfile"));
|
|
|
|
const Info = lazy(() => import("./Info"));
|
|
|
|
const Error = lazy(() => import("./Error"));
|
|
|
|
const LoginResetPassword = lazy(() => import("./LoginResetPassword"));
|
|
|
|
const LoginVerifyEmail = lazy(() => import("./LoginVerifyEmail"));
|
|
|
|
const Terms = lazy(() => import("./Terms"));
|
|
|
|
const LoginOtp = lazy(() => import("./LoginOtp"));
|
|
|
|
const LoginUpdatePassword = lazy(() => import("./LoginUpdatePassword"));
|
|
|
|
const LoginUpdateProfile = lazy(() => import("./LoginUpdateProfile"));
|
|
|
|
const LoginIdpLinkConfirm = lazy(() => import("./LoginIdpLinkConfirm"));
|
|
|
|
const LoginPageExpired = lazy(() => import("./LoginPageExpired"));
|
|
|
|
const LoginIdpLinkEmail = lazy(() => import("./LoginIdpLinkEmail"));
|
|
|
|
const LoginConfigTotp = lazy(() => import("./LoginConfigTotp"));
|
|
|
|
const LogoutConfirm = lazy(() => import("./LogoutConfirm"));
|
|
|
|
|
2022-07-31 22:30:32 +02:00
|
|
|
const KcApp = memo(({ kcContext, i18n: userProvidedI18n, ...props }: { kcContext: KcContextBase; i18n?: I18n } & KcProps) => {
|
|
|
|
const i18n = (function useClosure() {
|
|
|
|
const i18n = useI18n({
|
|
|
|
kcContext,
|
|
|
|
"extraMessages": {},
|
2022-08-20 11:44:48 +07:00
|
|
|
"doSkip": userProvidedI18n !== undefined
|
2022-07-31 22:30:32 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
return userProvidedI18n ?? i18n;
|
|
|
|
})();
|
|
|
|
|
2022-08-01 03:07:06 +02:00
|
|
|
if (i18n === null) {
|
2022-07-31 22:30:32 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-07-29 01:31:55 +02:00
|
|
|
return (
|
2022-07-31 22:30:32 +02:00
|
|
|
<Suspense>
|
|
|
|
{(() => {
|
|
|
|
switch (kcContext.pageId) {
|
|
|
|
case "login.ftl":
|
|
|
|
return <Login {...{ kcContext, i18n, ...props }} />;
|
|
|
|
case "register.ftl":
|
|
|
|
return <Register {...{ kcContext, i18n, ...props }} />;
|
|
|
|
case "register-user-profile.ftl":
|
|
|
|
return <RegisterUserProfile {...{ kcContext, i18n, ...props }} />;
|
|
|
|
case "info.ftl":
|
|
|
|
return <Info {...{ kcContext, i18n, ...props }} />;
|
|
|
|
case "error.ftl":
|
|
|
|
return <Error {...{ kcContext, i18n, ...props }} />;
|
|
|
|
case "login-reset-password.ftl":
|
|
|
|
return <LoginResetPassword {...{ kcContext, i18n, ...props }} />;
|
|
|
|
case "login-verify-email.ftl":
|
|
|
|
return <LoginVerifyEmail {...{ kcContext, i18n, ...props }} />;
|
|
|
|
case "terms.ftl":
|
|
|
|
return <Terms {...{ kcContext, i18n, ...props }} />;
|
|
|
|
case "login-otp.ftl":
|
|
|
|
return <LoginOtp {...{ kcContext, i18n, ...props }} />;
|
|
|
|
case "login-update-password.ftl":
|
|
|
|
return <LoginUpdatePassword {...{ kcContext, i18n, ...props }} />;
|
|
|
|
case "login-update-profile.ftl":
|
|
|
|
return <LoginUpdateProfile {...{ kcContext, i18n, ...props }} />;
|
|
|
|
case "login-idp-link-confirm.ftl":
|
|
|
|
return <LoginIdpLinkConfirm {...{ kcContext, i18n, ...props }} />;
|
|
|
|
case "login-idp-link-email.ftl":
|
|
|
|
return <LoginIdpLinkEmail {...{ kcContext, i18n, ...props }} />;
|
|
|
|
case "login-page-expired.ftl":
|
|
|
|
return <LoginPageExpired {...{ kcContext, i18n, ...props }} />;
|
|
|
|
case "login-config-totp.ftl":
|
|
|
|
return <LoginConfigTotp {...{ kcContext, i18n, ...props }} />;
|
|
|
|
case "logout-confirm.ftl":
|
|
|
|
return <LogoutConfirm {...{ kcContext, i18n, ...props }} />;
|
|
|
|
}
|
|
|
|
})()}
|
|
|
|
</Suspense>
|
2022-07-29 01:31:55 +02:00
|
|
|
);
|
2021-10-12 00:26:29 +02:00
|
|
|
});
|
2022-07-29 01:31:55 +02:00
|
|
|
|
|
|
|
export default KcApp;
|