From 2b82d2aa8a00d67d4a6eae0d667a3e48dad3216e Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 5 Jun 2023 13:46:04 +0330 Subject: [PATCH] small fix --- components/LinkList.tsx | 28 ++++++++++++++++++++++++---- pages/collections/index.tsx | 1 - pages/search/[query].tsx | 13 ++++++++++--- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/components/LinkList.tsx b/components/LinkList.tsx index 2ab9fec..77242e9 100644 --- a/components/LinkList.tsx +++ b/components/LinkList.tsx @@ -1,4 +1,7 @@ -import { LinkIncludingCollectionAndTags } from "@/types/global"; +import { + CollectionIncludingMembers, + LinkIncludingCollectionAndTags, +} from "@/types/global"; import { faFolder, faArrowUpRightFromSquare, @@ -6,13 +9,14 @@ import { } from "@fortawesome/free-solid-svg-icons"; import { faFileImage, faFilePdf } from "@fortawesome/free-regular-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import Image from "next/image"; import Dropdown from "./Dropdown"; import useLinkStore from "@/store/links"; import Modal from "./Modal"; import LinkModal from "./Modal/LinkModal"; import Link from "next/link"; +import useCollectionStore from "@/store/collections"; type Props = { link: LinkIncludingCollectionAndTags; @@ -23,6 +27,22 @@ export default function ({ link, count }: Props) { const [expandDropdown, setExpandDropdown] = useState(false); const [editModal, setEditModal] = useState(false); + const { collections } = useCollectionStore(); + + const [collection, setCollection] = useState( + collections.find( + (e) => e.id === link.collection.id + ) as CollectionIncludingMembers + ); + + useEffect(() => { + setCollection( + collections.find( + (e) => e.id === link.collection.id + ) as CollectionIncludingMembers + ); + }, [collections]); + const { removeLink } = useLinkStore(); const url = new URL(link.url); @@ -88,9 +108,9 @@ export default function ({ link, count }: Props) { -

{link.collection.name}

+

{collection.name}

diff --git a/pages/collections/index.tsx b/pages/collections/index.tsx index f81817b..0f5044b 100644 --- a/pages/collections/index.tsx +++ b/pages/collections/index.tsx @@ -77,7 +77,6 @@ export default function () { }, [collections, sortBy]); return ( - // ml-80
diff --git a/pages/search/[query].tsx b/pages/search/[query].tsx index 965e261..9277b63 100644 --- a/pages/search/[query].tsx +++ b/pages/search/[query].tsx @@ -70,9 +70,16 @@ export default function Links() {
-
- -

Search Results

+
+
+ +

+ Search Results +

+