|
| 1 | +import { MemoryRouter } from 'react-router-dom'; |
| 2 | +import { fn } from 'storybook/test'; |
| 3 | +import AddressUtility from './AddressUtility'; |
| 4 | + |
| 5 | +const sampleCountries = [ |
| 6 | + { id: 'GB', name: 'United Kingdom', countryCode: 'GB', countryName: 'United Kingdom' }, |
| 7 | + { id: 'US', name: 'United States', countryCode: 'US', countryName: 'United States' }, |
| 8 | + { id: 'DE', name: 'Germany', countryCode: 'DE', countryName: 'Germany' } |
| 9 | +]; |
| 10 | + |
| 11 | +const sampleAddresses = [ |
| 12 | + { |
| 13 | + id: 1, |
| 14 | + name: '1 Linn Products Way', |
| 15 | + description: 'Glasgow, G76 0EQ', |
| 16 | + addressId: 1, |
| 17 | + postCode: 'G76 0EQ', |
| 18 | + countryCode: 'GB', |
| 19 | + href: '/addresses/1' |
| 20 | + } |
| 21 | +]; |
| 22 | + |
| 23 | +export default { |
| 24 | + title: 'Components/AddressUtility', |
| 25 | + component: AddressUtility, |
| 26 | + tags: ['autodocs'], |
| 27 | + decorators: [ |
| 28 | + Story => ( |
| 29 | + <MemoryRouter> |
| 30 | + <Story /> |
| 31 | + </MemoryRouter> |
| 32 | + ) |
| 33 | + ], |
| 34 | + args: { |
| 35 | + createAddress: fn(), |
| 36 | + createAddressLoading: false, |
| 37 | + selectAddress: fn(), |
| 38 | + searchCountries: fn(), |
| 39 | + searchAddresses: fn(), |
| 40 | + countriesSearchResults: [], |
| 41 | + countriesSearchLoading: false, |
| 42 | + addressSearchResults: [], |
| 43 | + addressSearchLoading: false, |
| 44 | + clearAddressesSearch: fn(), |
| 45 | + clearCountriesSearch: fn(), |
| 46 | + defaultAddressee: false, |
| 47 | + isActive: false, |
| 48 | + setIsActive: fn() |
| 49 | + } |
| 50 | +}; |
| 51 | + |
| 52 | +export const Default = {}; |
| 53 | + |
| 54 | +export const DialogOpen = { |
| 55 | + name: 'Dialog open', |
| 56 | + args: { |
| 57 | + isActive: true |
| 58 | + } |
| 59 | +}; |
| 60 | + |
| 61 | +export const WithCountryResults = { |
| 62 | + name: 'Dialog open with country results', |
| 63 | + args: { |
| 64 | + isActive: true, |
| 65 | + countriesSearchResults: sampleCountries |
| 66 | + } |
| 67 | +}; |
| 68 | + |
| 69 | +export const WithAddressResults = { |
| 70 | + name: 'Dialog open with address results', |
| 71 | + args: { |
| 72 | + isActive: true, |
| 73 | + addressSearchResults: sampleAddresses |
| 74 | + } |
| 75 | +}; |
| 76 | + |
| 77 | +export const LoadingAddress = { |
| 78 | + name: 'Loading address creation', |
| 79 | + args: { |
| 80 | + isActive: true, |
| 81 | + createAddressLoading: true |
| 82 | + } |
| 83 | +}; |
0 commit comments