2
0

chore: 🔥 Remove ownerIds

This commit is contained in:
Baptiste Arnaud
2022-05-14 16:52:05 -07:00
parent 210bad32f9
commit bda4116fbc
47 changed files with 81 additions and 81 deletions

View File

@ -21,8 +21,8 @@ import { Typebot } from 'models'
import { useTypebotDnd } from 'contexts/TypebotDndContext'
import { useDebounce } from 'use-debounce'
import { EmojiOrImageIcon } from 'components/shared/EmojiOrImageIcon'
import { useUser } from 'contexts/UserContext'
import { Plan } from 'db'
import { useWorkspace } from 'contexts/WorkspaceContext'
type ChatbotCardProps = {
typebot: Pick<Typebot, 'id' | 'publishedTypebotId' | 'name' | 'icon'>
@ -38,7 +38,7 @@ export const TypebotButton = ({
onMouseDown,
}: ChatbotCardProps) => {
const router = useRouter()
const { user } = useUser()
const { workspace } = useWorkspace()
const { draggedTypebot } = useTypebotDnd()
const [draggedTypebotDebounced] = useDebounce(draggedTypebot, 200)
const {
@ -79,7 +79,7 @@ export const TypebotButton = ({
if (!typebotToDuplicate) return { error: new Error('Typebot not found') }
const { data: createdTypebot, error } = await importTypebot(
data.typebot,
user?.plan ?? Plan.FREE
workspace?.plan ?? Plan.FREE
)
if (error)
return toast({

View File

@ -12,7 +12,6 @@ import {
import { TrashIcon } from 'assets/icons'
import { UpgradeButton } from 'components/shared/buttons/UpgradeButton'
import { useTypebot } from 'contexts/TypebotContext/TypebotContext'
import { useUser } from 'contexts/UserContext'
import { useWorkspace } from 'contexts/WorkspaceContext'
import React from 'react'
import { parseDefaultPublicId } from 'services/typebots'

View File

@ -13,7 +13,6 @@ import {
} from '@chakra-ui/react'
import { ChevronLeftIcon, PlusIcon, TrashIcon } from 'assets/icons'
import React, { useState } from 'react'
import { useUser } from 'contexts/UserContext'
import { CustomDomainModal } from './CustomDomainModal'
import { deleteCustomDomain, useCustomDomains } from 'services/user'
import { useWorkspace } from 'contexts/WorkspaceContext'

View File

@ -1,7 +1,6 @@
import { useTypebot } from 'contexts/TypebotContext'
import { useUser } from 'contexts/UserContext'
import { useWorkspace } from 'contexts/WorkspaceContext'
import { Plan } from 'db'
import React, { useEffect, useState } from 'react'
import { isCloudProdInstance } from 'services/utils'
import { planToReadable } from 'services/workspace'

View File

@ -40,7 +40,6 @@ export const CreateNewTypebotButtons = () => {
...typebot,
folderId,
workspaceId: workspace.id,
ownerId: user.id,
theme: {
...typebot.theme,
chat: {

View File

@ -34,7 +34,6 @@ export function CustomAdapter(p: PrismaClient): Adapter {
...data,
id: user.id,
apiToken: randomUUID(),
plan: process.env.ADMIN_EMAIL === data.email ? Plan.PRO : Plan.FREE,
workspaces:
workspaceInvitations.length > 0
? undefined

View File

@ -81,7 +81,6 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
'blocks' in data
? data
: (parseNewTypebot({
ownerId: user.id,
ownerAvatarUrl: user.image,
...data,
}) as Prisma.TypebotUncheckedCreateInput),

View File

@ -24,7 +24,7 @@ const DashboardPage = () => {
useEffect(() => {
const subscribePlan = query.subscribePlan as 'pro' | 'team' | undefined
if (workspace && subscribePlan && user && user.plan === 'FREE') {
if (workspace && subscribePlan && user && workspace.plan === 'FREE') {
setIsLoading(true)
pay({
user,

View File

@ -3,7 +3,6 @@
"createdAt": "2022-02-04T08:16:59.215Z",
"updatedAt": "2022-02-04T08:16:59.215Z",
"name": "My typebot",
"ownerId": "ckz6t9iep0006k31a22j05fwq",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -3,7 +3,6 @@
"createdAt": "2022-03-21T15:01:46.107Z",
"updatedAt": "2022-03-21T15:03:07.312Z",
"name": "My typebot",
"ownerId": "cl10hgjy90000lm1a1gyccuqj",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -3,7 +3,6 @@
"createdAt": "2022-02-04T13:40:19.455Z",
"updatedAt": "2022-02-04T13:40:19.455Z",
"name": "My typebot",
"ownerId": "ckz6t9iep0006k31a22j05fwq",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -3,7 +3,6 @@
"createdAt": "2022-02-04T13:40:19.455Z",
"updatedAt": "2022-02-04T13:40:19.455Z",
"name": "My typebot",
"ownerId": "ckz6t9iep0006k31a22j05fwq",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -3,7 +3,6 @@
"createdAt": "2022-02-07T10:06:35.274Z",
"updatedAt": "2022-02-07T10:06:35.274Z",
"name": "My typebot",
"ownerId": "ckz6t9iep0006k31a22j05fwq",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -3,7 +3,6 @@
"createdAt": "2022-02-04T13:44:30.386Z",
"updatedAt": "2022-02-04T13:44:30.386Z",
"name": "My typebot",
"ownerId": "ckz6t9iep0006k31a22j05fwq",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -3,7 +3,6 @@
"createdAt": "2022-02-04T14:14:21.394Z",
"updatedAt": "2022-02-04T14:14:21.394Z",
"name": "My typebot",
"ownerId": "ckz6t9iep0006k31a22j05fwq",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -3,7 +3,6 @@
"createdAt": "2022-02-04T13:47:42.459Z",
"updatedAt": "2022-02-04T13:47:42.459Z",
"name": "My typebot",
"ownerId": "ckz6t9iep0006k31a22j05fwq",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -3,7 +3,6 @@
"createdAt": "2022-03-09T07:01:25.917Z",
"updatedAt": "2022-03-09T07:01:25.917Z",
"name": "My typebot",
"ownerId": "cl0cfi60r0000381a2bft9yis",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -3,7 +3,6 @@
"createdAt": "2022-03-08T17:18:50.337Z",
"updatedAt": "2022-03-08T21:05:28.825Z",
"name": "Another typebot",
"ownerId": "cl0cfi60r0000381a2bft9yis",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -3,7 +3,6 @@
"createdAt": "2022-02-04T14:14:21.394Z",
"updatedAt": "2022-02-04T14:14:21.394Z",
"name": "My typebot",
"ownerId": "ckz6t9iep0006k31a22j05fwq",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -3,7 +3,6 @@
"createdAt": "2022-02-04T14:15:06.953Z",
"updatedAt": "2022-02-04T14:15:06.953Z",
"name": "My typebot",
"ownerId": "ckz6t9iep0006k31a22j05fwq",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -3,7 +3,6 @@
"createdAt": "2022-02-05T06:21:16.522Z",
"updatedAt": "2022-02-05T06:21:16.522Z",
"name": "My typebot",
"ownerId": "ckzmhmiey001009mnzt5nkxu8",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -3,7 +3,6 @@
"createdAt": "2022-03-10T10:50:23.912Z",
"updatedAt": "2022-03-10T10:50:23.912Z",
"name": "My typebot",
"ownerId": "cl0cfi60r0000381a2bft9yis",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -3,7 +3,6 @@
"createdAt": "2022-02-04T14:17:20.022Z",
"updatedAt": "2022-02-04T14:17:20.022Z",
"name": "My typebot",
"ownerId": "ckz6t9iep0006k31a22j05fwq",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -3,7 +3,6 @@
"createdAt": "2022-02-04T14:19:29.412Z",
"updatedAt": "2022-02-04T14:19:29.412Z",
"name": "My typebot",
"ownerId": "ckz6t9iep0006k31a22j05fwq",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -249,7 +249,6 @@ const parseTypebotToPublicTypebot = (
const parseTestTypebot = (partialTypebot: Partial<Typebot>): Typebot => ({
id: partialTypebot.id ?? 'typebot',
ownerId: 'proUser',
workspaceId: proWorkspaceId,
folderId: null,
name: 'My typebot',
@ -312,10 +311,9 @@ export const importTypebotInDatabase = async (
path: string,
updates?: Partial<Typebot>
) => {
const typebot: any = {
const typebot: Typebot = {
...JSON.parse(readFileSync(path).toString()),
workspaceId: proWorkspaceId,
ownerId: 'proUser',
...updates,
}
await prisma.typebot.create({

View File

@ -3,7 +3,6 @@
"createdAt": "2022-03-22T14:33:05.037Z",
"updatedAt": "2022-03-22T16:33:37.928Z",
"name": "Onboarding",
"ownerId": "ckzmhmiey001009mnzt5nkxu8",
"publishedTypebotId": "cl128n64i00092e69wenv1dlx",
"folderId": null,
"blocks": [

View File

@ -4,7 +4,6 @@
"updatedAt": "2022-03-25T15:42:12.544Z",
"name": "Customer Support",
"icon": "😍",
"ownerId": "cl13od3wt0000pl1aat7bdrxf",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -4,7 +4,6 @@
"updatedAt": "2022-02-05T06:21:16.522Z",
"name": "Lead Generation",
"icon": "🤝",
"ownerId": "ckz6t9iep0006k31a22j05fwq",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -4,7 +4,6 @@
"updatedAt": "2022-04-09T22:35:22.449Z",
"icon": "🏆",
"name": "Lead Scoring",
"ownerId": "cl1qykt2w00007w1agho81e26",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -4,7 +4,6 @@
"updatedAt": "2022-04-08T23:03:34.726Z",
"icon": "🕹️",
"name": "Digital Marketing Quiz",
"ownerId": "cl1qykt2w00007w1agho81e26",
"publishedTypebotId": null,
"folderId": null,
"blocks": [

View File

@ -24,7 +24,7 @@ export const useCredentials = ({
}
export const createCredentials = async (
credentials: Omit<Credentials, 'id' | 'iv' | 'createdAt' | 'ownerId'>
credentials: Omit<Credentials, 'id' | 'iv' | 'createdAt'>
) =>
sendRequest<{
credentials: Credentials

View File

@ -13,7 +13,7 @@ export const useCustomDomains = ({
onError: (error: Error) => void
}) => {
const { data, error, mutate } = useSWR<
{ customDomains: Omit<CustomDomain, 'createdAt' | 'ownerId'>[] },
{ customDomains: Omit<CustomDomain, 'createdAt'>[] },
Error
>(
workspaceId ? `/api/customDomains?${stringify({ workspaceId })}` : null,
@ -29,7 +29,7 @@ export const useCustomDomains = ({
export const createCustomDomain = async (
workspaceId: string,
customDomain: Omit<CustomDomain, 'createdAt' | 'workspaceId' | 'ownerId'>
customDomain: Omit<CustomDomain, 'createdAt' | 'workspaceId'>
) =>
sendRequest<{
credentials: Credentials

View File

@ -36,7 +36,6 @@ export const parsePublicTypebotToTypebot = (
updatedAt: existingTypebot.updatedAt,
publishedTypebotId: typebot.id,
folderId: existingTypebot.folderId,
ownerId: existingTypebot.ownerId,
icon: existingTypebot.icon,
workspaceId: existingTypebot.workspaceId,
})

View File

@ -418,7 +418,6 @@ export const parseNewTypebot = ({
steps: [startStep],
}
return {
ownerId: null,
folderId,
name,
workspaceId,