2022-07-08 13:09:08 +00:00
|
|
|
import * as React from 'react'
|
|
|
|
import type { GetServerSideProps } from 'next'
|
|
|
|
import { getSession } from 'next-auth/react'
|
|
|
|
import dynamic from 'next/dynamic'
|
|
|
|
import { Utils } from '@tldraw/core'
|
2022-07-08 20:25:08 +00:00
|
|
|
import { IFrameWarning } from 'components/IFrameWarning'
|
2022-07-08 13:09:08 +00:00
|
|
|
const ReadOnlyMultiplayerEditor = dynamic(() => import('components/ReadOnlyMultiplayerEditor'), {
|
|
|
|
ssr: false,
|
|
|
|
}) as any
|
|
|
|
|
|
|
|
interface RoomProps {
|
|
|
|
id: string
|
|
|
|
isSponsor: boolean
|
|
|
|
isUser: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function Room({ id, isUser, isSponsor }: RoomProps) {
|
2022-07-08 20:25:08 +00:00
|
|
|
if (typeof window !== 'undefined') {
|
|
|
|
return <IFrameWarning url={`https://tldraw.com/v/${id}`} />
|
|
|
|
}
|
|
|
|
|
2022-07-08 13:09:08 +00:00
|
|
|
return <ReadOnlyMultiplayerEditor isUser={isUser} isSponsor={isSponsor} roomId={id} />
|
|
|
|
}
|
|
|
|
|
|
|
|
export const getServerSideProps: GetServerSideProps = async (context) => {
|
|
|
|
const session = await getSession(context)
|
|
|
|
const id = context.query.id?.toString()
|
|
|
|
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
id: Utils.lns(id),
|
|
|
|
isUser: session?.user ? true : false,
|
|
|
|
isSponsor: session?.isSponsor ?? false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|