mirror of
https://github.com/documenso/documenso.git
synced 2025-11-18 10:42:01 +10:00
document status, dashboard
This commit is contained in:
@ -39,18 +39,14 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||
// todo handle sending to single recipient even though more exist
|
||||
|
||||
const recipients = prisma.recipient.findMany({
|
||||
where: { documentId: +documentId },
|
||||
where: {
|
||||
documentId: +documentId,
|
||||
sendStatus: SendStatus.NOT_SENT,
|
||||
},
|
||||
});
|
||||
|
||||
(await recipients).forEach(async (recipient) => {
|
||||
await sendSigningRequestMail(recipient, document);
|
||||
await prisma.recipient.updateMany({
|
||||
where: {
|
||||
id: recipient.id,
|
||||
sendStatus: SendStatus.NOT_SENT,
|
||||
},
|
||||
data: { sendStatus: SendStatus.SENT },
|
||||
});
|
||||
});
|
||||
|
||||
return res.status(200).end();
|
||||
|
||||
@ -5,7 +5,7 @@ import {
|
||||
} from "@documenso/lib/server";
|
||||
import prisma from "@documenso/prisma";
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import { SigningStatus } from "@prisma/client";
|
||||
import { SigningStatus, DocumentStatus } from "@prisma/client";
|
||||
|
||||
async function postHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const existingUser = await getUserFromToken(req, res);
|
||||
@ -33,7 +33,24 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||
|
||||
if (!document) res.status(404).end(`No document found.`);
|
||||
|
||||
// todo sign ui
|
||||
// todo sign stuff
|
||||
|
||||
const unsignedRecipients = await prisma.recipient.findMany({
|
||||
where: {
|
||||
signingStatus: SigningStatus.NOT_SIGNED,
|
||||
},
|
||||
});
|
||||
|
||||
if (unsignedRecipients.length === 0) {
|
||||
await prisma.document.update({
|
||||
where: {
|
||||
id: recipient.documentId,
|
||||
},
|
||||
data: {
|
||||
status: DocumentStatus.COMPLETED,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
await prisma.recipient.update({
|
||||
where: {
|
||||
|
||||
@ -57,6 +57,7 @@ async function getHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
status: true,
|
||||
Recipient: true,
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user