mirror of
https://github.com/documenso/documenso.git
synced 2025-11-21 04:01:45 +10:00
render doc list
This commit is contained in:
@ -47,9 +47,12 @@ async function getHandler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
let user = await getUserFromToken(req, res);
|
let user = await getUserFromToken(req, res);
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
|
|
||||||
return res
|
return res.status(200).json(
|
||||||
.status(200)
|
await prisma.document.findMany({
|
||||||
.json(await prisma.document.findMany({ where: { userId: user?.id } }));
|
where: { userId: user?.id },
|
||||||
|
select: { id: true },
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defaultHandler({
|
export default defaultHandler({
|
||||||
|
|||||||
@ -1,17 +1,45 @@
|
|||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "next-auth/react";
|
||||||
import type { ReactElement } from "react";
|
import { ReactElement, useEffect, useState } from "react";
|
||||||
import Layout from "../components/layout";
|
import Layout from "../components/layout";
|
||||||
import type { NextPageWithLayout } from "./_app";
|
import type { NextPageWithLayout } from "./_app";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import { PlusIcon } from "@heroicons/react/24/outline";
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const DocumentsPage: NextPageWithLayout = () => {
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>Documents | Documenso</title>
|
<title>Documents | Documenso</title>
|
||||||
</Head>
|
</Head>
|
||||||
<div className="text-center mt-24" id="empty">
|
{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
|
<svg
|
||||||
className="mx-auto h-12 w-12 text-gray-400"
|
className="mx-auto h-12 w-12 text-gray-400"
|
||||||
fill="none"
|
fill="none"
|
||||||
|
|||||||
Reference in New Issue
Block a user