🛂 Add isSuspended prop on workspace
This commit is contained in:
@@ -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'
|
||||
@@ -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>()
|
||||
@@ -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) => {
|
||||
|
||||
31
apps/builder/src/pages/suspended.tsx
Normal file
31
apps/builder/src/pages/suspended.tsx
Normal file
@@ -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's a mistake, feel free to{' '}
|
||||
<Link href="mailto:baptiste@typebot.io" textDecor="underline">
|
||||
reach out
|
||||
</Link>
|
||||
.
|
||||
</Text>
|
||||
</VStack>
|
||||
</WorkspaceProvider>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user