mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 04:22:32 +10:00
Compare commits
3 Commits
eff7d90f43
...
fix/templa
| Author | SHA1 | Date | |
|---|---|---|---|
| 90b6ebe5f0 | |||
| 6e8cd8fc6a | |||
| 928745e13b |
@ -1,6 +1,7 @@
|
||||
import type { z } from 'zod';
|
||||
|
||||
import { prisma } from '@documenso/prisma';
|
||||
import { FolderType } from '@documenso/prisma/generated/types';
|
||||
import { TemplateSchema } from '@documenso/prisma/generated/zod/modelSchema//TemplateSchema';
|
||||
import type { TCreateTemplateMutationSchema } from '@documenso/trpc/server/template-router/schema';
|
||||
|
||||
@ -44,29 +45,34 @@ export const createTemplate = async ({
|
||||
}
|
||||
}
|
||||
|
||||
const folder = await prisma.folder.findFirstOrThrow({
|
||||
where: {
|
||||
id: folderId,
|
||||
...(teamId
|
||||
? {
|
||||
team: {
|
||||
id: teamId,
|
||||
members: {
|
||||
some: {
|
||||
userId,
|
||||
let folder = null;
|
||||
|
||||
if (folderId) {
|
||||
folder = await prisma.folder.findFirst({
|
||||
where: {
|
||||
id: folderId,
|
||||
type: FolderType.TEMPLATE,
|
||||
...(teamId
|
||||
? {
|
||||
team: {
|
||||
id: teamId,
|
||||
members: {
|
||||
some: {
|
||||
userId,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
: {
|
||||
userId,
|
||||
teamId: null,
|
||||
}),
|
||||
},
|
||||
});
|
||||
}
|
||||
: {
|
||||
userId,
|
||||
teamId: null,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
if (!team) {
|
||||
throw new AppError(AppErrorCode.NOT_FOUND);
|
||||
if (!folder) {
|
||||
throw new AppError(AppErrorCode.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
return await prisma.template.create({
|
||||
@ -75,7 +81,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