2
0

🛂 Add isSuspended prop on workspace

This commit is contained in:
Baptiste Arnaud
2023-07-04 14:56:36 +02:00
parent 92740ad2ff
commit 5a05310a9c
9 changed files with 95 additions and 13 deletions

View File

@@ -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) => {

View 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&apos;s a mistake, feel free to{' '}
<Link href="mailto:baptiste@typebot.io" textDecor="underline">
reach out
</Link>
.
</Text>
</VStack>
</WorkspaceProvider>
)
}