overleaf/services/web/frontend/stories/clone-project-modal.stories.js
Alf Eaton 199ab985a0 Merge pull request #7223 from overleaf/ta-storybook-organise
Reorganise Storybook Stories

GitOrigin-RevId: 91014f49f84c645f87091724f03a007b731a8ad5
2022-04-05 12:16:53 +00:00

53 lines
1.3 KiB
JavaScript

import useFetchMock from './hooks/use-fetch-mock'
import { withContextRoot } from './utils/with-context-root'
import CloneProjectModal from '../js/features/clone-project-modal/components/clone-project-modal'
const project = { _id: 'original-project', name: 'Project Title' }
export const Success = args => {
useFetchMock(fetchMock => {
fetchMock.post(
'express:/project/:projectId/clone',
{ status: 200 },
{ delay: 250 }
)
})
return withContextRoot(<CloneProjectModal {...args} />, { project })
}
export const GenericErrorResponse = args => {
useFetchMock(fetchMock => {
fetchMock.post(
'express:/project/:projectId/clone',
{ status: 500 },
{ delay: 250 }
)
})
return withContextRoot(<CloneProjectModal {...args} />, { project })
}
export const SpecificErrorResponse = args => {
useFetchMock(fetchMock => {
fetchMock.post(
'express:/project/:projectId/clone',
{ status: 400, body: 'The project name is not valid' },
{ delay: 250 }
)
})
return withContextRoot(<CloneProjectModal {...args} />, { project })
}
export default {
title: 'Editor / Modals / Clone Project',
component: CloneProjectModal,
args: {
show: true,
},
argTypes: {
handleHide: { action: 'close modal' },
openProject: { action: 'open project' },
},
}