keycloak_theme/stories/login/pages/Register.stories.tsx

118 lines
3.1 KiB
TypeScript
Raw Normal View History

2023-04-20 05:41:34 +02:00
import React from "react";
2024-06-03 00:11:19 +02:00
import type { Meta, StoryObj } from "@storybook/react";
2024-06-05 21:44:26 +02:00
import { createPageStory, parameters } from "../PageStory";
2023-04-20 05:41:34 +02:00
const pageId = "register.ftl";
const { PageStory } = createPageStory({ pageId });
2024-06-03 00:11:19 +02:00
const meta = {
2023-04-20 05:41:34 +02:00
title: `login/${pageId}`,
component: PageStory,
2024-06-02 22:37:04 +02:00
parameters
2024-06-03 00:11:19 +02:00
} satisfies Meta<typeof PageStory>;
2023-04-20 05:41:34 +02:00
export default meta;
2024-06-03 00:11:19 +02:00
type Story = StoryObj<typeof meta>;
export const Default: Story = {
render: () => <PageStory />
};
2024-06-03 00:11:19 +02:00
export const WithFieldError: Story = {
render: () => (
<PageStory
kcContext={{
profile: {
2024-06-03 23:54:08 +02:00
attributesByName: {
email: {
2024-06-03 00:11:19 +02:00
value: "max.mustermann@gmail.com"
}
2024-06-03 23:54:08 +02:00
}
2024-06-03 00:11:19 +02:00
},
messagesPerField: {
existsError: (fieldName: string) => fieldName === "email",
exists: (fieldName: string) => fieldName === "email",
get: (fieldName: string) => (fieldName === "email" ? "I don't like your email address" : undefined),
printIfExists: <T,>(fieldName: string, x: T) => (fieldName === "email" ? x : undefined)
}
}}
/>
)
};
2024-06-03 00:11:19 +02:00
export const WithEmailAsUsername: Story = {
render: () => (
<PageStory
kcContext={{
realm: {
registrationEmailAsUsername: true
}
}}
/>
)
};
2024-06-03 00:11:19 +02:00
export const WithoutPassword: Story = {
render: () => (
<PageStory
kcContext={{
passwordRequired: false
}}
/>
)
};
2024-06-03 00:11:19 +02:00
export const WithRecaptcha: Story = {
render: () => (
<PageStory
kcContext={{
2024-06-04 01:39:54 +02:00
scripts: ["https://www.google.com/recaptcha/api.js?hl=en"],
2024-06-03 00:11:19 +02:00
recaptchaRequired: true,
2024-06-04 01:39:54 +02:00
recaptchaSiteKey: "6LfQHvApAAAAAE73SYTd5vS0lB1Xr7zdiQ-6iBVa"
2024-06-03 00:11:19 +02:00
}}
/>
)
};
2024-06-05 01:02:17 +02:00
export const WithRecaptchaFrench: Story = {
render: () => (
<PageStory
kcContext={{
locale: {
currentLanguageTag: "fr"
},
scripts: ["https://www.google.com/recaptcha/api.js?hl=fr"],
recaptchaRequired: true,
recaptchaSiteKey: "6LfQHvApAAAAAE73SYTd5vS0lB1Xr7zdiQ-6iBVa"
}}
/>
)
};
2024-06-03 00:11:19 +02:00
export const WithPresets: Story = {
render: () => (
<PageStory
kcContext={{
profile: {
2024-06-03 23:54:08 +02:00
attributesByName: {
firstName: {
2024-06-03 00:11:19 +02:00
value: "Max"
},
2024-06-03 23:54:08 +02:00
lastName: {
2024-06-03 00:11:19 +02:00
value: "Mustermann"
},
2024-06-03 23:54:08 +02:00
email: {
2024-06-03 00:11:19 +02:00
value: "max.mustermann@gmail.com"
},
2024-06-03 23:54:08 +02:00
username: {
2024-06-03 00:11:19 +02:00
value: "max.mustermann"
}
2024-06-03 23:54:08 +02:00
}
2024-06-03 00:11:19 +02:00
}
}}
/>
)
};