Merge branch 'feat/handle-files' into dev

This commit is contained in:
Daniel
2023-12-02 21:58:23 +03:30
committed by GitHub
19 changed files with 179 additions and 29 deletions
+4 -3
View File
@@ -44,6 +44,7 @@ export default function AddOrEditLink({
activeLink || {
name: "",
url: "",
type: "",
description: "",
tags: [],
screenshotPath: "",
@@ -139,10 +140,10 @@ export default function AddOrEditLink({
{method === "UPDATE" ? (
<div
className="text-neutral break-all w-full flex gap-2"
title={link.url}
title={link.url || ""}
>
<FontAwesomeIcon icon={faLink} className="w-6 h-6" />
<Link href={link.url} target="_blank" className="w-full">
<Link href={link.url || ""} target="_blank" className="w-full">
{link.url}
</Link>
</div>
@@ -153,7 +154,7 @@ export default function AddOrEditLink({
<div className="sm:col-span-3 col-span-5">
<p className="mb-2">Address (URL)</p>
<TextInput
value={link.url}
value={link.url || ""}
onChange={(e) => setLink({ ...link, url: e.target.value })}
placeholder="e.g. http://example.com/"
className="bg-base-200"
+7 -4
View File
@@ -76,8 +76,7 @@ export default function PreservedFormats() {
// Create a temporary link and click it to trigger the download
const link = document.createElement("a");
link.href = path;
link.download =
format === ArchivedFormat.screenshot ? "Screenshot" : "PDF";
link.download = format === ArchivedFormat.png ? "Screenshot" : "PDF";
link.click();
} else {
console.error("Failed to download file");
@@ -102,7 +101,7 @@ export default function PreservedFormats() {
<div className="flex gap-1">
<div
onClick={() => handleDownload(ArchivedFormat.screenshot)}
onClick={() => handleDownload(ArchivedFormat.png)}
className="cursor-pointer hover:opacity-60 duration-100 p-2 rounded-md"
>
<FontAwesomeIcon
@@ -112,7 +111,11 @@ export default function PreservedFormats() {
</div>
<Link
href={`/api/v1/archives/${link?.id}?format=${ArchivedFormat.screenshot}`}
href={`/api/v1/archives/${link?.id}?format=${
link.screenshotPath.endsWith("png")
? ArchivedFormat.png
: ArchivedFormat.jpeg
}`}
target="_blank"
className="cursor-pointer hover:opacity-60 duration-100 p-2 rounded-md"
>