diff --git a/apps/web/components/pdf-viewer.js b/apps/web/components/pdf-viewer.js index cbcaadc05..2b86c368b 100644 --- a/apps/web/components/pdf-viewer.js +++ b/apps/web/components/pdf-viewer.js @@ -2,8 +2,9 @@ import { useState } from "react"; import { Document, Page } from "react-pdf/dist/esm/entry.webpack5"; export default function PDFViewer(props) { - const [file, setFile] = useState("./sample.pdf"); + const [file, setFile] = useState(""); const [numPages, setNumPages] = useState(null); + const [loading, setLoading] = useState(true); function onFileChange(event) { setFile(event.target.files[0]); @@ -21,7 +22,7 @@ export default function PDFViewer(props) { return ( <> -
+ + ); } diff --git a/apps/web/pages/documents.tsx b/apps/web/pages/documents.tsx index 20c2c6ee9..f1c892cc4 100644 --- a/apps/web/pages/documents.tsx +++ b/apps/web/pages/documents.tsx @@ -13,13 +13,15 @@ import toast from "react-hot-toast"; const DocumentsPage: NextPageWithLayout = (req, res) => { const router = useRouter(); - const [documents, setDocuments] = useState([]); + const [documents = [], setDocuments] = useState([]); + const [loading, setLoading] = useState(true); useEffect(() => { getDocuments(); - }); + }, []); const getDocuments = async () => { + setLoading(true); fetch("/api/documents", { headers: { "Content-Type": "application/json", @@ -27,6 +29,7 @@ const DocumentsPage: NextPageWithLayout = (req, res) => { }).then((res) => { res.json().then((j) => { setDocuments(j); + setLoading(false); }); }); }; @@ -67,7 +70,27 @@ const DocumentsPage: NextPageWithLayout = (req, res) => { Documents | Documenso -