LFT 77 (2)
2 Followers • 1 Member

code new css

7/31/23
import useServerAction from '@/components/useServerAction'

export default observer(function WorkspaceUpdatesNewPostContent({ workspaceJSON }) {
const richEditorRef = useRef()
const [submitting, setSubmitting] = useState(false)
const workspace = useMemo(() => Workspace.fromServer(workspaceJSON), [workspaceJSON])

const { i18n } = useI18n('workspace-updates')

const { action: createUpdatePostAction /* status: createUpdatePostStatus */ } = useServerAction({
serverAction: createUpdatePostServerAction,
onSuccess: () => {
window.location.href = workspace.makePath('/updates')
},
})

const newPost = useLocalObservable(() => ({
category: '',
title: '',
content: '',
}))

const handleSubmit = async (evt) => {
evt.preventDefault()
setSubmitting(true)
try {
const { content, html } = await richEditorRef.current.finish()
newPost.content = content
newPost.contentHtml = html

createUpdatePostAction(workspace.id, toJS(newPost))
} finally {
setSubmitting(false)
}
return false
}

return (
<PageLayout containerWidth="full">
<PageLayout.Content width="medium">
❤️
🎉
Chatbot
Bot

Hello! How can I assist you today?