feat: add folders (#1711)

This commit is contained in:
Catalin Pit
2025-05-01 19:46:59 +03:00
committed by GitHub
parent 12ada567f5
commit 17370749b4
91 changed files with 10497 additions and 183 deletions

View File

@ -20,6 +20,7 @@ export const createTemplate = async ({
userId,
teamId,
templateDocumentDataId,
folderId,
}: CreateTemplateOptions) => {
let team = null;
@ -43,12 +44,38 @@ export const createTemplate = async ({
}
}
const folder = await prisma.folder.findFirstOrThrow({
where: {
id: folderId,
...(teamId
? {
team: {
id: teamId,
members: {
some: {
userId,
},
},
},
}
: {
userId,
teamId: null,
}),
},
});
if (!team) {
throw new AppError(AppErrorCode.NOT_FOUND);
}
return await prisma.template.create({
data: {
title,
userId,
templateDocumentDataId,
teamId,
folderId: folder.id,
templateMeta: {
create: {
language: team?.teamGlobalSettings?.documentLanguage,