diff --git a/src/login/KcPage.tsx b/src/login/KcPage.tsx index 2d4da1bc..9a8b45ef 100644 --- a/src/login/KcPage.tsx +++ b/src/login/KcPage.tsx @@ -13,6 +13,7 @@ const Login = lazy(() => import("./pages/Login")); const Register = lazy(() => import("./pages/Register")); const LoginUpdateProfile = lazy(() => import("./pages/LoginUpdateProfile")); const LoginUpdatePassword = lazy(() => import("./pages/LoginUpdatePassword")); +const Info = lazy(() => import("./pages/Info")); const Error = lazy(() => import("./pages/Error")); const LoginResetPassword = lazy(() => import("./pages/LoginResetPassword")); @@ -83,6 +84,14 @@ export default function KcPage(props: { kcContext: KcContext }) { doUseDefaultCss={false} /> ); + case "info.ftl": + return ( + + ); case "error.ftl": return ( ; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = { + render: () => ( + + ) +}; + +/** + * WithRequiredActions: + * - Purpose: Tests the info page when certain actions are required from the user. + * - Scenario: Simulates a scenario where the user needs to complete specific actions (e.g., verify email, update password). + * - Key Aspect: Displays a list of required actions that the user must complete. + */ +export const WithRequiredActions: Story = { + render: () => ( + + ) +}; + +/** + * WithActionUri: + * - Purpose: Tests the page with an action URI link. + * - Scenario: Simulates an info page that provides a link to proceed with a specific action. + * - Key Aspect: Displays a "proceed with action" link instead of "back to application". + */ +export const WithActionUri: Story = { + render: () => ( + + ) +}; + +/** + * WithClientBaseUrl: + * - Purpose: Tests the page with only a client base URL available. + * - Scenario: Simulates when no specific redirect URI is provided, falling back to the client's base URL. + * - Key Aspect: Uses the client base URL as the "back to application" link. + */ +export const WithClientBaseUrl: Story = { + render: () => ( + + ) +}; + +/** + * EmailVerificationSuccess: + * - Purpose: Tests a typical email verification success message. + * - Scenario: User clicks on email verification link and sees success message. + * - Key Aspect: Shows success message with redirect to application. + */ +export const EmailVerificationSuccess: Story = { + render: () => ( + + ) +}; diff --git a/src/login/pages/Info.tsx b/src/login/pages/Info.tsx new file mode 100644 index 00000000..1707d421 --- /dev/null +++ b/src/login/pages/Info.tsx @@ -0,0 +1,71 @@ +import { getKcClsx } from "keycloakify/login/lib/kcClsx"; +import type { PageProps } from "keycloakify/login/pages/PageProps"; +import type { KcContext } from "../KcContext"; +import type { I18n } from "../i18n"; +import Alert from "@codegouvfr/react-dsfr/Alert"; +import { fr } from "@codegouvfr/react-dsfr"; + +export default function Info(props: PageProps, I18n>) { + const { kcContext, i18n, doUseDefaultCss, Template, classes } = props; + + const { kcClsx } = getKcClsx({ + doUseDefaultCss, + classes + }); + + const { messageHeader, message, requiredActions, skipLink, pageRedirectUri, actionUri, client, url } = kcContext; + + const { msg, advancedMsg } = i18n; + + return ( + + {message !== undefined && ( + + )} + + {requiredActions !== undefined && requiredActions.length > 0 && ( + + + {requiredActions.map((requiredAction, index) => ( + {advancedMsg(`requiredAction.${requiredAction}` as any)} + ))} + + + )} + + + {!skipLink && ( + actionUri !== undefined ? ( + + {msg("doContinue")} + + ) : pageRedirectUri !== undefined ? ( + + {msg("backToApplication")} + + ) : client.baseUrl !== undefined ? ( + + {msg("backToApplication")} + + ) : ( + + {msg("backToLogin")} + + ) + )} + + + ); +}