Skip to content

Commit

Permalink
chore: 🔥 Remove ownerIds
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed May 17, 2022
1 parent 210bad3 commit bda4116
Show file tree
Hide file tree
Showing 47 changed files with 81 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'>
Expand All @@ -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 {
Expand Down Expand Up @@ -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({
Expand Down
1 change: 0 additions & 1 deletion apps/builder/components/share/ShareContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 0 additions & 1 deletion apps/builder/components/shared/SupportBubble.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const CreateNewTypebotButtons = () => {
...typebot,
folderId,
workspaceId: workspace.id,
ownerId: user.id,
theme: {
...typebot.theme,
chat: {
Expand Down
1 change: 0 additions & 1 deletion apps/builder/pages/api/auth/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion apps/builder/pages/api/typebots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/pages/typebots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
1 change: 0 additions & 1 deletion apps/builder/playwright/fixtures/typebots/logic/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
1 change: 0 additions & 1 deletion apps/builder/playwright/fixtures/typebots/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
1 change: 0 additions & 1 deletion apps/builder/playwright/fixtures/typebots/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
4 changes: 1 addition & 3 deletions apps/builder/playwright/services/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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({
Expand Down
1 change: 0 additions & 1 deletion apps/builder/public/bots/onboarding.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
1 change: 0 additions & 1 deletion apps/builder/public/templates/customer-support.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"updatedAt": "2022-03-25T15:42:12.544Z",
"name": "Customer Support",
"icon": "😍",
"ownerId": "cl13od3wt0000pl1aat7bdrxf",
"publishedTypebotId": null,
"folderId": null,
"blocks": [
Expand Down
1 change: 0 additions & 1 deletion apps/builder/public/templates/lead-gen.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"updatedAt": "2022-02-05T06:21:16.522Z",
"name": "Lead Generation",
"icon": "🤝",
"ownerId": "ckz6t9iep0006k31a22j05fwq",
"publishedTypebotId": null,
"folderId": null,
"blocks": [
Expand Down
1 change: 0 additions & 1 deletion apps/builder/public/templates/lead-scoring.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"updatedAt": "2022-04-09T22:35:22.449Z",
"icon": "🏆",
"name": "Lead Scoring",
"ownerId": "cl1qykt2w00007w1agho81e26",
"publishedTypebotId": null,
"folderId": null,
"blocks": [
Expand Down
1 change: 0 additions & 1 deletion apps/builder/public/templates/quiz.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"updatedAt": "2022-04-08T23:03:34.726Z",
"icon": "🕹️",
"name": "Digital Marketing Quiz",
"ownerId": "cl1qykt2w00007w1agho81e26",
"publishedTypebotId": null,
"folderId": null,
"blocks": [
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/services/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/services/customDomains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion apps/builder/services/publicTypebot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down
1 change: 0 additions & 1 deletion apps/builder/services/typebots/typebots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ export const parseNewTypebot = ({
steps: [startStep],
}
return {
ownerId: null,
folderId,
name,
workspaceId,
Expand Down
1 change: 0 additions & 1 deletion apps/landing-page/public/typebots/lead-gen-lp.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"createdAt": "2022-03-15T12:54:54.778Z",
"updatedAt": "2022-03-15T13:13:54.482Z",
"name": "My typebot",
"ownerId": "ckzmhmiey001009mnzt5nkxu8",
"publishedTypebotId": null,
"folderId": null,
"blocks": [
Expand Down
1 change: 0 additions & 1 deletion apps/landing-page/public/typebots/realtime-airtable.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"createdAt": "2022-03-15T15:41:00.241Z",
"updatedAt": "2022-03-15T17:32:29.840Z",
"name": "My typebot",
"ownerId": "ckzmhmiey001009mnzt5nkxu8",
"publishedTypebotId": "pioizXgk6U9Xtz1BdyjPFy",
"folderId": null,
"blocks": [
Expand Down
1 change: 0 additions & 1 deletion apps/viewer/playwright/fixtures/typebots/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"createdAt": "2022-02-05T06:21:16.522Z",
"updatedAt": "2022-02-05T06:21:16.522Z",
"name": "My typebot",
"ownerId": "ckzwaq0p000149f1a2ejh3qm0",
"publishedTypebotId": null,
"folderId": null,
"blocks": [
Expand Down
1 change: 0 additions & 1 deletion apps/viewer/playwright/fixtures/typebots/hugeBlock.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"createdAt": "2022-03-09T16:17:51.321Z",
"updatedAt": "2022-03-09T16:19:07.037Z",
"name": "My typebot",
"ownerId": "cl0cfi60r0000381a2bft9yis",
"publishedTypebotId": "dm12bh6hmEQemywn86osJD",
"folderId": null,
"blocks": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"createdAt": "2022-03-08T15:58:49.720Z",
"updatedAt": "2022-03-08T16:07:18.899Z",
"name": "My typebot",
"ownerId": "cl0cfi60r0000381a2bft9yis",
"publishedTypebotId": null,
"folderId": null,
"blocks": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"createdAt": "2022-03-08T15:59:06.589Z",
"updatedAt": "2022-03-08T15:59:10.498Z",
"name": "Another typebot",
"ownerId": "cl0cfi60r0000381a2bft9yis",
"publishedTypebotId": null,
"folderId": null,
"blocks": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"createdAt": "2022-03-23T08:41:30.106Z",
"updatedAt": "2022-03-23T08:41:30.106Z",
"name": "My typebot",
"ownerId": "cl139ni700000481a01gxhw4z",
"publishedTypebotId": null,
"folderId": null,
"blocks": [
Expand Down
1 change: 0 additions & 1 deletion apps/viewer/playwright/fixtures/typebots/sendEmail.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"updatedAt": "2022-04-12T14:34:44.287Z",
"icon": null,
"name": "My typebot",
"ownerId": "ckzmhmiey001009mnzt5nkxu8",
"publishedTypebotId": null,
"folderId": null,
"blocks": [
Expand Down
1 change: 0 additions & 1 deletion apps/viewer/playwright/fixtures/typebots/webhook.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"updatedAt": "2022-04-19T20:40:48.366Z",
"icon": null,
"name": "My typebot",
"ownerId": "proUser",
"publishedTypebotId": null,
"folderId": null,
"blocks": [
Expand Down
Loading

0 comments on commit bda4116

Please sign in to comment.