mirror of
https://github.com/documenso/documenso.git
synced 2025-11-18 10:42:01 +10:00
feat: wip
This commit is contained in:
@ -70,20 +70,24 @@ export const documentRouter = router({
|
||||
.input(ZCreateDocumentMutationSchema)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
try {
|
||||
const { title, documentDataId } = input;
|
||||
const { title, documentDataId, teamId } = input;
|
||||
|
||||
const { remaining } = await getServerLimits({ email: ctx.user.email });
|
||||
// Teams bypass document limits.
|
||||
if (teamId !== undefined) {
|
||||
const { remaining } = await getServerLimits({ email: ctx.user.email });
|
||||
|
||||
if (remaining.documents <= 0) {
|
||||
throw new TRPCError({
|
||||
code: 'BAD_REQUEST',
|
||||
message:
|
||||
'You have reached your document limit for this month. Please upgrade your plan.',
|
||||
});
|
||||
if (remaining.documents <= 0) {
|
||||
throw new TRPCError({
|
||||
code: 'BAD_REQUEST',
|
||||
message:
|
||||
'You have reached your document limit for this month. Please upgrade your plan.',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return await createDocument({
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
title,
|
||||
documentDataId,
|
||||
});
|
||||
|
||||
@ -17,6 +17,7 @@ export type TGetDocumentByTokenQuerySchema = z.infer<typeof ZGetDocumentByTokenQ
|
||||
export const ZCreateDocumentMutationSchema = z.object({
|
||||
title: z.string().min(1),
|
||||
documentDataId: z.string().min(1),
|
||||
teamId: z.number().optional(),
|
||||
});
|
||||
|
||||
export type TCreateDocumentMutationSchema = z.infer<typeof ZCreateDocumentMutationSchema>;
|
||||
|
||||
Reference in New Issue
Block a user