🚸 (dashboard) Add unpublish menu item in dashboard
Also remove the useless publishedTypebotId field in Typebot Closes #232
This commit is contained in:
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-03-22T14:33:05.037Z",
|
||||
"updatedAt": "2022-03-22T16:33:37.928Z",
|
||||
"name": "Onboarding",
|
||||
"publishedTypebotId": "cl128n64i00092e69wenv1dlx",
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-03-22T14:33:05.037Z",
|
||||
"updatedAt": "2022-03-22T16:33:37.928Z",
|
||||
"name": "Onboarding",
|
||||
"publishedTypebotId": "cl128n64i00092e69wenv1dlx",
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
"updatedAt": "2022-03-25T15:42:12.544Z",
|
||||
"name": "Customer Support",
|
||||
"icon": "😍",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
"updatedAt": "2022-05-31T12:31:12.867Z",
|
||||
"icon": "🖼️",
|
||||
"name": "Digital Product Payment",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
"updatedAt": "2022-10-13T06:27:31.951Z",
|
||||
"icon": "💬",
|
||||
"name": "FAQ",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
"updatedAt": "2022-02-05T06:21:16.522Z",
|
||||
"name": "Lead Generation",
|
||||
"icon": "🤝",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
"updatedAt": "2022-04-09T22:35:22.449Z",
|
||||
"icon": "🏆",
|
||||
"name": "Lead Scoring",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
"updatedAt": "2022-04-08T23:03:34.726Z",
|
||||
"icon": "🕹️",
|
||||
"name": "Digital Marketing Quiz",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -12,7 +12,6 @@ export type NewTypebotProps = Omit<
|
||||
| 'createdAt'
|
||||
| 'updatedAt'
|
||||
| 'id'
|
||||
| 'publishedTypebotId'
|
||||
| 'publicId'
|
||||
| 'customDomain'
|
||||
| 'icon'
|
||||
|
@ -56,7 +56,6 @@ const duplicateTypebot = (
|
||||
...typebot,
|
||||
id,
|
||||
name: `${typebot.name} copy`,
|
||||
publishedTypebotId: null,
|
||||
publicId: null,
|
||||
customDomain: null,
|
||||
groups: typebot.groups.map((b) => ({
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { Typebot } from 'models'
|
||||
|
||||
export type TypebotInDashboard = Pick<
|
||||
Typebot,
|
||||
'id' | 'name' | 'publishedTypebotId' | 'icon'
|
||||
>
|
||||
export type TypebotInDashboard = Pick<Typebot, 'id' | 'name' | 'icon'> & {
|
||||
publishedTypebotId?: string
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import { RightPanel, useEditor } from '../../providers/EditorProvider'
|
||||
import { useTypebot } from '../../providers/TypebotProvider'
|
||||
import { useRouter } from 'next/router'
|
||||
import React, { useState } from 'react'
|
||||
import { isNotDefined } from 'utils'
|
||||
import { isDefined, isNotDefined } from 'utils'
|
||||
import { EditableTypebotName } from './EditableTypebotName'
|
||||
import { getBubbleActions } from 'typebot-js'
|
||||
import Link from 'next/link'
|
||||
@ -34,6 +34,7 @@ export const TypebotHeader = () => {
|
||||
const router = useRouter()
|
||||
const {
|
||||
typebot,
|
||||
publishedTypebot,
|
||||
updateTypebot,
|
||||
save,
|
||||
undo,
|
||||
@ -126,7 +127,7 @@ export const TypebotHeader = () => {
|
||||
>
|
||||
Share
|
||||
</Button>
|
||||
{typebot?.publishedTypebotId && (
|
||||
{isDefined(publishedTypebot) && (
|
||||
<Button
|
||||
as={Link}
|
||||
href={`/typebots/${typebot?.id}/results`}
|
||||
|
@ -16,14 +16,13 @@ import {
|
||||
useMemo,
|
||||
useState,
|
||||
} from 'react'
|
||||
import { isDefined, isNotDefined, omit } from 'utils'
|
||||
import { isDefined, omit } from 'utils'
|
||||
import { edgesAction, EdgesActions } from './actions/edges'
|
||||
import { itemsAction, ItemsActions } from './actions/items'
|
||||
import { GroupsActions, groupsActions } from './actions/groups'
|
||||
import { blocksAction, BlocksActions } from './actions/blocks'
|
||||
import { variablesAction, VariablesActions } from './actions/variables'
|
||||
import { dequal } from 'dequal'
|
||||
import cuid from 'cuid'
|
||||
import { useToast } from '@/hooks/useToast'
|
||||
import { useTypebotQuery } from '@/hooks/useTypebotQuery'
|
||||
import useUndo from '../../hooks/useUndo'
|
||||
@ -52,7 +51,6 @@ type UpdateTypebotPayload = Partial<{
|
||||
settings: Settings
|
||||
publicId: string
|
||||
name: string
|
||||
publishedTypebotId: string
|
||||
icon: string
|
||||
customDomain: string
|
||||
resultsTablePreferences: ResultsTablePreferences
|
||||
@ -254,17 +252,12 @@ export const TypebotProvider = ({
|
||||
|
||||
const publishTypebot = async () => {
|
||||
if (!localTypebot) return
|
||||
const publishedTypebotId = cuid()
|
||||
const newLocalTypebot = { ...localTypebot }
|
||||
if (publishedTypebot && isNotDefined(localTypebot.publishedTypebotId)) {
|
||||
updateLocalTypebot({ publishedTypebotId: publishedTypebot.id })
|
||||
await saveTypebot()
|
||||
}
|
||||
if (!publishedTypebot) {
|
||||
const newPublicId =
|
||||
localTypebot.publicId ??
|
||||
parseDefaultPublicId(localTypebot.name, localTypebot.id)
|
||||
updateLocalTypebot({ publicId: newPublicId, publishedTypebotId })
|
||||
updateLocalTypebot({ publicId: newPublicId })
|
||||
newLocalTypebot.publicId = newPublicId
|
||||
await saveTypebot()
|
||||
}
|
||||
@ -277,8 +270,7 @@ export const TypebotProvider = ({
|
||||
setIsPublishing(true)
|
||||
const { data, error } = await createPublishedTypebotQuery(
|
||||
{
|
||||
...parseTypebotToPublicTypebot(newLocalTypebot),
|
||||
id: publishedTypebotId,
|
||||
...omit(parseTypebotToPublicTypebot(newLocalTypebot), 'id'),
|
||||
},
|
||||
localTypebot.workspaceId
|
||||
)
|
||||
|
@ -104,7 +104,7 @@ export const FolderContent = ({ folder }: Props) => {
|
||||
if (newFolder) mutateFolders({ folders: [...folders, newFolder] })
|
||||
}
|
||||
|
||||
const handleTypebotDeleted = () => {
|
||||
const handleTypebotUpdated = () => {
|
||||
if (!typebots) return
|
||||
refetchTypebots()
|
||||
}
|
||||
@ -208,7 +208,7 @@ export const FolderContent = ({ folder }: Props) => {
|
||||
<TypebotButton
|
||||
key={typebot.id.toString()}
|
||||
typebot={typebot}
|
||||
onTypebotDeleted={handleTypebotDeleted}
|
||||
onTypebotUpdated={handleTypebotUpdated}
|
||||
onMouseDown={handleMouseDown(typebot)}
|
||||
/>
|
||||
))}
|
||||
|
@ -13,7 +13,6 @@ import {
|
||||
import { useRouter } from 'next/router'
|
||||
import { ConfirmModal } from '@/components/ConfirmModal'
|
||||
import { GripIcon } from '@/components/icons'
|
||||
import { Typebot } from 'models'
|
||||
import { useTypebotDnd } from '../TypebotDndProvider'
|
||||
import { useDebounce } from 'use-debounce'
|
||||
import { Plan } from 'db'
|
||||
@ -24,23 +23,25 @@ import {
|
||||
getTypebotQuery,
|
||||
deleteTypebotQuery,
|
||||
importTypebotQuery,
|
||||
TypebotInDashboard,
|
||||
} from '@/features/dashboard'
|
||||
import { MoreButton } from './MoreButton'
|
||||
import { EmojiOrImageIcon } from '@/components/EmojiOrImageIcon'
|
||||
import { deletePublishedTypebotQuery } from '@/features/publish/queries/deletePublishedTypebotQuery'
|
||||
|
||||
type ChatbotCardProps = {
|
||||
typebot: Pick<Typebot, 'id' | 'publishedTypebotId' | 'name' | 'icon'>
|
||||
type Props = {
|
||||
typebot: TypebotInDashboard
|
||||
isReadOnly?: boolean
|
||||
onTypebotDeleted?: () => void
|
||||
onTypebotUpdated: () => void
|
||||
onMouseDown?: (e: React.MouseEvent<HTMLButtonElement>) => void
|
||||
}
|
||||
|
||||
export const TypebotButton = ({
|
||||
typebot,
|
||||
onTypebotDeleted,
|
||||
isReadOnly = false,
|
||||
onTypebotUpdated,
|
||||
onMouseDown,
|
||||
}: ChatbotCardProps) => {
|
||||
}: Props) => {
|
||||
const router = useRouter()
|
||||
const { workspace } = useWorkspace()
|
||||
const { draggedTypebot } = useTypebotDnd()
|
||||
@ -70,7 +71,7 @@ export const TypebotButton = ({
|
||||
title: "Couldn't delete typebot",
|
||||
description: error.message,
|
||||
})
|
||||
if (onTypebotDeleted) onTypebotDeleted()
|
||||
onTypebotUpdated()
|
||||
}
|
||||
|
||||
const handleDuplicateClick = async (e: React.MouseEvent) => {
|
||||
@ -95,6 +96,17 @@ export const TypebotButton = ({
|
||||
onDeleteOpen()
|
||||
}
|
||||
|
||||
const handleUnpublishClick = async (e: React.MouseEvent) => {
|
||||
e.stopPropagation()
|
||||
if (!typebot.publishedTypebotId) return
|
||||
const { error } = await deletePublishedTypebotQuery({
|
||||
publishedTypebotId: typebot.publishedTypebotId,
|
||||
typebotId: typebot.id,
|
||||
})
|
||||
if (error) showToast({ description: error.message })
|
||||
else onTypebotUpdated()
|
||||
}
|
||||
|
||||
return (
|
||||
<Button
|
||||
as={WrapItem}
|
||||
@ -143,6 +155,9 @@ export const TypebotButton = ({
|
||||
right="20px"
|
||||
aria-label={`Show ${typebot.name} menu`}
|
||||
>
|
||||
{typebot.publishedTypebotId && (
|
||||
<MenuItem onClick={handleUnpublishClick}>Unpublish</MenuItem>
|
||||
)}
|
||||
<MenuItem onClick={handleDuplicateClick}>Duplicate</MenuItem>
|
||||
<MenuItem color="red" onClick={handleDeleteClick}>
|
||||
Delete
|
||||
|
@ -29,7 +29,7 @@ import { integrationsList } from './embeds/EmbedButton'
|
||||
|
||||
export const SharePage = () => {
|
||||
const { workspace } = useWorkspace()
|
||||
const { typebot, updateTypebot } = useTypebot()
|
||||
const { typebot, updateTypebot, publishedTypebot } = useTypebot()
|
||||
const { showToast } = useToast()
|
||||
|
||||
const handlePublicIdChange = async (publicId: string) => {
|
||||
@ -39,7 +39,7 @@ export const SharePage = () => {
|
||||
const publicId = typebot
|
||||
? typebot?.publicId ?? parseDefaultPublicId(typebot.name, typebot.id)
|
||||
: ''
|
||||
const isPublished = isDefined(typebot?.publishedTypebotId)
|
||||
const isPublished = isDefined(publishedTypebot)
|
||||
|
||||
const handlePathnameChange = (pathname: string) => {
|
||||
if (!typebot?.customDomain) return
|
||||
|
@ -2,7 +2,7 @@ import { PublicTypebot } from 'models'
|
||||
import { sendRequest } from 'utils'
|
||||
|
||||
export const createPublishedTypebotQuery = async (
|
||||
typebot: PublicTypebot,
|
||||
typebot: Omit<PublicTypebot, 'id'>,
|
||||
workspaceId: string
|
||||
) =>
|
||||
sendRequest<PublicTypebot>({
|
||||
|
@ -20,7 +20,6 @@ export const parsePublicTypebotToTypebot = (
|
||||
customDomain: existingTypebot.customDomain,
|
||||
createdAt: existingTypebot.createdAt,
|
||||
updatedAt: existingTypebot.updatedAt,
|
||||
publishedTypebotId: typebot.id,
|
||||
folderId: existingTypebot.folderId,
|
||||
icon: existingTypebot.icon,
|
||||
workspaceId: existingTypebot.workspaceId,
|
||||
|
@ -2,7 +2,8 @@ import prisma from '@/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/utils/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { WorkspaceRole } from 'db'
|
||||
import { Typebot, typebotSchema } from 'models'
|
||||
import { PublicTypebot, Typebot, typebotSchema } from 'models'
|
||||
import { omit } from 'utils'
|
||||
import { z } from 'zod'
|
||||
|
||||
export const listTypebotsProcedure = authenticatedProcedure
|
||||
@ -19,12 +20,13 @@ export const listTypebotsProcedure = authenticatedProcedure
|
||||
.output(
|
||||
z.object({
|
||||
typebots: z.array(
|
||||
typebotSchema.pick({
|
||||
name: true,
|
||||
icon: true,
|
||||
id: true,
|
||||
publishedTypebotId: true,
|
||||
})
|
||||
typebotSchema
|
||||
.pick({
|
||||
name: true,
|
||||
icon: true,
|
||||
id: true,
|
||||
})
|
||||
.and(z.object({ publishedTypebotId: z.string().optional() }))
|
||||
),
|
||||
})
|
||||
)
|
||||
@ -58,11 +60,23 @@ export const listTypebotsProcedure = authenticatedProcedure
|
||||
],
|
||||
},
|
||||
orderBy: { createdAt: 'desc' },
|
||||
select: { name: true, publishedTypebotId: true, id: true, icon: true },
|
||||
})) as Pick<Typebot, 'name' | 'id' | 'icon' | 'publishedTypebotId'>[]
|
||||
select: {
|
||||
name: true,
|
||||
publishedTypebot: { select: { id: true } },
|
||||
id: true,
|
||||
icon: true,
|
||||
},
|
||||
})) as (Pick<Typebot, 'name' | 'id' | 'icon'> & {
|
||||
publishedTypebot: Pick<PublicTypebot, 'id'>
|
||||
})[]
|
||||
|
||||
if (!typebots)
|
||||
throw new TRPCError({ code: 'NOT_FOUND', message: 'No typebots found' })
|
||||
|
||||
return { typebots }
|
||||
return {
|
||||
typebots: typebots.map((typebot) => ({
|
||||
publishedTypebotId: typebot.publishedTypebot?.id,
|
||||
...omit(typebot, 'publishedTypebot'),
|
||||
})),
|
||||
}
|
||||
})
|
||||
|
@ -80,7 +80,7 @@ test('can update workspace info', async ({ page }) => {
|
||||
await page.fill('input[value="Pro workspace"]', 'My awesome workspace')
|
||||
await page.getByTestId('typebot-logo').click({ force: true })
|
||||
await expect(
|
||||
page.getByRole('button', { name: '🏦 My awesome workspace Pro' })
|
||||
page.getByRole('button', { name: 'My awesome workspace Pro' })
|
||||
).toBeVisible()
|
||||
})
|
||||
|
||||
|
@ -14,7 +14,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
if (!workspaceId) return badRequest(res, 'workspaceId is required')
|
||||
const data = (
|
||||
typeof req.body === 'string' ? JSON.parse(req.body) : req.body
|
||||
) as PublicTypebot
|
||||
) as Omit<PublicTypebot, 'id'>
|
||||
const typebotContainsFileInput = data.groups
|
||||
.flatMap((g) => g.blocks)
|
||||
.some((b) => b.type === InputBlockType.FILE)
|
||||
|
@ -77,7 +77,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
],
|
||||
},
|
||||
orderBy: { createdAt: 'desc' },
|
||||
select: { name: true, publishedTypebotId: true, id: true, icon: true },
|
||||
select: { name: true, id: true, icon: true },
|
||||
})
|
||||
return res.send({ typebots })
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-02-05T06:21:16.522Z",
|
||||
"updatedAt": "2022-02-05T06:21:16.522Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
"updatedAt": "2022-12-23T09:04:36.750Z",
|
||||
"icon": null,
|
||||
"name": "My typebot copy",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
"updatedAt": "2022-06-02T07:34:02.336Z",
|
||||
"icon": null,
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
"updatedAt": "2022-06-15T15:36:44.821Z",
|
||||
"icon": null,
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-03-21T15:01:46.107Z",
|
||||
"updatedAt": "2022-03-21T15:03:07.312Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-02-04T13:40:19.455Z",
|
||||
"updatedAt": "2022-02-04T13:40:19.455Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-02-04T13:40:19.455Z",
|
||||
"updatedAt": "2022-02-04T13:40:19.455Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-02-07T10:06:35.274Z",
|
||||
"updatedAt": "2022-02-07T10:06:35.274Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-02-04T13:44:30.386Z",
|
||||
"updatedAt": "2022-02-04T13:44:30.386Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-02-04T13:47:42.459Z",
|
||||
"updatedAt": "2022-02-04T13:47:42.459Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-03-09T07:01:25.917Z",
|
||||
"updatedAt": "2022-03-09T07:01:25.917Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-03-08T17:18:50.337Z",
|
||||
"updatedAt": "2022-03-08T21:05:28.825Z",
|
||||
"name": "Another typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-02-04T14:14:21.394Z",
|
||||
"updatedAt": "2022-02-04T14:14:21.394Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-02-04T14:14:21.394Z",
|
||||
"updatedAt": "2022-02-04T14:14:21.394Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
"updatedAt": "2022-10-17T20:14:48.231Z",
|
||||
"icon": null,
|
||||
"name": "My typebot copy",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -1 +1,129 @@
|
||||
{"id":"clddbpdus00011asqclyl0vlw","createdAt":"2023-01-26T16:42:16.803Z","updatedAt":"2023-01-26T16:48:53.712Z","icon":null,"name":"My typebot","publishedTypebotId":null,"folderId":null,"groups":[{"id":"clddbpduq002ssq1a2h622bw0","title":"Start","blocks":[{"id":"clddbpduq002tsq1aghl4dh31","type":"start","label":"Start","groupId":"clddbpduq002ssq1a2h622bw0","outgoingEdgeId":"clddbq3yp000l3b6ss15lu48v"}],"graphCoordinates":{"x":0,"y":0}},{"id":"clddbpito000e3b6spz6qqipa","title":"Group #1","blocks":[{"id":"clddbpito000f3b6srs0cizys","type":"choice input","items":[{"id":"clddbpito000g3b6snvioor95","type":0,"blockId":"clddbpito000f3b6srs0cizys","content":"Wait now"}],"groupId":"clddbpito000e3b6spz6qqipa","options":{"buttonLabel":"Send","isMultipleChoice":false}},{"id":"clddbw55x000m3b6svz34enqq","groupId":"clddbpito000e3b6spz6qqipa","type":"Wait","options":{"secondsToWaitFor":""},"outgoingEdgeId":"clddbw6l4000n3b6st6le0hu9"}],"graphCoordinates":{"x":357.49609375,"y":148.40625}},{"id":"clddbpwh9000i3b6s9e1vdjrd","title":"Group #2","blocks":[{"id":"clddbpwh9000j3b6srnzdpbcx","type":"text","content":{"html":"<div>Hi there!</div>","richText":[{"type":"p","children":[{"text":"Hi there!"}]}],"plainText":"Hi there!"},"groupId":"clddbpwh9000i3b6s9e1vdjrd"}],"graphCoordinates":{"x":545.25,"y":447.36328125}}],"variables":[],"edges":[{"id":"clddbq3yp000l3b6ss15lu48v","to":{"groupId":"clddbpito000e3b6spz6qqipa"},"from":{"blockId":"clddbpduq002tsq1aghl4dh31","groupId":"clddbpduq002ssq1a2h622bw0"}},{"from":{"groupId":"clddbpito000e3b6spz6qqipa","blockId":"clddbw55x000m3b6svz34enqq"},"to":{"groupId":"clddbpwh9000i3b6s9e1vdjrd"},"id":"clddbw6l4000n3b6st6le0hu9"}],"theme":{"chat":{"inputs":{"color":"#303235","backgroundColor":"#FFFFFF","placeholderColor":"#9095A0"},"buttons":{"color":"#FFFFFF","backgroundColor":"#0042DA"},"hostAvatar":{"url":"https://avatars.githubusercontent.com/u/16015833?v=4","isEnabled":true},"hostBubbles":{"color":"#303235","backgroundColor":"#F7F8FF"},"guestBubbles":{"color":"#FFFFFF","backgroundColor":"#FF8E21"}},"general":{"font":"Open Sans","background":{"type":"Color","content":"#ffffff"}}},"settings":{"general":{"isBrandingEnabled":false,"isInputPrefillEnabled":true,"isResultSavingEnabled":true,"isHideQueryParamsEnabled":true,"isNewResultOnRefreshEnabled":false},"metadata":{"description":"Build beautiful conversational forms and embed them directly in your applications without a line of code. Triple your response rate and collect answers that has more value compared to a traditional form."},"typingEmulation":{"speed":300,"enabled":true,"maxDelay":1.5}},"publicId":null,"customDomain":null,"workspaceId":"proWorkspace","resultsTablePreferences":null,"isArchived":false,"isClosed":false}
|
||||
{
|
||||
"id": "clddbpdus00011asqclyl0vlw",
|
||||
"createdAt": "2023-01-26T16:42:16.803Z",
|
||||
"updatedAt": "2023-01-26T16:48:53.712Z",
|
||||
"icon": null,
|
||||
"name": "My typebot",
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
"id": "clddbpduq002ssq1a2h622bw0",
|
||||
"title": "Start",
|
||||
"blocks": [
|
||||
{
|
||||
"id": "clddbpduq002tsq1aghl4dh31",
|
||||
"type": "start",
|
||||
"label": "Start",
|
||||
"groupId": "clddbpduq002ssq1a2h622bw0",
|
||||
"outgoingEdgeId": "clddbq3yp000l3b6ss15lu48v"
|
||||
}
|
||||
],
|
||||
"graphCoordinates": { "x": 0, "y": 0 }
|
||||
},
|
||||
{
|
||||
"id": "clddbpito000e3b6spz6qqipa",
|
||||
"title": "Group #1",
|
||||
"blocks": [
|
||||
{
|
||||
"id": "clddbpito000f3b6srs0cizys",
|
||||
"type": "choice input",
|
||||
"items": [
|
||||
{
|
||||
"id": "clddbpito000g3b6snvioor95",
|
||||
"type": 0,
|
||||
"blockId": "clddbpito000f3b6srs0cizys",
|
||||
"content": "Wait now"
|
||||
}
|
||||
],
|
||||
"groupId": "clddbpito000e3b6spz6qqipa",
|
||||
"options": { "buttonLabel": "Send", "isMultipleChoice": false }
|
||||
},
|
||||
{
|
||||
"id": "clddbw55x000m3b6svz34enqq",
|
||||
"groupId": "clddbpito000e3b6spz6qqipa",
|
||||
"type": "Wait",
|
||||
"options": { "secondsToWaitFor": "" },
|
||||
"outgoingEdgeId": "clddbw6l4000n3b6st6le0hu9"
|
||||
}
|
||||
],
|
||||
"graphCoordinates": { "x": 357.49609375, "y": 148.40625 }
|
||||
},
|
||||
{
|
||||
"id": "clddbpwh9000i3b6s9e1vdjrd",
|
||||
"title": "Group #2",
|
||||
"blocks": [
|
||||
{
|
||||
"id": "clddbpwh9000j3b6srnzdpbcx",
|
||||
"type": "text",
|
||||
"content": {
|
||||
"html": "<div>Hi there!</div>",
|
||||
"richText": [
|
||||
{ "type": "p", "children": [{ "text": "Hi there!" }] }
|
||||
],
|
||||
"plainText": "Hi there!"
|
||||
},
|
||||
"groupId": "clddbpwh9000i3b6s9e1vdjrd"
|
||||
}
|
||||
],
|
||||
"graphCoordinates": { "x": 545.25, "y": 447.36328125 }
|
||||
}
|
||||
],
|
||||
"variables": [],
|
||||
"edges": [
|
||||
{
|
||||
"id": "clddbq3yp000l3b6ss15lu48v",
|
||||
"to": { "groupId": "clddbpito000e3b6spz6qqipa" },
|
||||
"from": {
|
||||
"blockId": "clddbpduq002tsq1aghl4dh31",
|
||||
"groupId": "clddbpduq002ssq1a2h622bw0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": {
|
||||
"groupId": "clddbpito000e3b6spz6qqipa",
|
||||
"blockId": "clddbw55x000m3b6svz34enqq"
|
||||
},
|
||||
"to": { "groupId": "clddbpwh9000i3b6s9e1vdjrd" },
|
||||
"id": "clddbw6l4000n3b6st6le0hu9"
|
||||
}
|
||||
],
|
||||
"theme": {
|
||||
"chat": {
|
||||
"inputs": {
|
||||
"color": "#303235",
|
||||
"backgroundColor": "#FFFFFF",
|
||||
"placeholderColor": "#9095A0"
|
||||
},
|
||||
"buttons": { "color": "#FFFFFF", "backgroundColor": "#0042DA" },
|
||||
"hostAvatar": {
|
||||
"url": "https://avatars.githubusercontent.com/u/16015833?v=4",
|
||||
"isEnabled": true
|
||||
},
|
||||
"hostBubbles": { "color": "#303235", "backgroundColor": "#F7F8FF" },
|
||||
"guestBubbles": { "color": "#FFFFFF", "backgroundColor": "#FF8E21" }
|
||||
},
|
||||
"general": {
|
||||
"font": "Open Sans",
|
||||
"background": { "type": "Color", "content": "#ffffff" }
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"general": {
|
||||
"isBrandingEnabled": false,
|
||||
"isInputPrefillEnabled": true,
|
||||
"isResultSavingEnabled": true,
|
||||
"isHideQueryParamsEnabled": true,
|
||||
"isNewResultOnRefreshEnabled": false
|
||||
},
|
||||
"metadata": {
|
||||
"description": "Build beautiful conversational forms and embed them directly in your applications without a line of code. Triple your response rate and collect answers that has more value compared to a traditional form."
|
||||
},
|
||||
"typingEmulation": { "speed": 300, "enabled": true, "maxDelay": 1.5 }
|
||||
},
|
||||
"publicId": null,
|
||||
"customDomain": null,
|
||||
"workspaceId": "proWorkspace",
|
||||
"resultsTablePreferences": null,
|
||||
"isArchived": false,
|
||||
"isClosed": false
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-02-05T06:21:16.522Z",
|
||||
"updatedAt": "2022-02-05T06:21:16.522Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-03-10T10:50:23.912Z",
|
||||
"updatedAt": "2022-03-10T10:50:23.912Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-02-04T14:17:20.022Z",
|
||||
"updatedAt": "2022-02-04T14:17:20.022Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
"updatedAt": "2022-06-26T14:07:19.077Z",
|
||||
"icon": null,
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-03-15T12:54:54.778Z",
|
||||
"updatedAt": "2022-03-15T13:13:54.482Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -108,7 +108,6 @@ test.describe('API', () => {
|
||||
expect(typebots.length).toBeGreaterThanOrEqual(1)
|
||||
expect(typebots.find((typebot) => typebot.id === typebotId)).toMatchObject({
|
||||
id: typebotId,
|
||||
publishedTypebotId: null,
|
||||
name: 'My typebot',
|
||||
})
|
||||
})
|
||||
|
@ -9,9 +9,19 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
if (!user) return res.status(401).json({ message: 'Not authenticated' })
|
||||
const typebots = await prisma.typebot.findMany({
|
||||
where: { workspace: { members: { some: { userId: user.id } } } },
|
||||
select: { name: true, publishedTypebotId: true, id: true },
|
||||
select: {
|
||||
name: true,
|
||||
publishedTypebot: { select: { id: true } },
|
||||
id: true,
|
||||
},
|
||||
})
|
||||
return res.send({
|
||||
typebots: typebots.map((typebot) => ({
|
||||
id: typebot.id,
|
||||
name: typebot.name,
|
||||
publishedTypebotId: typebot.publishedTypebot?.id,
|
||||
})),
|
||||
})
|
||||
return res.send({ typebots })
|
||||
}
|
||||
return methodNotAllowed(res)
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-02-05T06:21:16.522Z",
|
||||
"updatedAt": "2022-02-05T06:21:16.522Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
"updatedAt": "2022-11-24T09:13:16.782Z",
|
||||
"icon": "👶",
|
||||
"name": "Sub bot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
"updatedAt": "2022-11-24T09:12:57.036Z",
|
||||
"icon": "🤖",
|
||||
"name": "Complete bot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
"updatedAt": "2022-06-08T16:19:32.893Z",
|
||||
"icon": null,
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": "cl45ol3j8000f2e6gcifqf21t",
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-03-09T16:17:51.321Z",
|
||||
"updatedAt": "2022-03-09T16:19:07.037Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": "dm12bh6hmEQemywn86osJD",
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-03-08T15:58:49.720Z",
|
||||
"updatedAt": "2022-03-08T16:07:18.899Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
"updatedAt": "2022-12-15T09:17:15.366Z",
|
||||
"icon": null,
|
||||
"name": "Another typebot copy",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
"createdAt": "2022-03-23T08:41:30.106Z",
|
||||
"updatedAt": "2022-03-23T08:41:30.106Z",
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
"updatedAt": "2022-12-14T14:48:19.086Z",
|
||||
"icon": null,
|
||||
"name": "My typebot copy",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
"updatedAt": "2022-10-21T16:30:57.642Z",
|
||||
"icon": null,
|
||||
"name": "My typebot",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"groups": [
|
||||
{
|
||||
|
@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `publishedTypebotId` on the `Typebot` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Typebot" DROP COLUMN "publishedTypebotId";
|
@ -155,7 +155,6 @@ model Typebot {
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
icon String?
|
||||
name String
|
||||
publishedTypebotId String?
|
||||
folderId String?
|
||||
groups Json
|
||||
variables Json[]
|
||||
|
@ -52,7 +52,6 @@ export const typebotSchema = schemaForType<TypebotPrisma>()(
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
icon: z.string().nullable(),
|
||||
publishedTypebotId: z.string().nullable(),
|
||||
folderId: z.string().nullable(),
|
||||
publicId: z.string().nullable(),
|
||||
customDomain: z.string().nullable(),
|
||||
|
@ -24,7 +24,6 @@ export const parseTestTypebot = (
|
||||
publicId: null,
|
||||
updatedAt: new Date(),
|
||||
createdAt: new Date(),
|
||||
publishedTypebotId: null,
|
||||
customDomain: null,
|
||||
icon: null,
|
||||
isArchived: false,
|
||||
|
Reference in New Issue
Block a user