2021-06-28 20:45:06 +00:00
|
|
|
import dynamic from 'next/dynamic'
|
|
|
|
import { GetServerSideProps } from 'next'
|
|
|
|
import { getSession } from 'next-auth/client'
|
2021-06-30 20:31:29 +00:00
|
|
|
import { useEffect } from 'react'
|
|
|
|
import coopState from 'state/coop/coop-state'
|
2021-06-28 20:45:06 +00:00
|
|
|
|
|
|
|
const Editor = dynamic(() => import('components/editor'), { ssr: false })
|
|
|
|
|
|
|
|
export default function Room({ id }: { id: string }): JSX.Element {
|
2021-06-30 20:31:29 +00:00
|
|
|
useEffect(() => {
|
|
|
|
return () => {
|
|
|
|
coopState.send('LEFT_ROOM')
|
|
|
|
}
|
|
|
|
}, [])
|
|
|
|
|
2021-06-28 20:45:06 +00:00
|
|
|
return <Editor roomId={id} />
|
|
|
|
}
|
|
|
|
|
|
|
|
export const getServerSideProps: GetServerSideProps = async (context) => {
|
|
|
|
const session = await getSession(context)
|
|
|
|
|
|
|
|
const { id } = context.query
|
|
|
|
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
session,
|
|
|
|
id,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|