From 0dfd2664874d8b786e7fb5976010f34c377888f3 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 23 Jul 2023 14:27:12 -0400 Subject: [PATCH 1/8] bug fix --- lib/api/controllers/collections/postCollection.ts | 2 +- lib/api/controllers/links/postLink.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api/controllers/collections/postCollection.ts b/lib/api/controllers/collections/postCollection.ts index 8e4cc99..917f02f 100644 --- a/lib/api/controllers/collections/postCollection.ts +++ b/lib/api/controllers/collections/postCollection.ts @@ -37,7 +37,7 @@ export default async function postCollection( id: userId, }, }, - name: collection.name, + name: collection.name.trim(), description: collection.description, color: collection.color, members: { diff --git a/lib/api/controllers/links/postLink.ts b/lib/api/controllers/links/postLink.ts index 2991235..7a1bf56 100644 --- a/lib/api/controllers/links/postLink.ts +++ b/lib/api/controllers/links/postLink.ts @@ -57,7 +57,7 @@ export default async function postLink( }, }, create: { - name: link.collection.name, + name: link.collection.name.trim(), ownerId: userId, }, }, From 400939cb0b2a0c94eef50a9a889762793833f9c1 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 23 Jul 2023 15:52:08 -0400 Subject: [PATCH 2/8] minor fix --- lib/api/controllers/collections/updateCollection.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/controllers/collections/updateCollection.ts b/lib/api/controllers/collections/updateCollection.ts index 16a7d7f..7cafedd 100644 --- a/lib/api/controllers/collections/updateCollection.ts +++ b/lib/api/controllers/collections/updateCollection.ts @@ -37,7 +37,7 @@ export default async function updateCollection( }, data: { - name: collection.name, + name: collection.name.trim(), description: collection.description, color: collection.color, isPublic: collection.isPublic, From 6708be2dfde063353764056dbe2b7e32d7641298 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 24 Jul 2023 07:25:15 -0400 Subject: [PATCH 3/8] improved responsiveness --- pages/collections/[id].tsx | 2 +- pages/tags/[id].tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/collections/[id].tsx b/pages/collections/[id].tsx index 798a98a..097e4f1 100644 --- a/pages/collections/[id].tsx +++ b/pages/collections/[id].tsx @@ -236,7 +236,7 @@ export default function Index() { {links[0] ? ( -
+
{links .filter((e) => e.collectionId === Number(router.query.id)) .map((e, i) => { diff --git a/pages/tags/[id].tsx b/pages/tags/[id].tsx index 0571b4a..afbd1a5 100644 --- a/pages/tags/[id].tsx +++ b/pages/tags/[id].tsx @@ -66,7 +66,7 @@ export default function Index() { ) : null}
-
+
{links .filter((e) => e.tags.some((e) => e.id === Number(router.query.id))) .map((e, i) => { From cbf53f6e3075ef95e787075ac9e1a6a316950c61 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 24 Jul 2023 09:39:51 -0400 Subject: [PATCH 4/8] improvements + better error handling --- components/LinkCard.tsx | 20 +++++++++++-- components/Modal/Link/AddOrEditLink.tsx | 37 ++++++++++++------------- lib/api/controllers/links/postLink.ts | 20 +++++++++---- lib/api/getTitle.ts | 2 +- 4 files changed, 51 insertions(+), 28 deletions(-) diff --git a/components/LinkCard.tsx b/components/LinkCard.tsx index 873966f..2dd2b47 100644 --- a/components/LinkCard.tsx +++ b/components/LinkCard.tsx @@ -2,7 +2,11 @@ import { CollectionIncludingMembersAndLinkCount, LinkIncludingShortenedCollectionAndTags, } from "@/types/global"; -import { faFolder, faEllipsis } from "@fortawesome/free-solid-svg-icons"; +import { + faFolder, + faEllipsis, + faLink, +} from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { useEffect, useState } from "react"; import Image from "next/image"; @@ -33,6 +37,14 @@ export default function LinkCard({ link, count, className }: Props) { const { account } = useAccountStore(); + let shortendURL; + + try { + shortendURL = new URL(link.url).host.toLowerCase(); + } catch (error) { + console.log(error); + } + const [collection, setCollection] = useState( collections.find( @@ -144,7 +156,7 @@ export default function LinkCard({ link, count, className }: Props) {

{count + 1}.

- {link.name} + {link.name || link.description}

@@ -159,6 +171,10 @@ export default function LinkCard({ link, count, className }: Props) {

+
+ +

{shortendURL}

+

{formattedDate}

diff --git a/components/Modal/Link/AddOrEditLink.tsx b/components/Modal/Link/AddOrEditLink.tsx index f1d2f85..205513c 100644 --- a/components/Modal/Link/AddOrEditLink.tsx +++ b/components/Modal/Link/AddOrEditLink.tsx @@ -11,6 +11,7 @@ import useCollectionStore from "@/store/collections"; import { useRouter } from "next/router"; import SubmitButton from "../../SubmitButton"; import { toast } from "react-hot-toast"; +import Link from "next/link"; type Props = | { @@ -70,8 +71,6 @@ export default function AddOrEditLink({ } }, []); - // const shortendURL = method === "UPDATE" ? new URL(link.url).host.toLowerCase() : undefined; - const setTags = (e: any) => { const tagNames = e.map((e: any) => { return { name: e.label }; @@ -119,27 +118,15 @@ export default function AddOrEditLink({ className="text-gray-500 my-2 text-center truncate w-full" title={link.url} > - Edit {link.url} + + {link.url} +

) : null}
-
-

- Name - -

- setLink({ ...link, name: e.target.value })} - type="text" - placeholder="e.g. Example Link" - className="w-full rounded-md p-2 border-sky-100 border-solid border outline-none focus:border-sky-700 duration-100" - /> -
- {method === "CREATE" ? ( -
+

URL @@ -173,7 +160,7 @@ export default function AddOrEditLink({ />

-
+

Tags

+ +
+

Name

+ setLink({ ...link, name: e.target.value })} + type="text" + placeholder="e.g. Example Link" + className="w-full rounded-md p-2 border-sky-100 border-solid border outline-none focus:border-sky-700 duration-100" + /> +
+

Description