diff --git a/src/components/document-details.tsx b/src/components/document-details.tsx
index 99e7f08..35b8234 100644
--- a/src/components/document-details.tsx
+++ b/src/components/document-details.tsx
@@ -15,7 +15,7 @@ import {
import { toast } from "sonner";
import { getUserData } from "@/app/actions";
import { Button, buttonVariants } from "@/components/ui/button";
-import { useRouter } from "next/navigation";
+import { useRouter, useSearchParams } from "next/navigation";
import {
useQuery,
QueryClientProvider,
@@ -27,6 +27,7 @@ import OpenExternalLink from "./external-link";
import type { PaperlessDocumentType } from "@/types";
import React from "react";
import BodyMessage from "@/components/body-message";
+import Link from "next/link";
const queryClient = new QueryClient();
@@ -111,6 +112,8 @@ async function getPaperlessDocumentData(id: number, userData: UsersTableType) {
function DocumentDetailsInner(props: { id: number }) {
const router = useRouter();
+ const searchParams = useSearchParams();
+ const query = searchParams.get("query");
const { data: userData, isLoading: isUserDataLoading } = useQuery({
queryKey: ["userData"],
@@ -155,18 +158,16 @@ function DocumentDetailsInner(props: { id: number }) {
-
+
{/*
Download
@@ -198,7 +199,7 @@ function DocumentDetailsInner(props: { id: number }) {
const response = await deleteDocument(props.id);
if (response.ok) {
toast("Pdf deleted", {
- description: "The recording has been deleted.",
+ description: "The pdf has been deleted.",
});
} else {
toast("Error deleting pdf", {
@@ -206,7 +207,7 @@ function DocumentDetailsInner(props: { id: number }) {
"An error occurred while deleting the pdf.",
});
}
- router.back();
+ router.push(`/paperless?query=${query}`);
}}
>
Continue
diff --git a/src/components/document-preview.tsx b/src/components/document-preview.tsx
index b5d70a2..1d5d2e6 100644
--- a/src/components/document-preview.tsx
+++ b/src/components/document-preview.tsx
@@ -6,10 +6,11 @@ import {
QueryClient,
} from "@tanstack/react-query";
import type { AdviceAPIType } from "@/types";
-import OpenInternalLink from "./internal-link";
import type { UsersTableType } from "@/server/db/schema";
-import BodyMessage from "./body-message";
-import { buttonVariants } from "./ui/button";
+import { Button, buttonVariants } from "@/components/ui/button";
+import { ChevronLeft } from "lucide-react";
+import { useRouter } from "next/navigation";
+import { useSearchParams } from "next/navigation";
const queryClient = new QueryClient();
@@ -98,24 +99,29 @@ function Preview(props: { id: number }) {
if (isPdfUrlLoading ?? isUserDataLoading) {
return ;
}
-
- if (!pdfUrl || !userData) {
- return Failed to get document;
- }
- return ;
+ return ;
}
export default function DocumentPreview(props: { id: number }) {
+ const router = useRouter();
+ const searchParams = useSearchParams();
+ const query = searchParams.get("query");
+
return (
-
- Open full page
-
+
);
}