From 9ecff2f5c30ea0157a80bb62c10b798b3133d191 Mon Sep 17 00:00:00 2001 From: Aamir Azad Date: Wed, 26 Jun 2024 09:48:23 +0530 Subject: [PATCH] It works! Doesn't look good and is slow, but it works! --- bun.lockb | Bin 258652 -> 258652 bytes next.config.js | 17 ------ package.json | 2 +- .../(.)paperless/document/[id]/page.tsx | 9 +-- src/app/actions.ts | 1 + src/app/document-testing/page.tsx | 40 ------------- src/app/document-testing/something.tsx | 53 ------------------ src/app/paperless/document/[id]/page.tsx | 7 +-- src/components/document-viewer.tsx | 2 +- 9 files changed, 8 insertions(+), 123 deletions(-) delete mode 100644 src/app/document-testing/page.tsx delete mode 100644 src/app/document-testing/something.tsx diff --git a/bun.lockb b/bun.lockb index 1b7c16fe92388ea5c442c3a1bfdd9380fc087194..5271a3ce9693c53d8564fbe9469ecd6ec81254e6 100755 GIT binary patch delta 32 ocmccfg#XSH{)QIDEle+`b1=pk>lqs98MJ?#&b0mGbmr_R0P6n@djJ3c delta 32 kcmccfg#XSH{)QIDEle+`b1*SLK>Nq(Oxr(BXU>iS0M&sD`~Uy| diff --git a/next.config.js b/next.config.js index 5bbc884..07d270c 100644 --- a/next.config.js +++ b/next.config.js @@ -19,23 +19,6 @@ const config = { }, ], }, - webpack: (config, { isServer }) => { - if (!isServer) { - config.resolve.fallback.fs = false; - } - - return config; - }, - experimental: { - turbo: { - rules: { - "*.svg": { - loaders: ["@svgr/webpack"], - as: "*.js", - }, - }, - }, - }, }; export default config; diff --git a/package.json b/package.json index bdbb14d..755fdd1 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "db:migrate": "drizzle-kit migrate", "db:push": "drizzle-kit push", "db:studio": "drizzle-kit studio", - "dev": "next dev --turbo", + "dev": "next dev", "lint": "next lint", "start": "next start" }, diff --git a/src/app/@modal/(.)paperless/document/[id]/page.tsx b/src/app/@modal/(.)paperless/document/[id]/page.tsx index 6d8d8af..b8fc2d7 100644 --- a/src/app/@modal/(.)paperless/document/[id]/page.tsx +++ b/src/app/@modal/(.)paperless/document/[id]/page.tsx @@ -1,10 +1,5 @@ -import { Modal } from "./modal"; import DocumentViewer from "@/components/document-viewer"; -export default function DocumentModal(props: { id: number }) { - return ( - - - - ); +export default function FullPageDocumentPage({ params }: { params: { id: number } }) { + return ; } diff --git a/src/app/actions.ts b/src/app/actions.ts index 09e288f..a4f3dd1 100644 --- a/src/app/actions.ts +++ b/src/app/actions.ts @@ -89,4 +89,5 @@ export async function getPaperlessDocument(id: number) { } } catch (error) { console.error("Error fetching PDF:", error); + } } diff --git a/src/app/document-testing/page.tsx b/src/app/document-testing/page.tsx deleted file mode 100644 index e34e854..0000000 --- a/src/app/document-testing/page.tsx +++ /dev/null @@ -1,40 +0,0 @@ -"use client"; -import { useState } from 'react'; -import { Document, Page, pdfjs } from 'react-pdf'; -import { getServerSideProps } from './something'; - -// Configure PDF.js worker -pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.min.js`; - -interface PDFViewerProps { - pdfUrl: string; // URL to the PDF document -} - -const PDFViewer: React.FC = ({ pdfUrl }) => { - const [numPages, setNumPages] = useState(null); - - const onDocumentLoadSuccess = ({ numPages }: { numPages: number }) => { - setNumPages(numPages); - }; - - return ( -
- - {Array.from( - new Array(numPages || 0), - (el, index) => ( - - ), - )} - -
- ); -}; - -export default PDFViewer; diff --git a/src/app/document-testing/something.tsx b/src/app/document-testing/something.tsx deleted file mode 100644 index 1478fb8..0000000 --- a/src/app/document-testing/something.tsx +++ /dev/null @@ -1,53 +0,0 @@ -// pages/pdf-viewer.tsx - -import { useState } from 'react'; -import { Document, Page, pdfjs } from 'react-pdf'; -import { GetServerSideProps } from 'next'; - -// Configure PDF.js worker -pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.min.js`; - -interface PDFViewerProps { - pdfUrl: string; // URL to the PDF document -} - -const PDFViewer: React.FC = ({ pdfUrl }) => { - const [numPages, setNumPages] = useState(null); - - const onDocumentLoadSuccess = ({ numPages }: { numPages: number }) => { - setNumPages(numPages); - }; - - return ( -
- - {Array.from( - new Array(numPages || 0), - (el, index) => ( - - ), - )} - -
- ); -}; - -export const getServerSideProps: GetServerSideProps = async () => { - // Fetch PDF URL from your API or any other source - const res = await fetch('URL_TO_YOUR_PDF_API_ENDPOINT'); - const { pdfUrl } = await res.json(); - - return { - props: { - pdfUrl - } - }; -}; - -export default PDFViewer; diff --git a/src/app/paperless/document/[id]/page.tsx b/src/app/paperless/document/[id]/page.tsx index be788e3..7248b50 100644 --- a/src/app/paperless/document/[id]/page.tsx +++ b/src/app/paperless/document/[id]/page.tsx @@ -1,7 +1,6 @@ import DocumentViewer from "@/components/document-viewer"; -export default function FullPageDocumentPage(props: { id: number }) { - return ( - - ); +export default function FullPageDocumentPage({ params }: { params: { id: number } }) { + console.log("FULLL PAPGJPIGHEGPIUSHEGPIUWEGHPIWUEGH: " + params.id); + return ; } diff --git a/src/components/document-viewer.tsx b/src/components/document-viewer.tsx index 8adf363..8f734f5 100644 --- a/src/components/document-viewer.tsx +++ b/src/components/document-viewer.tsx @@ -7,6 +7,7 @@ import LoadingSpinner from "@/components/loading-spinner"; export default function DocumentViewer(props: { id: number }) { const [pdfUrl, setPdfUrl] = useState(null); const [loading, setLoading] = useState(true); + console.log("docuement viewer: " + props.id) useEffect(() => { const fetchData = async () => { @@ -21,7 +22,6 @@ export default function DocumentViewer(props: { id: number }) { try { const response = await fetch(url, { headers: { - "Content-Type": "application/pdf", Authorization: `Token ${userData.paperlessToken}`, }, });