IO-2433 Delete on cancel, improved styling.

This commit is contained in:
Patrick Fic
2026-02-27 16:03:27 -08:00
parent 52f43a600c
commit 51fba24a3d
5 changed files with 66 additions and 40 deletions

View File

@@ -43,8 +43,25 @@ async function distributeDocument(req, res) {
}
}
async function newEsignDocument(req, res) {
async function deleteDocument(req, res) {
try {
const { documentId } = req.body;
//TODO: This needs to be hardened to prevent deleting other people's documents, completed ones, etc.
const deleteResult = await documenso.documents.delete({
documentId
});
res.json({ success: true, deleteResult });
} catch (error) {
console.error("Error deleting document:", error?.data);
logger.log(`esig-delete-error`, "ERROR", "esig", "api", {
message: error.message, stack: error.stack,
body: req.body
});
res.status(500).json({ error: "An error occurred while deleting the document." });
}
}
async function newEsignDocument(req, res) {
try {
const client = req.userGraphQLClient;
const { bodyshop } = req.body
@@ -58,7 +75,7 @@ async function newEsignDocument(req, res) {
const createDocumentResponse = await documenso.documents.create({
payload: {
title: esigData?.title,
externalId: req.body.jobid,
externalId: `${req.body.jobid}|${req.user?.email}`, //Have to pass the uploaded by later on. Limited to 255 chars.
recipients: [
{
email: "patrick@imexsystems.ca",//jobData.ownr_ea,
@@ -264,7 +281,8 @@ const fetchContextData = async ({ templateObject, jsrAuth, req, }) => {
module.exports = {
newEsignDocument,
distributeDocument
distributeDocument,
deleteDocument
}