-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add esign schema * feat: add all esign procedure * feat: add draft only query feature * feat: add procedure * feat: esign audit sdk * feat: add audit * feat: add view option * feat: add template detail view * feat: add gap
- Loading branch information
Showing
13 changed files
with
302 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
-- CreateTable | ||
CREATE TABLE "EsignAudit" ( | ||
"id" TEXT NOT NULL, | ||
"companyId" TEXT NOT NULL, | ||
"templateId" TEXT NOT NULL, | ||
"recipientId" TEXT NOT NULL, | ||
"action" TEXT NOT NULL, | ||
"ip" TEXT NOT NULL, | ||
"userAgent" TEXT NOT NULL, | ||
"location" TEXT NOT NULL, | ||
"summary" TEXT NOT NULL, | ||
"occurredAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "EsignAudit_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "EsignAudit_companyId_idx" ON "EsignAudit"("companyId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "EsignAudit_templateId_idx" ON "EsignAudit"("templateId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "EsignAudit_recipientId_idx" ON "EsignAudit"("recipientId"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/app/(authenticated)/(dashboard)/[publicId]/documents/esign/v/[templatePublicId]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { PdfCanvas } from "@/components/template/pdf-canvas"; | ||
import { Alert, AlertDescription } from "@/components/ui/alert"; | ||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; | ||
import { TemplateSigningFieldProvider } from "@/providers/template-signing-field-provider"; | ||
import { api } from "@/trpc/server"; | ||
import { RiCheckFill } from "@remixicon/react"; | ||
|
||
export default async function TemplateDetailViewPage({ | ||
params: { templatePublicId }, | ||
}: { | ||
params: { templatePublicId: string }; | ||
}) { | ||
const [{ url, fields }, { audits }] = await Promise.all([ | ||
api.template.get.query({ | ||
publicId: templatePublicId, | ||
isDraftOnly: false, | ||
}), | ||
api.audit.allEsignAudits.query({ | ||
templatePublicId: templatePublicId, | ||
}), | ||
]); | ||
|
||
return ( | ||
<TemplateSigningFieldProvider fields={fields}> | ||
<div className="flex min-h-screen bg-gray-50"> | ||
<div className="flex h-full flex-grow flex-col"> | ||
<div className="mx-auto min-h-full w-full px-5 py-10 lg:px-8 2xl:max-w-screen-xl"> | ||
<div className="grid grid-cols-12"> | ||
<PdfCanvas mode="readonly" url={url} /> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="sticky top-0 flex min-h-full w-80 flex-col lg:border-l"> | ||
<Card className="border-none bg-transparent shadow-none"> | ||
<CardHeader> | ||
<CardTitle>eSigning activity logs</CardTitle> | ||
</CardHeader> | ||
<CardContent> | ||
{audits.length ? ( | ||
<div className="flex flex-col gap-y-3"> | ||
{audits.map((item) => ( | ||
<div className="flex items-start gap-x-2" key={item.id}> | ||
<div> | ||
<div className="rounded-full bg-green-700 "> | ||
<RiCheckFill className="h-5 w-5 text-white" /> | ||
</div> | ||
</div> | ||
<p className="break-words text-sm font-medium text-primary/80"> | ||
{item.summary} | ||
</p> | ||
</div> | ||
))} | ||
</div> | ||
) : ( | ||
<Alert> | ||
<AlertDescription>No logs to show</AlertDescription> | ||
</Alert> | ||
)} | ||
</CardContent> | ||
</Card> | ||
</div> | ||
</div> | ||
</TemplateSigningFieldProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/trpc/routers/audit-router/procedures/all-esign-audits.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { checkMembership } from "@/server/auth"; | ||
import { withAuth } from "@/trpc/api/trpc"; | ||
import { ZodAllEsignAuditsQuerySchema } from "../schema"; | ||
|
||
export const allEsignAuditsProcedure = withAuth | ||
.input(ZodAllEsignAuditsQuerySchema) | ||
.query(async ({ ctx, input }) => { | ||
const { db, session } = ctx; | ||
const { templatePublicId } = input; | ||
|
||
const { audits } = await db.$transaction(async (tx) => { | ||
const { companyId } = await checkMembership({ session, tx }); | ||
|
||
const { id: templateId } = await tx.template.findFirstOrThrow({ | ||
where: { | ||
publicId: templatePublicId, | ||
}, | ||
select: { | ||
id: true, | ||
}, | ||
}); | ||
|
||
const audits = await tx.esignAudit.findMany({ | ||
where: { | ||
companyId, | ||
templateId, | ||
}, | ||
}); | ||
|
||
return { audits }; | ||
}); | ||
|
||
return { audits }; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.