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'
|
|
|
|
|
|
|
|
const MOCK_DELAY = 1000
|
|
|
|
window.metaAttributesCache = window.metaAttributesCache || new Map()
|
|
|
|
|
|
|
|
function defaultSetupMocks(fetchMock) {
|
|
|
|
fetchMock.post(/\/user\/delete/, 200, {
|
|
|
|
delay: MOCK_DELAY,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-04-08 07:01:21 -04:00
|
|
|
function setDefaultMeta() {
|
2022-04-08 07:00:31 -04:00
|
|
|
window.metaAttributesCache.set('ol-userDefaultEmail', 'user@primary.com')
|
2022-04-08 07:01:21 -04:00
|
|
|
window.metaAttributesCache.set('ol-isSaas', true)
|
|
|
|
window.metaAttributesCache.set('ol-hasPassword', true)
|
|
|
|
}
|
|
|
|
|
|
|
|
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' },
|
|
|
|
},
|
|
|
|
}
|