@@ -17,9 +17,22 @@ import { useTypebot } from '../editor/providers/TypebotProvider'
|
||||
import { setWorkspaceIdInLocalStorage } from './helpers/setWorkspaceIdInLocalStorage'
|
||||
import { parseNewName } from './helpers/parseNewName'
|
||||
|
||||
export type WorkspaceInApp = Omit<
|
||||
Workspace,
|
||||
| 'chatsLimitFirstEmailSentAt'
|
||||
| 'chatsLimitSecondEmailSentAt'
|
||||
| 'storageLimitFirstEmailSentAt'
|
||||
| 'storageLimitSecondEmailSentAt'
|
||||
| 'customChatsLimit'
|
||||
| 'customStorageLimit'
|
||||
| 'additionalChatsIndex'
|
||||
| 'additionalStorageIndex'
|
||||
| 'isQuarantined'
|
||||
>
|
||||
|
||||
const workspaceContext = createContext<{
|
||||
workspaces: Pick<Workspace, 'id' | 'name' | 'icon' | 'plan'>[]
|
||||
workspace?: Workspace
|
||||
workspace?: WorkspaceInApp
|
||||
currentRole?: WorkspaceRole
|
||||
switchWorkspace: (workspaceId: string) => void
|
||||
createWorkspace: (name?: string) => Promise<void>
|
||||
|
||||
@@ -19,7 +19,18 @@ export const createWorkspace = authenticatedProcedure
|
||||
.input(z.object({ icon: z.string().optional(), name: z.string() }))
|
||||
.output(
|
||||
z.object({
|
||||
workspace: workspaceSchema,
|
||||
workspace: workspaceSchema.omit({
|
||||
chatsLimitFirstEmailSentAt: true,
|
||||
chatsLimitSecondEmailSentAt: true,
|
||||
storageLimitFirstEmailSentAt: true,
|
||||
storageLimitSecondEmailSentAt: true,
|
||||
customChatsLimit: true,
|
||||
customSeatsLimit: true,
|
||||
customStorageLimit: true,
|
||||
additionalChatsIndex: true,
|
||||
additionalStorageIndex: true,
|
||||
isQuarantined: true,
|
||||
}),
|
||||
})
|
||||
)
|
||||
.mutation(async ({ input: { name, icon }, ctx: { user } }) => {
|
||||
|
||||
@@ -16,7 +16,11 @@ export const deleteWorkspace = authenticatedProcedure
|
||||
})
|
||||
.input(
|
||||
z.object({
|
||||
workspaceId: z.string(),
|
||||
workspaceId: z
|
||||
.string()
|
||||
.describe(
|
||||
'[Where to find my workspace ID?](../how-to#how-to-find-my-workspaceid)'
|
||||
),
|
||||
})
|
||||
)
|
||||
.output(
|
||||
|
||||
@@ -17,12 +17,26 @@ export const getWorkspace = authenticatedProcedure
|
||||
})
|
||||
.input(
|
||||
z.object({
|
||||
workspaceId: z.string(),
|
||||
workspaceId: z
|
||||
.string()
|
||||
.describe(
|
||||
'[Where to find my workspace ID?](../how-to#how-to-find-my-workspaceid)'
|
||||
),
|
||||
})
|
||||
)
|
||||
.output(
|
||||
z.object({
|
||||
workspace: workspaceSchema,
|
||||
workspace: workspaceSchema.omit({
|
||||
chatsLimitFirstEmailSentAt: true,
|
||||
chatsLimitSecondEmailSentAt: true,
|
||||
storageLimitFirstEmailSentAt: true,
|
||||
storageLimitSecondEmailSentAt: true,
|
||||
customChatsLimit: true,
|
||||
customStorageLimit: true,
|
||||
additionalChatsIndex: true,
|
||||
additionalStorageIndex: true,
|
||||
isQuarantined: true,
|
||||
}),
|
||||
})
|
||||
)
|
||||
.query(async ({ input: { workspaceId }, ctx: { user } }) => {
|
||||
|
||||
@@ -17,7 +17,11 @@ export const listInvitationsInWorkspace = authenticatedProcedure
|
||||
})
|
||||
.input(
|
||||
z.object({
|
||||
workspaceId: z.string(),
|
||||
workspaceId: z
|
||||
.string()
|
||||
.describe(
|
||||
'[Where to find my workspace ID?](../how-to#how-to-find-my-workspaceid)'
|
||||
),
|
||||
})
|
||||
)
|
||||
.output(
|
||||
|
||||
@@ -17,7 +17,11 @@ export const listMembersInWorkspace = authenticatedProcedure
|
||||
})
|
||||
.input(
|
||||
z.object({
|
||||
workspaceId: z.string(),
|
||||
workspaceId: z
|
||||
.string()
|
||||
.describe(
|
||||
'[Where to find my workspace ID?](../how-to#how-to-find-my-workspaceid)'
|
||||
),
|
||||
})
|
||||
)
|
||||
.output(
|
||||
|
||||
@@ -19,12 +19,16 @@ export const updateWorkspace = authenticatedProcedure
|
||||
z.object({
|
||||
name: z.string().optional(),
|
||||
icon: z.string().optional(),
|
||||
workspaceId: z.string(),
|
||||
workspaceId: z
|
||||
.string()
|
||||
.describe(
|
||||
'[Where to find my workspace ID?](../how-to#how-to-find-my-workspaceid)'
|
||||
),
|
||||
})
|
||||
)
|
||||
.output(
|
||||
z.object({
|
||||
workspace: workspaceSchema,
|
||||
workspace: workspaceSchema.pick({ name: true, icon: true }),
|
||||
})
|
||||
)
|
||||
.mutation(async ({ input: { workspaceId, ...updates }, ctx: { user } }) => {
|
||||
|
||||
@@ -17,10 +17,10 @@ import {
|
||||
MenuItem,
|
||||
Text,
|
||||
} from '@chakra-ui/react'
|
||||
import { Workspace } from '@typebot.io/schemas'
|
||||
import { WorkspaceInApp } from '../WorkspaceProvider'
|
||||
|
||||
type Props = {
|
||||
currentWorkspace?: Workspace
|
||||
currentWorkspace?: WorkspaceInApp
|
||||
onWorkspaceSelected: (workspaceId: string) => void
|
||||
onCreateNewWorkspaceClick: () => void
|
||||
onLogoutClick: () => void
|
||||
|
||||
@@ -6,6 +6,10 @@ import {
|
||||
Button,
|
||||
useDisclosure,
|
||||
Text,
|
||||
Input,
|
||||
InputGroup,
|
||||
InputRightElement,
|
||||
FormHelperText,
|
||||
} from '@chakra-ui/react'
|
||||
import { ConfirmModal } from '@/components/ConfirmModal'
|
||||
import React from 'react'
|
||||
@@ -13,6 +17,7 @@ import { EditableEmojiOrImageIcon } from '@/components/EditableEmojiOrImageIcon'
|
||||
import { useWorkspace } from '../WorkspaceProvider'
|
||||
import { TextInput } from '@/components/inputs'
|
||||
import { useTranslate } from '@tolgee/react'
|
||||
import { CopyButton } from '@/components/CopyButton'
|
||||
|
||||
export const WorkspaceSettingsForm = ({ onClose }: { onClose: () => void }) => {
|
||||
const { t } = useTranslate()
|
||||
@@ -50,12 +55,31 @@ export const WorkspaceSettingsForm = ({ onClose }: { onClose: () => void }) => {
|
||||
</Flex>
|
||||
</FormControl>
|
||||
{workspace && (
|
||||
<TextInput
|
||||
label={t('workspace.settings.name.label')}
|
||||
withVariableButton={false}
|
||||
defaultValue={workspace?.name}
|
||||
onChange={handleNameChange}
|
||||
/>
|
||||
<>
|
||||
<TextInput
|
||||
label={t('workspace.settings.name.label')}
|
||||
withVariableButton={false}
|
||||
defaultValue={workspace?.name}
|
||||
onChange={handleNameChange}
|
||||
/>
|
||||
<FormControl>
|
||||
<FormLabel>ID:</FormLabel>
|
||||
<InputGroup>
|
||||
<Input
|
||||
type={'text'}
|
||||
defaultValue={workspace.id}
|
||||
pr="16"
|
||||
readOnly
|
||||
/>
|
||||
<InputRightElement width="72px">
|
||||
<CopyButton textToCopy={workspace.id} size="xs" />
|
||||
</InputRightElement>
|
||||
</InputGroup>
|
||||
<FormHelperText>
|
||||
Used when interacting with the Typebot API.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</>
|
||||
)}
|
||||
{workspace && workspaces && workspaces.length > 1 && (
|
||||
<DeleteWorkspaceButton
|
||||
|
||||
@@ -15,11 +15,11 @@ import {
|
||||
UsersIcon,
|
||||
} from '@/components/icons'
|
||||
import { EmojiOrImageIcon } from '@/components/EmojiOrImageIcon'
|
||||
import { User, Workspace, WorkspaceRole } from '@typebot.io/prisma'
|
||||
import { User, WorkspaceRole } from '@typebot.io/prisma'
|
||||
import { useState } from 'react'
|
||||
import { MembersList } from './MembersList'
|
||||
import { WorkspaceSettingsForm } from './WorkspaceSettingsForm'
|
||||
import { useWorkspace } from '../WorkspaceProvider'
|
||||
import { WorkspaceInApp, useWorkspace } from '../WorkspaceProvider'
|
||||
import packageJson from '../../../../../../package.json'
|
||||
import { UserPreferencesForm } from '@/features/account/components/UserPreferencesForm'
|
||||
import { MyAccountForm } from '@/features/account/components/MyAccountForm'
|
||||
@@ -29,7 +29,7 @@ import { useTranslate } from '@tolgee/react'
|
||||
type Props = {
|
||||
isOpen: boolean
|
||||
user: User
|
||||
workspace: Workspace
|
||||
workspace: WorkspaceInApp
|
||||
onClose: () => void
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user