Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

add more toasts

Marc Seitz4745ee3d1035
diff --git a/components/Notification.tsx b/components/Notification.tsx
index 8b66d8d4..39408cb3 100644
--- a/components/Notification.tsx
+++ b/components/Notification.tsx
@@ -6,9 +6,11 @@ import { Fragment } from "react";
export default function Notification({
t,
closeToast,
+ message = "Document uploaded and link copied to clipboard.",
}: {
t: any;
closeToast: () => void;
+ message?: string;
}) {
return (
<div className="flex w-full flex-col items-center space-y-4 sm:items-end">
@@ -36,9 +38,7 @@ export default function Notification({
<p className="text-sm font-medium text-gray-300">
Link copied to clipboard!
</p>
- <p className="mt-1 text-sm text-gray-500">
- Document uploaded and link copied to clipboard.
- </p>
+ <p className="mt-1 text-sm text-gray-500">{message}</p>
</div>
<div className="ml-4 flex flex-shrink-0">
<button
diff --git a/pages/documents.tsx b/pages/documents.tsx
index af2fa64e..7c21c738 100644
--- a/pages/documents.tsx
+++ b/pages/documents.tsx
@@ -90,7 +90,7 @@ export default function Documents({
);
toast.custom((t) => (
- <Notification t={t} closeToast={() => toast.dismiss(t.id)} />
+ <Notification t={t} closeToast={() => toast.dismiss(t.id)} message={``} />
));
};
@@ -126,12 +126,12 @@ export default function Documents({
<span className="whitespace-nowrap text-gray-500">
{getExtension(document.file)}
</span>
- {/* <span className="absolute inset-0" /> */}
+ <span className="absolute inset-0" />
</Link>
</h2>
<div className="flex ml-2">
<button
- className="text-gray-500 hover:text-gray-700"
+ className="text-gray-500 hover:text-gray-700 z-10"
onClick={() =>
handleCopyToClipboard(document.links[0].id)
}
diff --git a/pages/documents/[id].tsx b/pages/documents/[id].tsx
index 8fe84f43..0e3fe664 100644
--- a/pages/documents/[id].tsx
+++ b/pages/documents/[id].tsx
@@ -12,6 +12,8 @@ import { DocumentDuplicateIcon } from "@heroicons/react/24/outline";
import { parseISO, format, formatDistance } from "date-fns";
import { useState } from "react";
import Skeleton from "@/components/Skeleton";
+import toast from "react-hot-toast";
+import Notification from "@/components/Notification";
interface LinkWithView extends DocumentLink {
views: { viewedAt: string }[];
@@ -55,6 +57,16 @@ const DocumentPage = ({
{ name: "TBD", value: "98.5%", active: false },
];
+ const handleCopyToClipboard = (id: string) => {
+ navigator.clipboard.writeText(
+ `${process.env.NEXT_PUBLIC_BASE_URL}/view/${id}`
+ );
+
+ toast.custom((t) => (
+ <Notification t={t} closeToast={() => toast.dismiss(t.id)} message={``} />
+ ));
+ };
+
async function addNewLink() {
setIsLoading(true);
const response = await fetch("/api/links", {
@@ -207,11 +219,7 @@ const DocumentPage = ({
</div>
<button
className="text-gray-500 hover:text-gray-700"
- onClick={() =>
- navigator.clipboard.writeText(
- `${process.env.NEXT_PUBLIC_BASE_URL}/view/${link.id}`
- )
- }
+ onClick={() => handleCopyToClipboard(link.id)}
title="Copy to clipboard"
>
<DocumentDuplicateIcon