2
0

feat(editor): Restore published version button

Had to migrate webhooks into a standalone table
This commit is contained in:
Baptiste Arnaud
2022-03-01 07:13:09 +01:00
parent 0df719d531
commit e17a1a0869
46 changed files with 578 additions and 348 deletions

View File

@ -1,13 +1,14 @@
import { NotFoundPage } from 'layouts/NotFoundPage'
import { PublicTypebot } from 'models'
import { GetServerSideProps, GetServerSidePropsContext } from 'next'
import { isDefined, isNotDefined, omit } from 'utils'
import { TypebotPage, TypebotPageProps } from '../layouts/TypebotPage'
import prisma from '../libs/prisma'
export const getServerSideProps: GetServerSideProps = async (
context: GetServerSidePropsContext
) => {
let typebot: PublicTypebot | null
let typebot: Omit<PublicTypebot, 'createdAt' | 'updatedAt'> | null
const isIE = /MSIE|Trident/.test(context.req.headers['user-agent'] ?? '')
const pathname = context.resolvedUrl.split('?')[0]
try {
@ -42,17 +43,23 @@ const getTypebotFromPublicId = async (publicId?: string) => {
const typebot = await prisma.publicTypebot.findUnique({
where: { publicId },
})
return (typebot as unknown as PublicTypebot) ?? null
if (isNotDefined(typebot)) return null
return omit(typebot as PublicTypebot, 'createdAt', 'updatedAt')
}
const getTypebotFromCustomDomain = async (customDomain: string) => {
const typebot = await prisma.publicTypebot.findUnique({
where: { customDomain },
})
return (typebot as unknown as PublicTypebot) ?? null
if (isNotDefined(typebot)) return null
return omit(typebot as PublicTypebot, 'createdAt', 'updatedAt')
}
const App = ({ typebot, ...props }: TypebotPageProps) =>
typebot ? <TypebotPage typebot={typebot} {...props} /> : <NotFoundPage />
isDefined(typebot) ? (
<TypebotPage typebot={typebot} {...props} />
) : (
<NotFoundPage />
)
export default App