feat(db): 🗃️ Remove duplicate fields in PublicTypebot
This commit is contained in:
@@ -9,7 +9,7 @@ import { createResult, updateResult } from '../services/result'
|
||||
import { ErrorPage } from './ErrorPage'
|
||||
|
||||
export type TypebotPageProps = {
|
||||
typebot?: PublicTypebot
|
||||
typebot?: PublicTypebot & { typebot: { name: string } }
|
||||
url: string
|
||||
isIE: boolean
|
||||
customHeadCode: string | null
|
||||
@@ -97,7 +97,7 @@ export const TypebotPage = ({
|
||||
<div style={{ height: '100vh' }}>
|
||||
<SEO
|
||||
url={url}
|
||||
typebotName={typebot.name}
|
||||
typebotName={typebot.typebot.name}
|
||||
metadata={typebot.settings.metadata}
|
||||
/>
|
||||
{showTypebot && (
|
||||
|
||||
@@ -62,8 +62,9 @@ export const getServerSideProps: GetServerSideProps = async (
|
||||
|
||||
const getTypebotFromPublicId = async (publicId?: string) => {
|
||||
if (!publicId) return null
|
||||
const typebot = await prisma.publicTypebot.findUnique({
|
||||
where: { publicId },
|
||||
const typebot = await prisma.publicTypebot.findFirst({
|
||||
where: { typebot: { publicId } },
|
||||
include: { typebot: { select: { name: true } } },
|
||||
})
|
||||
if (isNotDefined(typebot)) return null
|
||||
return omit(typebot as unknown as PublicTypebot, 'createdAt', 'updatedAt')
|
||||
@@ -71,7 +72,8 @@ const getTypebotFromPublicId = async (publicId?: string) => {
|
||||
|
||||
const getTypebotFromCustomDomain = async (customDomain: string) => {
|
||||
const typebot = await prisma.publicTypebot.findFirst({
|
||||
where: { customDomain },
|
||||
where: { typebot: { customDomain } },
|
||||
include: { typebot: { select: { name: true } } },
|
||||
})
|
||||
if (isNotDefined(typebot)) return null
|
||||
return omit(typebot as unknown as PublicTypebot, 'createdAt', 'updatedAt')
|
||||
|
||||
@@ -92,15 +92,12 @@ const parseTypebotToPublicTypebot = (
|
||||
typebot: Typebot
|
||||
): PublicTypebot => ({
|
||||
id,
|
||||
name: typebot.name,
|
||||
blocks: typebot.blocks,
|
||||
typebotId: typebot.id,
|
||||
theme: typebot.theme,
|
||||
settings: typebot.settings,
|
||||
publicId: typebot.publicId,
|
||||
variables: typebot.variables,
|
||||
edges: typebot.edges,
|
||||
customDomain: null,
|
||||
createdAt: typebot.createdAt,
|
||||
updatedAt: typebot.updatedAt,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user