Fix more types and use logical ANDs
This commit is contained in:
@@ -166,8 +166,12 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
|
||||
where: { id: linkId },
|
||||
});
|
||||
|
||||
if (linkStillExists && files.file[0].mimetype?.includes("image")) {
|
||||
const collectionId = collectionPermissions.id as number;
|
||||
const { mimetype } = files.file[0];
|
||||
const isPDF = mimetype?.includes("pdf");
|
||||
const isImage = mimetype?.includes("image");
|
||||
|
||||
if (linkStillExists && isImage) {
|
||||
const collectionId = collectionPermissions.id;
|
||||
createFolder({
|
||||
filePath: `archives/preview/${collectionId}`,
|
||||
});
|
||||
@@ -184,15 +188,9 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
|
||||
await prisma.link.update({
|
||||
where: { id: linkId },
|
||||
data: {
|
||||
preview: files.file[0].mimetype?.includes("pdf")
|
||||
? "unavailable"
|
||||
: undefined,
|
||||
image: files.file[0].mimetype?.includes("image")
|
||||
? `archives/${collectionPermissions.id}/${linkId + suffix}`
|
||||
: null,
|
||||
pdf: files.file[0].mimetype?.includes("pdf")
|
||||
? `archives/${collectionPermissions.id}/${linkId + suffix}`
|
||||
: null,
|
||||
preview: isPDF ? "unavailable" : undefined,
|
||||
image: isImage ? `archives/${collectionPermissions.id}/${linkId + suffix}` : null,
|
||||
pdf: isPDF ? `archives/${collectionPermissions.id}/${linkId + suffix}` : null,
|
||||
lastPreserved: new Date().toISOString(),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import useCollectionStore from "@/store/collections";
|
||||
import useLinkStore from "@/store/links";
|
||||
import {
|
||||
AccountSettings,
|
||||
CollectionIncludingMembersAndLinkCount,
|
||||
Sort,
|
||||
ViewMode,
|
||||
@@ -53,15 +54,7 @@ export default function Index() {
|
||||
|
||||
const { account } = useAccountStore();
|
||||
|
||||
const [collectionOwner, setCollectionOwner] = useState({
|
||||
id: null as unknown as number,
|
||||
name: "",
|
||||
username: "",
|
||||
image: "",
|
||||
archiveAsScreenshot: undefined as unknown as boolean,
|
||||
archiveAsMonolith: undefined as unknown as boolean,
|
||||
archiveAsPDF: undefined as unknown as boolean,
|
||||
});
|
||||
const [collectionOwner, setCollectionOwner] = useState<Partial<AccountSettings>>({});
|
||||
|
||||
useEffect(() => {
|
||||
const fetchOwner = async () => {
|
||||
@@ -217,7 +210,7 @@ export default function Index() {
|
||||
/>
|
||||
)}
|
||||
{activeCollection.members
|
||||
.sort((a, b) => (a.userId as number) - (b.userId as number))
|
||||
.sort((a, b) => (a.userId) - (b.userId))
|
||||
.map((e, i) => {
|
||||
return (
|
||||
<ProfilePhoto
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
import getPublicCollectionData from "@/lib/client/getPublicCollectionData";
|
||||
import {
|
||||
AccountSettings,
|
||||
CollectionIncludingMembersAndLinkCount,
|
||||
Sort,
|
||||
ViewMode,
|
||||
@@ -36,15 +37,7 @@ export default function PublicCollections() {
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const [collectionOwner, setCollectionOwner] = useState({
|
||||
id: null as unknown as number,
|
||||
name: "",
|
||||
username: "",
|
||||
image: "",
|
||||
archiveAsScreenshot: undefined as unknown as boolean,
|
||||
archiveAsMonolith: undefined as unknown as boolean,
|
||||
archiveAsPDF: undefined as unknown as boolean,
|
||||
});
|
||||
const [collectionOwner, setCollectionOwner] = useState<Partial<AccountSettings>>({});
|
||||
|
||||
const [searchFilter, setSearchFilter] = useState({
|
||||
name: true,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import { useState, useEffect, ChangeEvent } from "react";
|
||||
import useAccountStore from "@/store/account";
|
||||
import { AccountSettings } from "@/types/global";
|
||||
import { toast } from "react-hot-toast";
|
||||
@@ -54,8 +54,10 @@ export default function Account() {
|
||||
if (!objectIsEmpty(account)) setUser({ ...account });
|
||||
}, [account]);
|
||||
|
||||
const handleImageUpload = async (e: any) => {
|
||||
const file: File = e.target.files[0];
|
||||
const handleImageUpload = async (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return toast.error(t("image_upload_no_file_error"));
|
||||
|
||||
const fileExtension = file.name.split(".").pop()?.toLowerCase();
|
||||
const allowedExtensions = ["png", "jpeg", "jpg"];
|
||||
if (allowedExtensions.includes(fileExtension as string)) {
|
||||
@@ -100,9 +102,10 @@ export default function Account() {
|
||||
setSubmitLoader(false);
|
||||
};
|
||||
|
||||
const importBookmarks = async (e: any, format: MigrationFormat) => {
|
||||
const importBookmarks = async (e: ChangeEvent<HTMLInputElement>, format: MigrationFormat) => {
|
||||
setSubmitLoader(true);
|
||||
const file: File = e.target.files[0];
|
||||
const file = e.target.files?.[0];
|
||||
|
||||
if (file) {
|
||||
var reader = new FileReader();
|
||||
reader.readAsText(file, "UTF-8");
|
||||
|
||||
Reference in New Issue
Block a user