|
5 | 5 | */ |
6 | 6 |
|
7 | 7 | const path = require("path"); |
8 | | - const { embedClickwrap, getActiveClickwraps } = require("../examples/embedClickwrap"); |
| 8 | + const { embedClickwrap, getActiveClickwraps, getInactiveClickwraps } = require("../examples/embedClickwrap"); |
9 | 9 | const validator = require("validator"); |
10 | 10 | const { getExampleByNumber } = require("../../manifestService"); |
11 | 11 | const dsConfig = require("../../../config/index.js").config; |
|
53 | 53 | clickwrapId: req.body.clickwrapId, |
54 | 54 | documentArgs: documentArgs |
55 | 55 | }; |
56 | | - |
| 56 | + const example = getExampleByNumber(res.locals.manifest, exampleNumber); |
57 | 57 |
|
58 | 58 | // Call the worker method |
59 | 59 | try { |
60 | 60 | results = await embedClickwrap(args); |
61 | 61 | console.log(JSON.parse(JSON.stringify(results))); |
62 | 62 | } catch (error) { |
63 | | - const errorBody = error && error.response && error.response.body; |
64 | | - // We can pull the DocuSign error code and message from the response body |
65 | | - const errorCode = errorBody && errorBody.errorCode; |
66 | | - const errorMessage = errorBody && errorBody.message; |
67 | | - // In production, you may want to provide customized error messages and |
68 | | - // remediation advice to the user |
69 | | - res.render("pages/error", { err: error, errorCode, errorMessage }); |
70 | | - } |
| 63 | + if (embedClickwrap.agreementUrl == null) { |
| 64 | + const errorCode = error.message; |
| 65 | + const errorMessage = "The email address was already used to agree to this elastic template. Provide a different email address if you want to view the agreement and agree to it."; |
| 66 | + res.render("pages/error", {err: error, errorCode, errorMessage}); |
| 67 | + } else { |
| 68 | + const errorBody = error && error.response && error.response.body; |
| 69 | + // We can pull the DocuSign error code and message from the response body |
| 70 | + const errorCode = errorBody && errorBody.errorCode; |
| 71 | + const errorMessage = errorBody && errorBody.message; |
| 72 | + |
| 73 | + // In production, may want to provide customized error messages and |
| 74 | + // remediation advice to the user. |
| 75 | + res.render('pages/error', {err: error, errorCode, errorMessage}); |
| 76 | + } |
| 77 | + } |
71 | 78 | if (results) { |
72 | 79 | // Save for use by other examples that need an clickwrapId |
73 | 80 | const example = getExampleByNumber(res.locals.manifest, exampleNumber); |
|
109 | 116 | example: example, |
110 | 117 | sourceFile: sourceFile, |
111 | 118 | clickwrapsData: await getActiveClickwraps(args), |
| 119 | + clickwrapsExist: await getInactiveClickwraps(args), |
112 | 120 | sourceUrl: dsConfig.githubExampleUrl + 'click/examples/' + sourceFile, |
113 | 121 | documentation: dsConfig.documentation + eg, |
114 | 122 | showDoc: dsConfig.documentation |
|
0 commit comments