mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 08:42:12 +10:00
fix: fix folder retrieval for template creation
This commit is contained in:
@ -44,9 +44,13 @@ export const createTemplate = async ({
|
||||
}
|
||||
}
|
||||
|
||||
const folder = await prisma.folder.findFirstOrThrow({
|
||||
let folder = null;
|
||||
|
||||
if (folderId) {
|
||||
folder = await prisma.folder.findFirstOrThrow({
|
||||
where: {
|
||||
id: folderId,
|
||||
type: 'TEMPLATE',
|
||||
...(teamId
|
||||
? {
|
||||
team: {
|
||||
@ -65,9 +69,10 @@ export const createTemplate = async ({
|
||||
},
|
||||
});
|
||||
|
||||
if (!team) {
|
||||
if (!folder) {
|
||||
throw new AppError(AppErrorCode.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
return await prisma.template.create({
|
||||
data: {
|
||||
@ -75,7 +80,7 @@ export const createTemplate = async ({
|
||||
userId,
|
||||
templateDocumentDataId,
|
||||
teamId,
|
||||
folderId: folder.id,
|
||||
folderId: folder?.id,
|
||||
templateMeta: {
|
||||
create: {
|
||||
language: team?.teamGlobalSettings?.documentLanguage,
|
||||
|
||||
Reference in New Issue
Block a user