clone-project-modal.stories.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import useFetchMock from './hooks/use-fetch-mock'
  2. import { withContextRoot } from './utils/with-context-root'
  3. import CloneProjectModal from '../js/features/clone-project-modal/components/clone-project-modal'
  4. const project = { _id: 'original-project', name: 'Project Title' }
  5. export const Success = args => {
  6. useFetchMock(fetchMock => {
  7. fetchMock.post(
  8. 'express:/project/:projectId/clone',
  9. { status: 200 },
  10. { delay: 250 }
  11. )
  12. })
  13. return withContextRoot(<CloneProjectModal {...args} />, { project })
  14. }
  15. export const GenericErrorResponse = args => {
  16. useFetchMock(fetchMock => {
  17. fetchMock.post(
  18. 'express:/project/:projectId/clone',
  19. { status: 500 },
  20. { delay: 250 }
  21. )
  22. })
  23. return withContextRoot(<CloneProjectModal {...args} />, { project })
  24. }
  25. export const SpecificErrorResponse = args => {
  26. useFetchMock(fetchMock => {
  27. fetchMock.post(
  28. 'express:/project/:projectId/clone',
  29. { status: 400, body: 'The project name is not valid' },
  30. { delay: 250 }
  31. )
  32. })
  33. return withContextRoot(<CloneProjectModal {...args} />, { project })
  34. }
  35. export default {
  36. title: 'Modals / Clone Project',
  37. component: CloneProjectModal,
  38. args: {
  39. show: true,
  40. },
  41. argTypes: {
  42. handleHide: { action: 'close modal' },
  43. openProject: { action: 'open project' },
  44. },
  45. }