🐛 (folders) Make sure to exit folder on workspace change
This commit is contained in:
@ -46,6 +46,7 @@ export const getFolder = authenticatedProcedure
|
||||
const folder = await prisma.dashboardFolder.findUnique({
|
||||
where: {
|
||||
id: folderId,
|
||||
workspaceId,
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -23,9 +23,11 @@ export const FolderPage = () => {
|
||||
},
|
||||
{
|
||||
enabled: !!workspace && !!router.query.id,
|
||||
retry: 0,
|
||||
onError: (error) => {
|
||||
if (error.data?.httpStatus === 404) router.replace('/typebots')
|
||||
showToast({
|
||||
description: error.message,
|
||||
title: 'Folder not found',
|
||||
})
|
||||
},
|
||||
}
|
||||
|
@ -80,6 +80,15 @@ export const createTypebot = authenticatedProcedure
|
||||
message: 'Public id not available',
|
||||
})
|
||||
|
||||
if (typebot.folderId) {
|
||||
const existingFolder = await prisma.dashboardFolder.findUnique({
|
||||
where: {
|
||||
id: typebot.folderId,
|
||||
},
|
||||
})
|
||||
if (!existingFolder) typebot.folderId = null
|
||||
}
|
||||
|
||||
const newTypebot = await prisma.typebot.create({
|
||||
data: {
|
||||
version: '6',
|
||||
|
@ -50,7 +50,7 @@ export const WorkspaceProvider = ({
|
||||
typebotId,
|
||||
children,
|
||||
}: WorkspaceContextProps) => {
|
||||
const { pathname, query, push, isReady: isRouterReady } = useRouter()
|
||||
const { pathname, query, push, isReady: isRouterReady, replace } = useRouter()
|
||||
const { user } = useUser()
|
||||
const userId = user?.id
|
||||
const [workspaceId, setWorkspaceId] = useState<string | undefined>()
|
||||
@ -163,6 +163,7 @@ export const WorkspaceProvider = ({
|
||||
const switchWorkspace = (workspaceId: string) => {
|
||||
setWorkspaceIdInLocalStorage(workspaceId)
|
||||
setWorkspaceId(workspaceId)
|
||||
replace('/typebots')
|
||||
}
|
||||
|
||||
const createWorkspace = async (userFullName?: string) => {
|
||||
|
@ -16024,6 +16024,17 @@
|
||||
},
|
||||
"skip": {
|
||||
"type": "string"
|
||||
},
|
||||
"success": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"single": {
|
||||
"type": "string"
|
||||
},
|
||||
"multiple": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -18711,6 +18722,17 @@
|
||||
},
|
||||
"skip": {
|
||||
"type": "string"
|
||||
},
|
||||
"success": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"single": {
|
||||
"type": "string"
|
||||
},
|
||||
"multiple": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -6309,6 +6309,17 @@
|
||||
},
|
||||
"skip": {
|
||||
"type": "string"
|
||||
},
|
||||
"success": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"single": {
|
||||
"type": "string"
|
||||
},
|
||||
"multiple": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -9421,6 +9432,17 @@
|
||||
},
|
||||
"skip": {
|
||||
"type": "string"
|
||||
},
|
||||
"success": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"single": {
|
||||
"type": "string"
|
||||
},
|
||||
"multiple": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user