tldraw/apps/www/pages/r/[id].tsx

31 lines
794 B
TypeScript
Raw Normal View History

2021-09-04 12:18:44 +00:00
import * as React from 'react'
import type { GetServerSideProps } from 'next'
import { getSession } from 'next-auth/react'
2021-09-04 12:18:44 +00:00
import dynamic from 'next/dynamic'
const MultiplayerEditor = dynamic(() => import('components/MultiplayerEditor'), {
ssr: false,
}) as any
2021-09-04 12:18:44 +00:00
interface RoomProps {
id: string
isSponsor: boolean
isUser: boolean
2021-09-04 12:18:44 +00:00
}
export default function Room({ id, isUser, isSponsor }: RoomProps) {
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()
2021-09-04 12:18:44 +00:00
return {
props: {
id,
2021-11-19 14:33:15 +00:00
isUser: session?.user ? true : false,
isSponsor: session?.isSponsor ?? false,
2021-09-04 12:18:44 +00:00
},
}
}