-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EmployeeWebClient - add router provider to storybook config
- Loading branch information
Showing
8 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react'; | ||
import { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
|
||
import { withParams } from 'utils/storybook'; | ||
import { managementMockService } from 'utils/mock'; | ||
import { FacilityFixture, generateID, MetaFixture, OfferFixture } from 'utils'; | ||
|
||
import { IOfferCollection, OfferStatus } from 'modules/offers/application/types'; | ||
import { offersQueryKey } from 'modules/offers/infrastructure/query'; | ||
import { FacilityProvider } from 'modules/context/application'; | ||
import Offers from './index'; | ||
|
||
const FACILITY_ID = generateID(); | ||
const OFFER_ID_1 = generateID(); | ||
const OFFER_ID_2 = generateID(); | ||
|
||
const facility = FacilityFixture.createPermutation({ facilityId: FACILITY_ID }); | ||
const offer1 = OfferFixture.createPermutation({ | ||
facilityId: FACILITY_ID, | ||
offerId: OFFER_ID_1, | ||
name: 'Existing offer 1', | ||
status: OfferStatus.Active, | ||
}); | ||
const offer2 = OfferFixture.createPermutation({ | ||
facilityId: FACILITY_ID, | ||
offerId: OFFER_ID_2, | ||
name: 'Existing offer 2', | ||
status: OfferStatus.Active, | ||
}); | ||
|
||
managementMockService.get<IOfferCollection>(offersQueryKey(FACILITY_ID)[0], { | ||
meta: MetaFixture.createPermutation({ total: 2 }), | ||
collection: [offer1, offer2], | ||
}); | ||
|
||
export default { | ||
title: 'pages/OffersPage', | ||
component: Offers, | ||
decorators: [withParams()], | ||
} as ComponentMeta<typeof Offers>; | ||
|
||
const Template: ComponentStory<typeof Offers> = () => { | ||
return ( | ||
<FacilityProvider value={facility}> | ||
<Offers /> | ||
</FacilityProvider> | ||
); | ||
}; | ||
|
||
export const Default = Template.bind({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { v4 } from 'uuid'; | ||
|
||
export const generateID = () => v4(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
import { useNavigate, useLocation, NavigateOptions } from 'react-router-dom'; | ||
|
||
import { QueryParamsProvider } from 'shared/Params'; | ||
|
||
// eslint-disable-next-line react/display-name | ||
export const withParams = () => (story: any) => { | ||
const navigate = useNavigate(); | ||
const location = useLocation(); | ||
|
||
return ( | ||
<QueryParamsProvider | ||
location={location} | ||
history={{ | ||
push: navigate, | ||
replace: (to: string, options?: NavigateOptions) => navigate(to, { replace: true, ...options }), | ||
}} | ||
> | ||
{story()} | ||
</QueryParamsProvider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters