The Open Source DocuSign Alternative.
TypeScript digital-signaturedocument-signingdocusign-alternativee-signatureesignesignaturenext-authnextjsopen-sourcepades-standardpdfpdf-signpdf-signaturepostgresqlprismaself-hostedsigningtypescript
upload file POC
Timur Ercanc7b1abe8f782
diff --git a/apps/web/pages/dashboard.tsx b/apps/web/pages/dashboard.tsxindex d1f1529d0..fb0b95848 100644--- a/apps/web/pages/dashboard.tsx+++ b/apps/web/pages/dashboard.tsx@@ -1,6 +1,6 @@import { useSession } from "next-auth/react";import Head from "next/head";-import type { ReactElement } from "react";+import { ReactElement, useEffect, useState } from "react";import Layout from "../components/layout";import Settings from "../components/settings";import Link from "next/link";@@ -13,9 +13,15 @@ import {SunIcon,XCircleIcon,} from "@heroicons/react/24/outline";+import { FormProvider, useForm } from "react-hook-form";+import Router from "next/router";+import { NEXT_PUBLIC_WEBAPP_URL } from "@documenso/lib";++type FormValues = {+ document: File;+};const DashboardPage: NextPageWithLayout = () => {- const status = useSession();const stats = [{name: "Draft",@@ -54,6 +60,24 @@ const DashboardPage: NextPageWithLayout = () => {link: "/documents?filter=",},];+ const uploadToServer = async (event: any) => {+ if (event.target.files && event.target.files[0]) {+ const body = new FormData();+ const document = event.target.files[0];+ body.append("document", document || "");+ const response: any = await fetch("/api/documents", {+ method: "POST",+ body,+ }).then((response: any) => {+ Router.push(+ `${NEXT_PUBLIC_WEBAPP_URL}/documents/${+ response.json().creadtedDocumentId+ }`+ );+ });+ }+ };+return (<><Head>@@ -108,7 +132,14 @@ const DashboardPage: NextPageWithLayout = () => {Upload a new PDF document</span></button>- <input id="fileUploadHelper" type="file" hidden />+ <input+ id="fileUploadHelper"+ type="file"+ onChange={(event: any) => {+ uploadToServer(event);+ }}+ hidden+ /></div></div></>