clone-project-modal.stories.jsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import useFetchMock from './hooks/use-fetch-mock'
  2. import CloneProjectModal from '../js/features/clone-project-modal/components/clone-project-modal'
  3. import { ScopeDecorator } from './decorators/scope'
  4. export const Success = args => {
  5. useFetchMock(fetchMock => {
  6. fetchMock.post(
  7. 'express:/project/:projectId/clone',
  8. { status: 200 },
  9. { delay: 250 }
  10. )
  11. })
  12. return <CloneProjectModal {...args} />
  13. }
  14. export const GenericErrorResponse = args => {
  15. useFetchMock(fetchMock => {
  16. fetchMock.post(
  17. 'express:/project/:projectId/clone',
  18. { status: 500 },
  19. { delay: 250 }
  20. )
  21. })
  22. return <CloneProjectModal {...args} />
  23. }
  24. export const SpecificErrorResponse = args => {
  25. useFetchMock(fetchMock => {
  26. fetchMock.post(
  27. 'express:/project/:projectId/clone',
  28. { status: 400, body: 'The project name is not valid' },
  29. { delay: 250 }
  30. )
  31. })
  32. return <CloneProjectModal {...args} />
  33. }
  34. export default {
  35. title: 'Editor / Modals / Clone Project',
  36. component: CloneProjectModal,
  37. args: {
  38. show: true,
  39. projectName: 'Project 1',
  40. projectTags: [
  41. {
  42. _id: 'tag-1',
  43. name: 'Category 1',
  44. color: '#c0ffee',
  45. },
  46. ],
  47. },
  48. argTypes: {
  49. handleHide: { action: 'close modal' },
  50. openProject: { action: 'open project' },
  51. handleAfterCloned: { action: 'after cloned' },
  52. },
  53. decorators: [ScopeDecorator],
  54. }