Use FieldDefinition for company show page (#1171)

* Use FieldDefinition for company show page

* removing console.log

* fix conflicts

* fix address placeholder + company show page field definition ordering

* fix story

* add replacePlaceholder

* use AppPath enum in stories

* add routeParams

* fix people input story
This commit is contained in:
Weiko
2023-08-11 14:31:52 -07:00
committed by GitHub
parent 3978ef4edb
commit 4eb4d1488c
43 changed files with 463 additions and 478 deletions

View File

@ -1,4 +1,4 @@
import { MemoryRouter } from 'react-router-dom';
import { MemoryRouter, Route, Routes } from 'react-router-dom';
import { Decorator } from '@storybook/react';
import { ClientConfigProvider } from '~/modules/client-config/components/ClientConfigProvider';
@ -7,18 +7,32 @@ import { UserProvider } from '~/modules/users/components/UserProvider';
import { FullHeightStorybookLayout } from '../FullHeightStorybookLayout';
export type PageDecoratorArgs = { currentPath: string };
export type PageDecoratorArgs = { routePath: string; routeParams: RouteParams };
export const PageDecorator: Decorator<{ currentPath: string }> = (
Story,
{ args },
) => (
type RouteParams = {
[param: string]: string;
};
function computeLocation(routePath: string, routeParams: RouteParams) {
return routePath.replace(/:(\w+)/g, (paramName) => {
return routeParams[paramName] ?? '';
});
}
export const PageDecorator: Decorator<{
routePath: string;
routeParams: RouteParams;
}> = (Story, { args }) => (
<UserProvider>
<ClientConfigProvider>
<MemoryRouter initialEntries={[args.currentPath]}>
<MemoryRouter
initialEntries={[computeLocation(args.routePath, args.routeParams)]}
>
<FullHeightStorybookLayout>
<DefaultLayout>
<Story />
<Routes>
<Route path={args.routePath} element={<Story />} />
</Routes>
</DefaultLayout>
</FullHeightStorybookLayout>
</MemoryRouter>