read status

This commit is contained in:
Timur Ercan
2023-01-27 18:31:40 +01:00
parent 59f5297dd7
commit 48a8fce724
2 changed files with 21 additions and 1 deletions

View File

@ -1,8 +1,11 @@
import prisma from "@documenso/prisma";
import Head from "next/head";
import { ReactElement } from "react";
import Layout from "../../../components/layout";
import Logo from "../../../components/logo";
import { NextPageWithLayout } from "../../_app";
import { Router } from "next/router";
import { ReadStatus } from "@prisma/client";
const SignPage: NextPageWithLayout = () => {
return (
@ -19,4 +22,21 @@ SignPage.getLayout = function getLayout(page: ReactElement) {
return <Layout>{page}</Layout>;
};
export async function getServerSideProps(context: any) {
const recipientToken: string = context.query["token"];
await prisma.recipient.updateMany({
where: {
token: recipientToken,
},
data: {
readStatus: ReadStatus.OPENED,
},
});
return {
props: {},
};
}
export default SignPage;

View File

@ -6,6 +6,6 @@ export const sendSignedMail = async (document: any, recipient: any) => {
await sendMail(
document.user.email,
`${recipient.email} signed ${document.title}`,
`Hi ${document.user.name}, ${recipient.email} has signed your document ${document.title}. Click <a href="${NEXT_PUBLIC_WEBAPP_URL}/document/${document.id}"> VIEW DOCUMENT</a> to view it now.`
`Hi ${document.user.name}, ${recipient.email} has signed your document ${document.title}. Click <a href="${NEXT_PUBLIC_WEBAPP_URL}/document/${document.id}?token=${recipient.token}"> VIEW DOCUMENT</a> to view it now.`
);
};