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