keycloakify-custom/src/account/PageStory.tsx

46 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-06-05 23:44:57 +00:00
import type { DeepPartial } from "keycloakify/tools/DeepPartial";
2024-06-06 03:26:06 +00:00
import type { KcContext } from "./KcContext";
2024-06-06 04:40:12 +00:00
import { createGetKcContextMock } from "keycloakify/account/KcContext";
2024-06-05 23:44:57 +00:00
import type {
2024-06-09 08:24:14 +00:00
KcContextExtension,
KcContextExtensionPerPage
2024-06-06 03:26:06 +00:00
} from "./KcContext";
2024-06-05 23:44:57 +00:00
import KcApp from "./KcApp";
2024-06-09 08:24:14 +00:00
import { themeNames, kcEnvDefaults } from "../kc.gen";
2024-06-05 23:44:57 +00:00
2024-06-09 08:24:14 +00:00
const kcContextExtension: KcContextExtension = {
themeName: themeNames[0],
properties: {
...kcEnvDefaults
}
};
const kcContextExtensionPerPage: KcContextExtensionPerPage = {};
2024-06-05 23:44:57 +00:00
export const { getKcContextMock } = createGetKcContextMock({
2024-06-09 08:24:14 +00:00
kcContextExtension,
kcContextExtensionPerPage,
2024-06-05 23:44:57 +00:00
overrides: {},
overridesPerPage: {}
});
2024-06-06 03:26:06 +00:00
export function createPageStory<PageId extends KcContext["pageId"]>(params: {
pageId: PageId;
}) {
2024-06-05 23:44:57 +00:00
const { pageId } = params;
2024-06-06 03:26:06 +00:00
function PageStory(props: {
kcContext?: DeepPartial<Extract<KcContext, { pageId: PageId }>>;
}) {
2024-06-05 23:44:57 +00:00
const { kcContext: overrides } = props;
const kcContextMock = getKcContextMock({
pageId,
overrides
});
2024-06-06 03:26:06 +00:00
return <KcApp kcContext={kcContextMock} />;
2024-06-05 23:44:57 +00:00
}
return { PageStory };
}