Skip to content

Commit 6e00a25

Browse files
Added qr and copy button
1 parent 37bdc0e commit 6e00a25

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

src/app/api/ai-upload/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export async function POST(req: Request) {
161161
});
162162
await paper.save();
163163
return NextResponse.json(
164-
{ status: "success", url: finalUrl, thumbnailUrl: thumbnailUrl },
164+
{ status: "success", },
165165
{ status: 201 },
166166
);
167167
} catch (error) {

src/components/pdfViewer.tsx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
import { Button } from "./ui/button";
3737
import { usePathname } from "next/navigation";
3838
import { useEffect, useState } from "react";
39+
import toast from "react-hot-toast";
3940

4041
interface Params {
4142
params: { id: string };
@@ -94,7 +95,7 @@ export default function PdfViewer({ url, name }: PdfViewerProps) {
9495
)}
9596
</ZoomIn>
9697
</div>
97-
<div className="flex gap-3">
98+
<div className="flex gap-5">
9899
<div className="hidden gap-x-4 md:flex md:items-center">
99100
<getFilePluginInstance.Download>
100101
{(props) => (
@@ -130,15 +131,24 @@ export default function PdfViewer({ url, name }: PdfViewerProps) {
130131
<div className="flex justify-center space-x-4">
131132
<QR url={paperPath}></QR>
132133
</div>
133-
<Button
134-
type="submit"
135-
size="sm"
136-
className="px-3"
137-
onClick={() => navigator.clipboard.writeText(paperPath)}
138-
>
139-
<span className="sr-only">Copy</span>
140-
<Copy />
141-
</Button>
134+
<Button
135+
type="submit"
136+
size="sm"
137+
className="px-3"
138+
onClick={async () => {
139+
await toast.promise(
140+
navigator.clipboard.writeText(paperPath), // This is a promise
141+
{
142+
success: "Link copied successfully",
143+
loading: "Copying link...",
144+
error: "Error copying link",
145+
},
146+
);
147+
}}
148+
>
149+
<span className="sr-only">Copy</span>
150+
<Copy />
151+
</Button>
142152
</DialogContent>
143153
</Dialog>
144154
</div>

0 commit comments

Comments
 (0)