Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add basic document preview and update document schema #120

Merged
merged 40 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
76cfc3e
feat: add react pdf
G3root Feb 14, 2024
fc26180
fix: upload provider enum
G3root Feb 14, 2024
69d8ae7
feat: add pdf viewer component
G3root Feb 14, 2024
2df2206
feat: add company url
G3root Feb 14, 2024
b9a1db0
feat: add get document procedure
G3root Feb 14, 2024
6a25f3f
feat: add get all documents procedure
G3root Feb 14, 2024
7b28d84
feat: add create document procedure
G3root Feb 14, 2024
f6c4629
fix: schema
G3root Feb 14, 2024
74effea
feat; add all procedures
G3root Feb 14, 2024
dba8627
fix: remove explicit type casting
G3root Feb 14, 2024
e658767
feat: update document schema
G3root Feb 14, 2024
ee5cad6
feat: make uploader component more generic
G3root Feb 14, 2024
d32704f
feat: use trpc and trpc types
G3root Feb 14, 2024
20c4790
feat: use company id
G3root Feb 14, 2024
6c2746c
feat: add page layout component
G3root Feb 14, 2024
72f8f3c
feat: add equity document upload page
G3root Feb 14, 2024
bfa47be
feat: add document detail page
G3root Feb 14, 2024
167c906
featL add pdf worker
G3root Feb 14, 2024
fff1056
feat: rename props
G3root Feb 14, 2024
05e2659
feat: add templates page
G3root Feb 15, 2024
2280cc8
feat : add bucket model
G3root Feb 15, 2024
6d86f64
feat: add relation for bucket
G3root Feb 15, 2024
a19a493
feat: refactor document fields
G3root Feb 15, 2024
e82e3d5
feat: update schema
G3root Feb 15, 2024
d21946d
feat: add status for template
G3root Feb 15, 2024
e9ffede
feat: add bucket router
G3root Feb 15, 2024
326b31f
feat: add create template procedure
G3root Feb 15, 2024
e07866b
fix: relation
G3root Feb 15, 2024
ce1a53d
feat: migration
G3root Feb 15, 2024
bc69831
feat: add get template procedure
G3root Feb 15, 2024
25b5510
feat: update document schema
G3root Feb 15, 2024
8202c9f
feat: use bucket procedure for uploader
G3root Feb 15, 2024
f58e059
feat: use relavant procedures
G3root Feb 15, 2024
2e2f265
feat: use template for query
G3root Feb 15, 2024
ac6dfbb
feat: use data
G3root Feb 15, 2024
c465b68
Merge branch 'main' into document-upload-new
G3root Feb 15, 2024
00bd19f
fix: provider enum
G3root Feb 15, 2024
cf06220
feat: add order by
G3root Feb 15, 2024
bf3ab35
feat: add new fields
G3root Feb 15, 2024
cb173e0
fix: eslint and build error and some minor changes
dahal Feb 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
* for Docker builds.
Expand All @@ -9,6 +11,15 @@ const config = {
images: {
domains: ["randomuser.me"],
},
webpack: (config) => {
/**
* Critical: prevents " ⨯ ./node_modules/canvas/build/Release/canvas.node
* Module parse failed: Unexpected character '�' (1:0)" error
*/
config.resolve.alias.canvas = false;

return config;
},

async redirects() {
return [
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"start": "next start",
"format": "prettier --write \"**/*.{css,js,json,jsx,ts,tsx}\" && npx prisma format",
"email:preview": "email preview ./src/emails",
"smpt:dev": "mailpit"
"smpt:dev": "mailpit",
"copy:pdfjs": "node scripts/copy-pdfjs-worker.cjs"
},
"dependencies": {
"@ant-design/plots": "^2.1.12",
Expand Down Expand Up @@ -50,6 +51,7 @@
"@trpc/next": "^10.43.6",
"@trpc/react-query": "^10.43.6",
"@trpc/server": "^10.43.6",
"@wojtekmaj/react-hooks": "^1.18.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"cmdk": "^0.2.0",
Expand All @@ -67,6 +69,7 @@
"react-dom": "18.2.0",
"react-dropzone": "^14.2.3",
"react-hook-form": "^7.49.3",
"react-pdf": "^7.7.0",
"server-only": "^0.0.1",
"sharp": "^0.33.2",
"superjson": "^2.2.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
Warnings:

- You are about to drop the column `uploadedById` on the `Document` table. All the data in the column will be lost.
- A unique constraint covering the columns `[publicId]` on the table `Document` will be added. If there are existing duplicate values, this will fail.
- Added the required column `mimeType` to the `Document` table without a default value. This is not possible if the table is not empty.
- Added the required column `publicId` to the `Document` table without a default value. This is not possible if the table is not empty.
- Added the required column `uploadProvider` to the `Document` table without a default value. This is not possible if the table is not empty.
- Added the required column `uploaderId` to the `Document` table without a default value. This is not possible if the table is not empty.
- Changed the type of `type` on the `Document` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.

*/
-- CreateEnum
CREATE TYPE "UploadProviders" AS ENUM ('S3', 'R2');

-- CreateEnum
CREATE TYPE "DocumentType" AS ENUM ('SAFE', 'EQUITY', 'GENERIC');

-- CreateEnum
CREATE TYPE "DocumentStatus" AS ENUM ('DRAFT', 'COMPLETED');

-- CreateEnum
CREATE TYPE "DocumentFieldTypes" AS ENUM ('TEXT', 'TEXT_AREA', 'RADIO', 'CHECK_BOX', 'SIGNATURE', 'DATE', 'DATE_TIME', 'EMAIL');

-- CreateEnum
CREATE TYPE "DocumentSigningStatus" AS ENUM ('NOT_SIGNED', 'SIGNED');

-- DropIndex
DROP INDEX "Document_uploadedById_idx";

-- AlterTable
ALTER TABLE "Document" DROP COLUMN "uploadedById",
ADD COLUMN "mimeType" TEXT NOT NULL,
ADD COLUMN "publicId" TEXT NOT NULL,
ADD COLUMN "status" "DocumentStatus" NOT NULL DEFAULT 'DRAFT',
ADD COLUMN "uploadProvider" "UploadProviders" NOT NULL,
ADD COLUMN "uploaderId" TEXT NOT NULL,
DROP COLUMN "type",
ADD COLUMN "type" "DocumentType" NOT NULL;

-- CreateTable
CREATE TABLE "DocumentFields" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"type" "DocumentFieldTypes" NOT NULL DEFAULT 'TEXT',
"placeholder" TEXT NOT NULL DEFAULT '',
"required" BOOLEAN NOT NULL DEFAULT false,
"documentId" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "DocumentFields_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "DocumentRecepients" (
"id" TEXT NOT NULL,
"signedStatus" "DocumentSigningStatus" NOT NULL,
"membershipId" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "DocumentRecepients_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "DocumentFields_documentId_idx" ON "DocumentFields"("documentId");

-- CreateIndex
CREATE INDEX "DocumentRecepients_membershipId_idx" ON "DocumentRecepients"("membershipId");

-- CreateIndex
CREATE INDEX "Document_uploaderId_idx" ON "Document"("uploaderId");

-- CreateIndex
CREATE UNIQUE INDEX "Document_publicId_key" ON "Document"("publicId");
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
Warnings:

- You are about to drop the column `key` on the `Document` table. All the data in the column will be lost.
- You are about to drop the column `mimeType` on the `Document` table. All the data in the column will be lost.
- You are about to drop the column `size` on the `Document` table. All the data in the column will be lost.
- You are about to drop the column `status` on the `Document` table. All the data in the column will be lost.
- You are about to drop the column `type` on the `Document` table. All the data in the column will be lost.
- You are about to drop the column `uploadProvider` on the `Document` table. All the data in the column will be lost.
- You are about to drop the `DocumentFields` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `DocumentRecepients` table. If the table is not empty, all the data it contains will be lost.
- Added the required column `bucketId` to the `Document` table without a default value. This is not possible if the table is not empty.

*/
-- CreateEnum
CREATE TYPE "FieldTypes" AS ENUM ('text', 'textArea', 'radio', 'checkBox', 'signature', 'date', 'dateTime', 'email');

-- CreateEnum
CREATE TYPE "TemplateStatus" AS ENUM ('draft', 'completed');

-- CreateEnum
CREATE TYPE "EsignRecipientStatus" AS ENUM ('notSigned', 'signed');

-- AlterTable
ALTER TABLE "Document" DROP COLUMN "key",
DROP COLUMN "mimeType",
DROP COLUMN "size",
DROP COLUMN "status",
DROP COLUMN "type",
DROP COLUMN "uploadProvider",
ADD COLUMN "bucketId" TEXT NOT NULL;

-- DropTable
DROP TABLE "DocumentFields";

-- DropTable
DROP TABLE "DocumentRecepients";

-- DropEnum
DROP TYPE "DocumentFieldTypes";

-- DropEnum
DROP TYPE "DocumentSigningStatus";

-- DropEnum
DROP TYPE "DocumentStatus";

-- DropEnum
DROP TYPE "DocumentType";

-- DropEnum
DROP TYPE "UploadProviders";

-- CreateTable
CREATE TABLE "Bucket" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"key" TEXT NOT NULL,
"mimeType" TEXT NOT NULL,
"size" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Bucket_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "TemplateField" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"type" "FieldTypes" NOT NULL DEFAULT 'text',
"placeholder" TEXT NOT NULL DEFAULT '',
"required" BOOLEAN NOT NULL DEFAULT false,
"positionX" DECIMAL(65,30) NOT NULL,
"positionY" DECIMAL(65,30) NOT NULL,
"width" DECIMAL(65,30) NOT NULL,
"height" DECIMAL(65,30) NOT NULL,
"templateId" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "TemplateField_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Template" (
"id" TEXT NOT NULL,
"publicId" TEXT NOT NULL,
"name" TEXT NOT NULL,
"status" "TemplateStatus" NOT NULL DEFAULT 'draft',
"bucketId" TEXT NOT NULL,
"uploaderId" TEXT NOT NULL,
"companyId" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Template_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "EsignRecipient" (
"id" TEXT NOT NULL,
"email" TEXT,
"status" "EsignRecipientStatus" NOT NULL,
"membershipId" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "EsignRecipient_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "TemplateField_templateId_idx" ON "TemplateField"("templateId");

-- CreateIndex
CREATE INDEX "Template_bucketId_idx" ON "Template"("bucketId");

-- CreateIndex
CREATE INDEX "Template_uploaderId_idx" ON "Template"("uploaderId");

-- CreateIndex
CREATE INDEX "Template_companyId_idx" ON "Template"("companyId");

-- CreateIndex
CREATE INDEX "EsignRecipient_membershipId_idx" ON "EsignRecipient"("membershipId");

-- CreateIndex
CREATE INDEX "Document_bucketId_idx" ON "Document"("bucketId");
Loading
Loading