mirror of
https://github.com/documenso/documenso.git
synced 2025-11-16 17:51:49 +10:00
80 lines
2.5 KiB
TypeScript
80 lines
2.5 KiB
TypeScript
import { useSession } from "next-auth/react";
|
|
import { ReactElement, useEffect, useState } from "react";
|
|
import Layout from "../components/layout";
|
|
import type { NextPageWithLayout } from "./_app";
|
|
import Head from "next/head";
|
|
import { PlusIcon } from "@heroicons/react/24/outline";
|
|
import { Document as PrismaDocument } from "@prisma/client";
|
|
import { getUserFromToken } from "@documenso/lib/server";
|
|
import Link from "next/link";
|
|
|
|
const DocumentsPage: NextPageWithLayout = (req, res) => {
|
|
const [documents = [], setDocuments] = useState([]);
|
|
|
|
useEffect(() => {
|
|
getDocuments();
|
|
}, []);
|
|
|
|
const getDocuments = async () => {
|
|
fetch("/api/documents", {
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
}).then((res) => {
|
|
res.json().then((j) => {
|
|
setDocuments(j);
|
|
});
|
|
});
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<Head>
|
|
<title>Documents | Documenso</title>
|
|
</Head>
|
|
{documents.map((item: any) => (
|
|
<div>
|
|
<Link key={item.id} href={"/documents/" + item.id} target="_blank">
|
|
Document Nr.{item.id}
|
|
</Link>
|
|
</div>
|
|
))}
|
|
<div className="text-center mt-24" id="empty" hidden>
|
|
<svg
|
|
className="mx-auto h-12 w-12 text-gray-400"
|
|
fill="none"
|
|
viewBox="0 0 24 24"
|
|
stroke="currentColor"
|
|
aria-hidden="true"
|
|
>
|
|
<path
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
d="M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m3.75 9v6m3-3H9m1.5-12H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"
|
|
/>
|
|
</svg>
|
|
|
|
<h3 className="mt-2 text-sm font-medium text-gray-900">No documents</h3>
|
|
<p className="mt-1 text-sm text-gray-500">
|
|
Get started by creating a new document.
|
|
</p>
|
|
<div className="mt-6">
|
|
<button
|
|
type="button"
|
|
className="inline-flex items-center rounded-md border border-transparent bg-neon px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
|
|
>
|
|
<PlusIcon className="-ml-1 mr-2 h-5 w-5" aria-hidden="true" />
|
|
Upload Document
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</>
|
|
);
|
|
};
|
|
|
|
DocumentsPage.getLayout = function getLayout(page: ReactElement) {
|
|
return <Layout>{page}</Layout>;
|
|
};
|
|
|
|
export default DocumentsPage;
|