2021-09-04 12:18:44 +00:00
|
|
|
import * as React from 'react'
|
|
|
|
import type { GetServerSideProps } from 'next'
|
|
|
|
import { getSession } from 'next-auth/client'
|
|
|
|
import dynamic from 'next/dynamic'
|
2021-11-16 16:01:29 +00:00
|
|
|
const MultiplayerEditor = dynamic(() => import('-components/MultiplayerEditor'), { ssr: false })
|
2021-09-04 12:18:44 +00:00
|
|
|
|
|
|
|
interface RoomProps {
|
|
|
|
id: string
|
2021-11-16 16:01:29 +00:00
|
|
|
isSponsor: boolean
|
|
|
|
isUser: boolean
|
2021-09-04 12:18:44 +00:00
|
|
|
}
|
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
export default function Room({ id, isUser, isSponsor }: RoomProps): JSX.Element {
|
|
|
|
return <MultiplayerEditor isUser={isUser} isSponsor={isSponsor} roomId={id} />
|
2021-09-04 12:18:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const getServerSideProps: GetServerSideProps = async (context) => {
|
|
|
|
const session = await getSession(context)
|
|
|
|
|
|
|
|
const id = context.query.id?.toString()
|
|
|
|
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
id,
|
2021-11-16 16:01:29 +00:00
|
|
|
isUser: false,
|
|
|
|
isSponsor: session?.user ? true : false,
|
2021-09-04 12:18:44 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|