keycloakify-custom/src/account/PageStory.tsx

40 lines
1.1 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-05 23:44:57 +00:00
import { createGetKcContextMock } from "keycloakify/account";
import type {
KcContextExtraProperties,
KcContextExtraPropertiesPerPage
2024-06-06 03:26:06 +00:00
} from "./KcContext";
2024-06-05 23:44:57 +00:00
import KcApp from "./KcApp";
const kcContextExtraProperties: KcContextExtraProperties = {};
const kcContextExtraPropertiesPerPage: KcContextExtraPropertiesPerPage = {};
export const { getKcContextMock } = createGetKcContextMock({
kcContextExtraProperties,
kcContextExtraPropertiesPerPage,
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 };
}