2022-04-08 07:00:31 -04:00
|
|
|
import useFetchMock from '../hooks/use-fetch-mock'
|
|
|
|
import LeaveModal from '../../js/features/settings/components/leave/modal'
|
|
|
|
import LeaveSection from '../../js/features/settings/components/leave-section'
|
2022-04-22 09:49:26 -04:00
|
|
|
import { setDefaultMeta, defaultSetupMocks } from './helpers/leave'
|
2024-10-10 03:26:18 -04:00
|
|
|
import { bsVersionDecorator } from '../../../.storybook/utils/with-bootstrap-switcher'
|
2022-04-08 07:01:21 -04:00
|
|
|
|
|
|
|
export const Section = args => {
|
2022-04-08 07:00:31 -04:00
|
|
|
useFetchMock(defaultSetupMocks)
|
2022-04-08 07:01:21 -04:00
|
|
|
setDefaultMeta()
|
2022-04-08 07:00:31 -04:00
|
|
|
|
|
|
|
return <LeaveSection {...args} />
|
|
|
|
}
|
|
|
|
Section.component = LeaveSection
|
|
|
|
Section.parameters = { controls: { include: [], hideNoControlsWarning: true } }
|
|
|
|
|
|
|
|
export const ModalSuccess = args => {
|
2022-04-08 07:01:21 -04:00
|
|
|
setDefaultMeta()
|
|
|
|
useFetchMock(defaultSetupMocks)
|
|
|
|
|
|
|
|
return <LeaveModal {...args} />
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ModalWithoutPassword = args => {
|
|
|
|
setDefaultMeta()
|
|
|
|
window.metaAttributesCache.set('ol-hasPassword', false)
|
2022-04-08 07:00:31 -04:00
|
|
|
useFetchMock(defaultSetupMocks)
|
|
|
|
|
|
|
|
return <LeaveModal {...args} />
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ModalAuthError = args => {
|
2022-04-08 07:01:21 -04:00
|
|
|
setDefaultMeta()
|
2022-04-08 07:00:31 -04:00
|
|
|
useFetchMock(fetchMock => {
|
|
|
|
fetchMock.post(/\/user\/delete/, 403)
|
|
|
|
})
|
|
|
|
|
|
|
|
return <LeaveModal {...args} />
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ModalServerError = args => {
|
2022-04-08 07:01:21 -04:00
|
|
|
setDefaultMeta()
|
2022-04-08 07:00:31 -04:00
|
|
|
useFetchMock(fetchMock => {
|
|
|
|
fetchMock.post(/\/user\/delete/, 500)
|
|
|
|
})
|
|
|
|
|
|
|
|
return <LeaveModal {...args} />
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ModalSubscriptionError = args => {
|
2022-04-08 07:01:21 -04:00
|
|
|
setDefaultMeta()
|
2022-04-08 07:00:31 -04:00
|
|
|
useFetchMock(fetchMock => {
|
|
|
|
fetchMock.post(/\/user\/delete/, {
|
|
|
|
status: 422,
|
|
|
|
body: {
|
|
|
|
error: 'SubscriptionAdminDeletionError',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
return <LeaveModal {...args} />
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
title: 'Account Settings / Leave',
|
|
|
|
component: LeaveModal,
|
|
|
|
args: {
|
|
|
|
isOpen: true,
|
|
|
|
},
|
|
|
|
argTypes: {
|
|
|
|
handleClose: { action: 'handleClose' },
|
2024-10-10 03:26:18 -04:00
|
|
|
...bsVersionDecorator.argTypes,
|
2022-04-08 07:00:31 -04:00
|
|
|
},
|
|
|
|
}
|