Skip to content

Commit

Permalink
🛂 Add isSuspended prop on workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jul 4, 2023
1 parent 92740ad commit 5a05310
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 13 deletions.
15 changes: 12 additions & 3 deletions apps/builder/src/features/workspace/WorkspaceProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
useMemo,
useState,
} from 'react'
import { byId } from '@typebot.io/lib'
import { byId, isNotDefined } from '@typebot.io/lib'
import { WorkspaceRole } from '@typebot.io/prisma'
import { useRouter } from 'next/router'
import { trpc } from '@/lib/trpc'
Expand Down Expand Up @@ -39,7 +39,7 @@ export const WorkspaceProvider = ({
typebotId,
children,
}: WorkspaceContextProps) => {
const { query } = useRouter()
const { pathname, query, push } = useRouter()
const { user } = useUser()
const userId = user?.id
const [workspaceId, setWorkspaceId] = useState<string | undefined>()
Expand Down Expand Up @@ -132,9 +132,18 @@ export const WorkspaceProvider = ({
workspaces,
])

useEffect(() => {
if (isNotDefined(workspace?.isSuspended)) return
if (workspace?.isSuspended && pathname !== '/suspended') push('/suspended')
}, [pathname, push, workspace?.isSuspended])

const switchWorkspace = (workspaceId: string) => {
setWorkspaceId(workspaceId)
setWorkspaceIdInLocalStorage(workspaceId)
if (pathname === '/suspended') {
window.location.href = '/typebots'
return
}
setWorkspaceId(workspaceId)
}

const createWorkspace = async (userFullName?: string) => {
Expand Down
31 changes: 31 additions & 0 deletions apps/builder/src/pages/suspended.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { TextLink } from '@/components/TextLink'
import { DashboardHeader } from '@/features/dashboard/components/DashboardHeader'
import { WorkspaceProvider } from '@/features/workspace/WorkspaceProvider'
import { Heading, Link, Text, VStack } from '@chakra-ui/react'

export default function Page() {
return (
<WorkspaceProvider>
<DashboardHeader />
<VStack w="full" h="calc(100vh - 64px)" justifyContent="center">
<Heading>Your workspace has been suspended.</Heading>
<Text>
We detected that one of your typebots does not comply with our{' '}
<TextLink
href="https://typebot.io/terms-of-service#scam-typebots"
isExternal
>
terms of service
</TextLink>
</Text>
<Text>
If you think it&apos;s a mistake, feel free to{' '}
<Link href="mailto:baptiste@typebot.io" textDecor="underline">
reach out
</Link>
.
</Text>
</VStack>
</WorkspaceProvider>
)
}
24 changes: 20 additions & 4 deletions apps/docs/openapi/builder/_spec_.json
Original file line number Diff line number Diff line change
Expand Up @@ -3900,6 +3900,9 @@
},
"isQuarantined": {
"type": "boolean"
},
"isSuspended": {
"type": "boolean"
}
},
"required": [
Expand All @@ -3919,7 +3922,8 @@
"customChatsLimit",
"customStorageLimit",
"customSeatsLimit",
"isQuarantined"
"isQuarantined",
"isSuspended"
],
"additionalProperties": false
}
Expand Down Expand Up @@ -4045,6 +4049,9 @@
},
"isQuarantined": {
"type": "boolean"
},
"isSuspended": {
"type": "boolean"
}
},
"required": [
Expand All @@ -4064,7 +4071,8 @@
"customChatsLimit",
"customStorageLimit",
"customSeatsLimit",
"isQuarantined"
"isQuarantined",
"isSuspended"
],
"additionalProperties": false
}
Expand Down Expand Up @@ -4207,6 +4215,9 @@
},
"isQuarantined": {
"type": "boolean"
},
"isSuspended": {
"type": "boolean"
}
},
"required": [
Expand All @@ -4226,7 +4237,8 @@
"customChatsLimit",
"customStorageLimit",
"customSeatsLimit",
"isQuarantined"
"isQuarantined",
"isSuspended"
],
"additionalProperties": false
}
Expand Down Expand Up @@ -5472,6 +5484,9 @@
},
"isQuarantined": {
"type": "boolean"
},
"isSuspended": {
"type": "boolean"
}
},
"required": [
Expand All @@ -5491,7 +5506,8 @@
"customChatsLimit",
"customStorageLimit",
"customSeatsLimit",
"isQuarantined"
"isQuarantined",
"isSuspended"
],
"additionalProperties": false,
"nullable": true
Expand Down
22 changes: 19 additions & 3 deletions apps/landing-page/pages/terms-of-service.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Stack, Heading } from '@chakra-ui/react'
import { Header } from 'components/common/Header/Header'
import { SocialMetaTags } from 'components/common/SocialMetaTags'
import { TextLink } from 'components/common/TextLink'

const PrivacyPolicies = () => {
return (
Expand Down Expand Up @@ -117,11 +118,26 @@ const PrivacyPolicies = () => {
bound by the current version of these Terms and Conditions of Use.
</p>

<Heading>8. Your Privacy</Heading>
<Heading id="scam-typebots">8. Prohibition of Scam Typebots</Heading>
<p>
You agree not to create or use typebots on Typebot&apos;s Website for
the purpose of engaging in fraudulent activities, scamming
individuals, or any other unethical or illegal activities. This
includes but is not limited to typebots designed to deceive, defraud,
or mislead people for financial gain or personal benefit. Typebot
reserves the right to take appropriate action, including the
termination of any user account, if it determines that a typebot is
being used in violation of this provision.
</p>

<Heading>9. Your Privacy</Heading>

<p>Please read our Privacy Policy.</p>
<p>
Please read our{' '}
<TextLink href={'/privacy-policies'}>Privacy Policy</TextLink>.
</p>

<Heading>9. Governing Law</Heading>
<Heading>10. Governing Law</Heading>

<p>
Any claim related to Typebot&apos;s Website shall be governed by the
Expand Down
11 changes: 8 additions & 3 deletions apps/viewer/src/features/chat/api/sendMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ const getTypebot = async (
additionalChatsIndex: true,
customChatsLimit: true,
isQuarantined: true,
isSuspended: true,
},
},
},
Expand All @@ -326,12 +327,16 @@ const getTypebot = async (
message: 'Typebot not found',
})

const isQuarantined =
const isQuarantinedOrSuspended =
typebotQuery &&
'typebot' in typebotQuery &&
typebotQuery.typebot.workspace.isQuarantined
(typebotQuery.typebot.workspace.isQuarantined ||
typebotQuery.typebot.workspace.isSuspended)

if (('isClosed' in parsedTypebot && parsedTypebot.isClosed) || isQuarantined)
if (
('isClosed' in parsedTypebot && parsedTypebot.isClosed) ||
isQuarantinedOrSuspended
)
throw new TRPCError({
code: 'BAD_REQUEST',
message: 'Typebot is closed',
Expand Down
1 change: 1 addition & 0 deletions packages/prisma/mysql/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ model Workspace {
customStorageLimit Int?
customSeatsLimit Int?
isQuarantined Boolean @default(false)
isSuspended Boolean @default(false)
themeTemplates ThemeTemplate[]
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Workspace" ADD COLUMN "isSuspended" BOOLEAN NOT NULL DEFAULT false;
1 change: 1 addition & 0 deletions packages/prisma/postgresql/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ model Workspace {
customStorageLimit Int?
customSeatsLimit Int?
isQuarantined Boolean @default(false)
isSuspended Boolean @default(false)
themeTemplates ThemeTemplate[]
}

Expand Down
1 change: 1 addition & 0 deletions packages/schemas/features/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const workspaceSchema = z.object({
customStorageLimit: z.number().nullable(),
customSeatsLimit: z.number().nullable(),
isQuarantined: z.boolean(),
isSuspended: z.boolean(),
}) satisfies z.ZodType<WorkspacePrisma>

export type Workspace = z.infer<typeof workspaceSchema>
Expand Down

4 comments on commit 5a05310

@vercel
Copy link

@vercel vercel bot commented on 5a05310 Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 5a05310 Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

bot.hostnation.de
bot.maitempah.com
bot.phuonghub.com
bot.reviewzer.com
bot.rihabilita.it
bot.uluhub.com.br
cares.urlabout.me
chat.gaswadern.de
chat.gniorder.com
chat.rojie.online
fmm.wpwakanda.com
footballmeetup.ie
gentleman-shop.fr
island.wakanda.is
k1.kandabrand.com
kp.pedroknoll.com
lb.ticketfute.com
ov1.wpwakanda.com
ov2.wpwakanda.com
ov3.wpwakanda.com
redeemchatgpt.com
support.triplo.ai
viewer.typebot.io
welcome.triplo.ai
1988.bouclidom.com
amancarseat.online
amostra-safe.click
andreimayer.com.br
bebesemcolicas.com
bot.danyservice.it
bot.iconicbrows.it
bot.lucide.contact
bot.neferlopez.com
bot.samplehunt.com
bot.wphelpchat.com
bots.robomotion.io
cadu.uninta.edu.br
chat.hand-made.one
chat.tuanpakya.com
chat.webisharp.com
dicanatural.online
digitalhelp.com.au
goalsettingbot.com
noticiasnet.online
pant.maxbot.com.br
pantherview.cr8.ai
bot.outstandbrand.com
bot.ramonmatos.com.br
bot.robertohairlab.it
bot.sharemyreview.net
bot.truongnguyen.live
bots.baptistearno.com
botz.cloudsiteapp.com
cdd.searchcube.com.sg
chat.missarkansas.org
chatbot.ownacademy.co
chats.maisefetivo.com
viewer-v2-typebot-io.vercel.app
mdb.assessoria.arthur.progenbr.com
mdb.assessoria.danilo.progenbr.com
mdb.assessoria.marcao.progenbr.com
mdb.assessoria.marcio.progenbr.com
preagendamento.sergiolimajr.com.br
prenotazione.ristorantekintsugi.it
studiotecnicoimmobiliaremerelli.it
download.thailandmicespecialist.com
mdb.assessoria.aloisio.progenbr.com
mdb.assessoria.girotto.progenbr.com
mdb.assessoria.marinho.progenbr.com
register.thailandmicespecialist.com
mdb.assessoria.desideri.progenbr.com
mdb.assessoria.fernanda.progenbr.com
mdb.assessoria.jbatista.progenbr.com
mdb.evento.equipeinterna.progenbr.com
bot.studiotecnicoimmobiliaremerelli.it
mdb.assessoria.boaventura.progenbr.com
mdb.assessoria.jtrebesqui.progenbr.com
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
gabinete.baleia.formulario.progenbr.com
mdb.assessoria.carreirinha.progenbr.com
chrome-os-inquiry-system.itschromeos.com
mdb.assessoria.paulomarques.progenbr.com
viewer-v2-git-main-typebot-io.vercel.app
main-menu-for-itschromeos.itschromeos.com
mdb.assessoria.qrcode.ademir.progenbr.com
mdb.assessoria.qrcode.arthur.progenbr.com
mdb.assessoria.qrcode.danilo.progenbr.com
mdb.assessoria.qrcode.marcao.progenbr.com
mdb.assessoria.qrcode.marcio.progenbr.com
mdb.assessoria.qrcode.aloisio.progenbr.com
mdb.assessoria.qrcode.girotto.progenbr.com
mdb.assessoria.qrcode.marinho.progenbr.com
mdb.assessoria.qrcode.desideri.progenbr.com
mdb.assessoria.qrcode.fernanda.progenbr.com
mdb.assessoria.qrcode.jbatista.progenbr.com
mdb.assessoria.qrcode.boaventura.progenbr.com
mdb.assessoria.qrcode.jtrebesqui.progenbr.com
mdb.assessoria.qrcode.carreirinha.progenbr.com
mdb.assessoria.qrcode.paulomarques.progenbr.com

@vercel
Copy link

@vercel vercel bot commented on 5a05310 Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app
app.typebot.io

@vercel
Copy link

@vercel vercel bot commented on 5a05310 Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-git-main-typebot-io.vercel.app
docs-typebot-io.vercel.app
docs.typebot.io

Please sign in to comment.