Files
sign/apps/web/pages/documents/[id]/recipients.tsx

124 lines
3.9 KiB
TypeScript
Raw Normal View History

2023-01-31 15:42:04 +01:00
import Head from "next/head";
import { ReactElement } from "react";
import Layout from "../../../components/layout";
import { NextPageWithLayout } from "../../_app";
2023-02-01 18:32:59 +01:00
import { NEXT_PUBLIC_WEBAPP_URL } from "@documenso/lib";
import { PaperAirplaneIcon, UserCircleIcon } from "@heroicons/react/24/outline";
2023-01-31 16:16:22 +01:00
import { ChevronLeftIcon, ChevronRightIcon } from "@heroicons/react/20/solid";
import { getUserFromToken } from "@documenso/lib/server";
2023-01-31 17:14:23 +01:00
import { useRouter } from "next/router";
import { toast } from "react-hot-toast";
2023-02-01 18:32:59 +01:00
import { getDocument } from "@documenso/lib/query";
import { Document as PrismaDocument } from "@prisma/client";
2023-02-03 13:06:26 +01:00
import { Breadcrumb, Button } from "@documenso/ui";
2023-01-31 15:42:04 +01:00
2023-01-31 16:16:22 +01:00
const RecipientsPage: NextPageWithLayout = (props: any) => {
2023-01-31 17:14:23 +01:00
const router = useRouter();
2023-01-31 16:16:22 +01:00
const title: string =
`"` + props?.document?.title + `"` + "Recipients | Documenso";
2023-01-31 15:42:04 +01:00
return (
<>
<Head>
2023-01-31 16:16:22 +01:00
<title>{title}</title>
2023-01-31 15:42:04 +01:00
</Head>
2023-01-31 16:16:22 +01:00
<div className="mt-10">
<div>
2023-02-03 13:06:26 +01:00
<Breadcrumb
document={props.document}
items={[
{
title: "Documents",
href: "/documents",
},
{
title: props.document.title,
href:
NEXT_PUBLIC_WEBAPP_URL + "/documents/" + props.document.id,
},
{
title: "Recipients",
href:
NEXT_PUBLIC_WEBAPP_URL +
"/documents/" +
props.document.id +
"/recipients",
},
]}
/>
2023-01-31 16:16:22 +01:00
</div>
<div className="mt-2 md:flex md:items-center md:justify-between">
<div className="min-w-0 flex-1">
<h2 className="text-2xl font-bold leading-7 text-gray-900 sm:truncate sm:text-3xl sm:tracking-tight">
{props.document.title}
</h2>
</div>
<div className="mt-4 flex flex-shrink-0 md:mt-0 md:ml-4">
2023-02-02 13:44:35 +01:00
<Button
color="primary"
icon={PaperAirplaneIcon}
2023-01-31 17:14:23 +01:00
onClick={() => {
2023-02-02 13:44:35 +01:00
alert();
// todo do stuff
2023-01-31 17:14:23 +01:00
}}
2023-02-02 13:44:35 +01:00
disabled={(props?.document?.Recipient?.length || 0) === 0}
2023-01-31 16:16:22 +01:00
>
Send
2023-02-02 13:44:35 +01:00
</Button>
2023-01-31 16:16:22 +01:00
</div>
</div>
2023-01-31 16:52:40 +01:00
<div className="overflow-hidden rounded-md bg-white shadow mt-10 p-6">
<div className="border-b border-gray-200 pb-5">
<h3 className="text-lg font-medium leading-6 text-gray-900">
Signers
</h3>
<p className="mt-2 max-w-4xl text-sm text-gray-500">
The people who will sign the document.
</p>
</div>
2023-01-31 16:42:22 +01:00
<ul role="list" className="divide-y divide-gray-200">
{props?.document?.Recipient.map((item: any) => (
2023-01-31 16:52:40 +01:00
<li key={item.id} className="px-0 py-4">
2023-01-31 16:42:22 +01:00
<div>
<UserCircleIcon className="inline w-6 mr-2"></UserCircleIcon>
{item.email}
2023-01-31 16:52:40 +01:00
<span> (You)</span>
2023-01-31 16:42:22 +01:00
</div>
</li>
))}
</ul>
2023-01-31 16:52:40 +01:00
<div className="border-b border-gray-200 pb-5 mt-6">
<h3 className="text-lg font-medium leading-6 text-gray-900">CC</h3>
<p className="mt-2 max-w-4xl text-sm text-gray-500">
Anybody who should get a copy.
</p>
</div>
2023-01-31 16:42:22 +01:00
</div>
2023-01-31 16:16:22 +01:00
</div>
2023-01-31 15:42:04 +01:00
</>
);
};
RecipientsPage.getLayout = function getLayout(page: ReactElement) {
return <Layout>{page}</Layout>;
};
export async function getServerSideProps(context: any) {
2023-01-31 16:16:22 +01:00
const user = await getUserFromToken(context.req, context.res);
if (!user) return;
const { id: documentId } = context.query;
2023-02-01 19:15:43 +01:00
const document: PrismaDocument = await getDocument(
+documentId,
context.req,
context.res
);
2023-01-31 16:16:22 +01:00
2023-01-31 15:42:04 +01:00
return {
2023-01-31 16:16:22 +01:00
props: {
document: document,
},
2023-01-31 15:42:04 +01:00
};
}
export default RecipientsPage;