mirror of
https://github.com/documenso/documenso.git
synced 2025-11-16 17:51:49 +10:00
fix: self sign team documents
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -17,8 +17,5 @@
|
|||||||
},
|
},
|
||||||
"[typescriptreact]": {
|
"[typescriptreact]": {
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
},
|
|
||||||
"[typescript]": {
|
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -313,6 +313,7 @@ export const EditDocumentForm = ({
|
|||||||
if (hasSameOwnerAsRecipient) {
|
if (hasSameOwnerAsRecipient) {
|
||||||
await selfSignDocument({
|
await selfSignDocument({
|
||||||
documentId: document.id,
|
documentId: document.id,
|
||||||
|
teamId: team?.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
router.push(`/sign/${recipients[0].token}`);
|
router.push(`/sign/${recipients[0].token}`);
|
||||||
|
|||||||
@ -12,12 +12,14 @@ import { insertFormValuesInPdf } from '../pdf/insert-form-values-in-pdf';
|
|||||||
export type SelfSignDocumentOptions = {
|
export type SelfSignDocumentOptions = {
|
||||||
documentId: number;
|
documentId: number;
|
||||||
userId: number;
|
userId: number;
|
||||||
|
teamId?: number;
|
||||||
requestMetadata?: RequestMetadata;
|
requestMetadata?: RequestMetadata;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const selfSignDocument = async ({
|
export const selfSignDocument = async ({
|
||||||
documentId,
|
documentId,
|
||||||
userId,
|
userId,
|
||||||
|
teamId,
|
||||||
requestMetadata,
|
requestMetadata,
|
||||||
}: SelfSignDocumentOptions) => {
|
}: SelfSignDocumentOptions) => {
|
||||||
const user = await prisma.user.findFirstOrThrow({
|
const user = await prisma.user.findFirstOrThrow({
|
||||||
@ -31,11 +33,24 @@ export const selfSignDocument = async ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const document = await prisma.document.findFirstOrThrow({
|
const document = await prisma.document.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: documentId,
|
id: documentId,
|
||||||
|
...(teamId
|
||||||
|
? {
|
||||||
|
team: {
|
||||||
|
id: teamId,
|
||||||
|
members: {
|
||||||
|
some: {
|
||||||
|
userId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {
|
||||||
userId,
|
userId,
|
||||||
teamId: null,
|
teamId: null,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
Recipient: {
|
Recipient: {
|
||||||
|
|||||||
@ -458,11 +458,12 @@ export const documentRouter = router({
|
|||||||
.input(ZSelfSignDocumentMutationSchema)
|
.input(ZSelfSignDocumentMutationSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
try {
|
try {
|
||||||
const { documentId } = input;
|
const { documentId, teamId } = input;
|
||||||
|
|
||||||
return await selfSignDocument({
|
return await selfSignDocument({
|
||||||
userId: ctx.user.id,
|
userId: ctx.user.id,
|
||||||
documentId,
|
documentId,
|
||||||
|
teamId,
|
||||||
requestMetadata: extractNextApiRequestMetadata(ctx.req),
|
requestMetadata: extractNextApiRequestMetadata(ctx.req),
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@ -172,6 +172,7 @@ export const ZSendDocumentMutationSchema = z.object({
|
|||||||
|
|
||||||
export const ZSelfSignDocumentMutationSchema = z.object({
|
export const ZSelfSignDocumentMutationSchema = z.object({
|
||||||
documentId: z.number(),
|
documentId: z.number(),
|
||||||
|
teamId: z.number().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const ZSetPasswordForDocumentMutationSchema = z.object({
|
export const ZSetPasswordForDocumentMutationSchema = z.object({
|
||||||
|
|||||||
Reference in New Issue
Block a user