mirror of
https://github.com/documenso/documenso.git
synced 2026-07-25 17:35:05 +10:00
feat: add team templates (#912)
This commit is contained in:
@@ -39,7 +39,7 @@ export const fieldRouter = router({
|
||||
|
||||
throw new TRPCError({
|
||||
code: 'BAD_REQUEST',
|
||||
message: 'We were unable to sign this field. Please try again later.',
|
||||
message: 'We were unable to set this field. Please try again later.',
|
||||
});
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -33,7 +33,7 @@ export const recipientRouter = router({
|
||||
|
||||
throw new TRPCError({
|
||||
code: 'BAD_REQUEST',
|
||||
message: 'We were unable to sign this field. Please try again later.',
|
||||
message: 'We were unable to set this field. Please try again later.',
|
||||
});
|
||||
}
|
||||
}),
|
||||
@@ -58,7 +58,7 @@ export const recipientRouter = router({
|
||||
|
||||
throw new TRPCError({
|
||||
code: 'BAD_REQUEST',
|
||||
message: 'We were unable to sign this field. Please try again later.',
|
||||
message: 'We were unable to set this field. Please try again later.',
|
||||
});
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -19,11 +19,12 @@ export const templateRouter = router({
|
||||
.input(ZCreateTemplateMutationSchema)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
try {
|
||||
const { title, templateDocumentDataId } = input;
|
||||
const { teamId, title, templateDocumentDataId } = input;
|
||||
|
||||
return await createTemplate({
|
||||
title,
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
title,
|
||||
templateDocumentDataId,
|
||||
});
|
||||
} catch (err) {
|
||||
@@ -64,11 +65,12 @@ export const templateRouter = router({
|
||||
.input(ZDuplicateTemplateMutationSchema)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
try {
|
||||
const { templateId } = input;
|
||||
const { teamId, templateId } = input;
|
||||
|
||||
return await duplicateTemplate({
|
||||
templateId,
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
templateId,
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
@@ -88,7 +90,7 @@ export const templateRouter = router({
|
||||
|
||||
const userId = ctx.user.id;
|
||||
|
||||
return await deleteTemplate({ id, userId });
|
||||
return await deleteTemplate({ userId, id });
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const ZCreateTemplateMutationSchema = z.object({
|
||||
title: z.string().min(1),
|
||||
title: z.string().min(1).trim(),
|
||||
teamId: z.number().optional(),
|
||||
templateDocumentDataId: z.string().min(1),
|
||||
});
|
||||
|
||||
@@ -11,6 +12,7 @@ export const ZCreateDocumentFromTemplateMutationSchema = z.object({
|
||||
|
||||
export const ZDuplicateTemplateMutationSchema = z.object({
|
||||
templateId: z.number(),
|
||||
teamId: z.number().optional(),
|
||||
});
|
||||
|
||||
export const ZDeleteTemplateMutationSchema = z.object({
|
||||
|
||||
Reference in New Issue
Block a user