mirror of
https://github.com/documenso/documenso.git
synced 2025-11-16 17:51:49 +10:00
🐛 dashbaord stats
This commit is contained in:
@ -13,10 +13,12 @@ import { uploadDocument } from "@documenso/features";
|
|||||||
import {
|
import {
|
||||||
DocumentStatus,
|
DocumentStatus,
|
||||||
SendStatus,
|
SendStatus,
|
||||||
|
SigningStatus,
|
||||||
Document as PrismaDocument,
|
Document as PrismaDocument,
|
||||||
} from "@prisma/client";
|
} from "@prisma/client";
|
||||||
import { getUserFromToken } from "@documenso/lib/server";
|
import { getUserFromToken } from "@documenso/lib/server";
|
||||||
import { getDocumentsForUserFromToken } from "@documenso/lib/query";
|
import { getDocumentsForUserFromToken } from "@documenso/lib/query";
|
||||||
|
import { truncate } from "fs";
|
||||||
|
|
||||||
type FormValues = {
|
type FormValues = {
|
||||||
document: File;
|
document: File;
|
||||||
@ -49,6 +51,7 @@ const DashboardPage: NextPageWithLayout = (props: any) => {
|
|||||||
<Head>
|
<Head>
|
||||||
<title>Dashboard | Documenso</title>
|
<title>Dashboard | Documenso</title>
|
||||||
</Head>
|
</Head>
|
||||||
|
|
||||||
<div className="py-10 max-sm:px-4">
|
<div className="py-10 max-sm:px-4">
|
||||||
<header>
|
<header>
|
||||||
<h1 className="text-3xl font-bold leading-tight tracking-tight text-gray-900">
|
<h1 className="text-3xl font-bold leading-tight tracking-tight text-gray-900">
|
||||||
@ -119,7 +122,6 @@ DashboardPage.getLayout = function getLayout(page: ReactElement) {
|
|||||||
|
|
||||||
function getStat(name: string, props: any) {
|
function getStat(name: string, props: any) {
|
||||||
if (name === "Draft") return props.dashboard.drafts;
|
if (name === "Draft") return props.dashboard.drafts;
|
||||||
if (name === "Action required") return props.dashboard.action;
|
|
||||||
if (name === "Waiting for others") return props.dashboard.waiting;
|
if (name === "Waiting for others") return props.dashboard.waiting;
|
||||||
if (name === "Completed") return props.dashboard.completed;
|
if (name === "Completed") return props.dashboard.completed;
|
||||||
return 0;
|
return 0;
|
||||||
@ -138,11 +140,11 @@ export async function getServerSideProps(context: any) {
|
|||||||
(d) => d.status === DocumentStatus.DRAFT
|
(d) => d.status === DocumentStatus.DRAFT
|
||||||
);
|
);
|
||||||
|
|
||||||
// Todo count declined, expired etc.
|
const waiting: any[] = documents.filter(
|
||||||
const action: PrismaDocument[] = [];
|
(e) =>
|
||||||
|
e.Recipient.length > 0 &&
|
||||||
const waiting: any[] = documents.filter((e) =>
|
e.Recipient.some((r: any) => r.sendStatus === SendStatus.SENT) &&
|
||||||
e.Recipient.some((e: any) => e.sendStatus === SendStatus.SENT)
|
e.Recipient.some((r: any) => r.signingStatus === SigningStatus.NOT_SIGNED)
|
||||||
);
|
);
|
||||||
|
|
||||||
const completed: PrismaDocument[] = documents.filter(
|
const completed: PrismaDocument[] = documents.filter(
|
||||||
@ -153,8 +155,8 @@ export async function getServerSideProps(context: any) {
|
|||||||
props: {
|
props: {
|
||||||
dashboard: {
|
dashboard: {
|
||||||
drafts: drafts.length,
|
drafts: drafts.length,
|
||||||
action: action.length,
|
|
||||||
waiting: waiting.length,
|
waiting: waiting.length,
|
||||||
|
docs: waiting,
|
||||||
completed: completed.length,
|
completed: completed.length,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user