mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
send fix, send error handling
This commit is contained in:
@ -430,24 +430,32 @@ async function send(document: any) {
|
|||||||
// todo toast
|
// todo toast
|
||||||
// loading
|
// loading
|
||||||
if (!document || !document.id) return;
|
if (!document || !document.id) return;
|
||||||
return toast
|
try {
|
||||||
.promise(
|
const sent = await toast.promise(
|
||||||
fetch(`/api/documents/${document.id}/send`, {
|
fetch(`/api/documents/${document.id}/send`, {
|
||||||
body: "",
|
body: "",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
method: "POST",
|
method: "POST",
|
||||||
}),
|
})
|
||||||
|
.then((res: any) => {
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(res.status.toString());
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
location.reload();
|
||||||
|
}),
|
||||||
{
|
{
|
||||||
loading: "Sending...",
|
loading: "Sending...",
|
||||||
success: `Sent!`,
|
success: `Sent!`,
|
||||||
error: "Changes could not send :/",
|
error: "Could not send :/",
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
.finally(() => {
|
} catch (err) {
|
||||||
location.reload();
|
console.log(err);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RecipientsPage;
|
export default RecipientsPage;
|
||||||
|
|||||||
@ -2,7 +2,11 @@ import { sendMail } from "./sendMail";
|
|||||||
import { NEXT_PUBLIC_WEBAPP_URL } from "@documenso/lib/constants";
|
import { NEXT_PUBLIC_WEBAPP_URL } from "@documenso/lib/constants";
|
||||||
import { transactionEmailTemplate } from "@documenso/lib/mail";
|
import { transactionEmailTemplate } from "@documenso/lib/mail";
|
||||||
|
|
||||||
export const sendSignedMail = async (recipient: any, document: any) => {
|
export const sendSignedMail = async (
|
||||||
|
recipient: any,
|
||||||
|
document: any,
|
||||||
|
user: any
|
||||||
|
) => {
|
||||||
// todo check if recipient has an account
|
// todo check if recipient has an account
|
||||||
await sendMail(
|
await sendMail(
|
||||||
document.User.email,
|
document.User.email,
|
||||||
@ -14,7 +18,8 @@ export const sendSignedMail = async (recipient: any, document: any) => {
|
|||||||
document,
|
document,
|
||||||
recipient,
|
recipient,
|
||||||
`${NEXT_PUBLIC_WEBAPP_URL}/documents/${document.id}`,
|
`${NEXT_PUBLIC_WEBAPP_URL}/documents/${document.id}`,
|
||||||
`View Document`
|
`View Document`,
|
||||||
|
user
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -18,7 +18,8 @@ export const sendSigningRequest = async (
|
|||||||
document,
|
document,
|
||||||
recipient,
|
recipient,
|
||||||
`${NEXT_PUBLIC_WEBAPP_URL}/documents/${document.id}/sign?token=${recipient.token}`,
|
`${NEXT_PUBLIC_WEBAPP_URL}/documents/${document.id}/sign?token=${recipient.token}`,
|
||||||
`Sign Document`
|
`Sign Document`,
|
||||||
|
user
|
||||||
)
|
)
|
||||||
).catch((err) => {
|
).catch((err) => {
|
||||||
throw err;
|
throw err;
|
||||||
|
|||||||
@ -6,7 +6,8 @@ export const transactionEmailTemplate = (
|
|||||||
document: any,
|
document: any,
|
||||||
recipient: any,
|
recipient: any,
|
||||||
ctaLink: string,
|
ctaLink: string,
|
||||||
ctaLabel: string
|
ctaLabel: string,
|
||||||
|
user: any
|
||||||
) => {
|
) => {
|
||||||
const html = `
|
const html = `
|
||||||
<div style="background-color: #eaeaea; padding: 2%;">
|
<div style="background-color: #eaeaea; padding: 2%;">
|
||||||
@ -20,7 +21,7 @@ export const transactionEmailTemplate = (
|
|||||||
</p>
|
</p>
|
||||||
<hr size="1" style="height:1px;border:none;color:#e0e0e0;background-color:#e0e0e0">
|
<hr size="1" style="height:1px;border:none;color:#e0e0e0;background-color:#e0e0e0">
|
||||||
Click the button to view "${document.title}".<br>
|
Click the button to view "${document.title}".<br>
|
||||||
<small>If you have questions about this document, you should ask ${document.User.name}.</small>
|
<small>If you have questions about this document, you should ask ${user.name}.</small>
|
||||||
<hr size="1" style="height:1px;border:none;color:#e0e0e0;background-color:#e0e0e0">
|
<hr size="1" style="height:1px;border:none;color:#e0e0e0;background-color:#e0e0e0">
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user