2022-05-16 09:38:20 +00:00
|
|
|
import { useEffect } from 'react'
|
2021-01-14 13:58:12 +00:00
|
|
|
import ChatPane from '../js/features/chat/components/chat-pane'
|
2021-05-11 14:25:22 +00:00
|
|
|
import useFetchMock from './hooks/use-fetch-mock'
|
2022-05-16 09:38:20 +00:00
|
|
|
import { generateMessages } from './fixtures/chat-messages'
|
|
|
|
import { ScopeDecorator } from './decorators/scope'
|
2021-01-14 13:58:12 +00:00
|
|
|
|
2021-05-11 14:25:22 +00:00
|
|
|
export const Conversation = args => {
|
|
|
|
useFetchMock(fetchMock => {
|
|
|
|
fetchMock.get(/messages/, generateMessages(35)).post(/messages/, {})
|
|
|
|
})
|
|
|
|
|
|
|
|
return <ChatPane {...args} />
|
2021-01-14 13:58:12 +00:00
|
|
|
}
|
|
|
|
|
2021-05-11 14:25:22 +00:00
|
|
|
export const NoMessages = args => {
|
|
|
|
useFetchMock(fetchMock => {
|
2021-01-14 13:58:12 +00:00
|
|
|
fetchMock.get(/messages/, [])
|
2021-05-11 14:25:22 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
return <ChatPane {...args} />
|
2021-01-14 13:58:12 +00:00
|
|
|
}
|
|
|
|
|
2021-05-11 14:25:22 +00:00
|
|
|
export const Loading = args => {
|
|
|
|
useFetchMock(fetchMock => {
|
2021-01-14 13:58:12 +00:00
|
|
|
fetchMock.get(/messages/, generateMessages(6), {
|
2021-04-27 07:52:58 +00:00
|
|
|
delay: 1000 * 10,
|
2021-01-14 13:58:12 +00:00
|
|
|
})
|
2021-05-11 14:25:22 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
return <ChatPane {...args} />
|
2021-01-14 13:58:12 +00:00
|
|
|
}
|
|
|
|
|
2022-05-16 09:38:20 +00:00
|
|
|
export const LoadingError = args => {
|
|
|
|
useFetchMock(fetchMock => {
|
|
|
|
fetchMock.get(/messages/, 500)
|
|
|
|
})
|
|
|
|
|
|
|
|
return <ChatPane {...args} />
|
|
|
|
}
|
|
|
|
|
2021-01-14 13:58:12 +00:00
|
|
|
export default {
|
2022-03-28 10:23:21 +00:00
|
|
|
title: 'Editor / Chat',
|
2021-01-14 13:58:12 +00:00
|
|
|
component: ChatPane,
|
|
|
|
argTypes: {
|
2021-04-27 07:52:58 +00:00
|
|
|
resetUnreadMessages: { action: 'resetUnreadMessages' },
|
2021-01-14 13:58:12 +00:00
|
|
|
},
|
|
|
|
args: {
|
2021-04-27 07:52:58 +00:00
|
|
|
resetUnreadMessages: () => {},
|
2021-01-14 13:58:12 +00:00
|
|
|
},
|
|
|
|
decorators: [
|
2022-05-16 09:38:20 +00:00
|
|
|
ScopeDecorator,
|
|
|
|
Story => {
|
|
|
|
useEffect(() => {
|
|
|
|
window.MathJax = {
|
|
|
|
Hub: {
|
|
|
|
Queue: () => {},
|
|
|
|
config: { tex2jax: { inlineMath: [['$', '$']] } },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
delete window.MathJax
|
|
|
|
}
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
return <Story />
|
|
|
|
},
|
2021-04-27 07:52:58 +00:00
|
|
|
],
|
2021-01-14 13:58:12 +00:00
|
|
|
}
|