2
0

🐛 (folders) Make sure to exit folder on workspace change

This commit is contained in:
Baptiste Arnaud
2024-02-06 12:26:20 +01:00
parent 5e9dfaaa49
commit c2603d99b1
6 changed files with 59 additions and 2 deletions

View File

@ -46,6 +46,7 @@ export const getFolder = authenticatedProcedure
const folder = await prisma.dashboardFolder.findUnique({
where: {
id: folderId,
workspaceId,
},
})

View File

@ -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',
})
},
}

View File

@ -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',

View File

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

View File

@ -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"
}
}
}
}
},

View File

@ -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"
}
}
}
}
},