diff --git a/components/Modal/AddLink.tsx b/components/Modal/AddLink.tsx index a803d2d..d1a992f 100644 --- a/components/Modal/AddLink.tsx +++ b/components/Modal/AddLink.tsx @@ -70,7 +70,7 @@ export default function AddLink({ toggleLinkModal }: Props) { if (response) toggleLinkModal(); }; return ( -
+

New Link

diff --git a/components/Modal/EditLink.tsx b/components/Modal/EditLink.tsx index e43b740..763de29 100644 --- a/components/Modal/EditLink.tsx +++ b/components/Modal/EditLink.tsx @@ -41,10 +41,10 @@ export default function EditLink({ toggleLinkModal, link }: Props) { }; return ( -
+

Edit Link

- {shortendURL} | {link.title} + {shortendURL} | {link.title}

Name

diff --git a/pages/api/routes/links/index.ts b/pages/api/routes/links/index.ts index 8f3c09d..dd12f22 100644 --- a/pages/api/routes/links/index.ts +++ b/pages/api/routes/links/index.ts @@ -27,8 +27,6 @@ export default async function (req: NextApiRequest, res: NextApiResponse) { response: deleted.response, }); } else if (req.method === "PUT") { - console.log("AAAAAAAAAAAAAAAAAAAAAAaa"); - const updated = await updateLink(req.body, session.user.id); return res.status(updated.status).json({ response: updated.response, diff --git a/pages/collections/[id].tsx b/pages/collections/[id].tsx index f1c0cff..db26986 100644 --- a/pages/collections/[id].tsx +++ b/pages/collections/[id].tsx @@ -1,18 +1,86 @@ +import Dropdown from "@/components/Dropdown"; import LinkList from "@/components/LinkList"; +import useCollectionStore from "@/store/collections"; import useLinkStore from "@/store/links"; +import { ExtendedLink } from "@/types/global"; +import { + faAdd, + faEllipsis, + faFolder, + faPenToSquare, + faTrashCan, +} from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { Collection } from "@prisma/client"; import { useRouter } from "next/router"; +import { useEffect, useState } from "react"; export default function () { const router = useRouter(); - const { links } = useLinkStore(); - const linksByCollection = links.filter( - (e) => e.collectionId === Number(router.query.id) - ); + const { links } = useLinkStore(); + const { collections } = useCollectionStore(); + + const [editDropdown, setEditDropdown] = useState(false); + const [activeCollection, setActiveCollection] = useState(); + const [linksByCollection, setLinksByCollection] = + useState(links); + + useEffect(() => { + setLinksByCollection( + links.filter((e) => e.collection.id === Number(router.query.id)) + ); + + setActiveCollection( + collections.find((e) => e.id === Number(router.query.id)) + ); + }, [links, router, collections]); return ( // ml-80
+
+
+ +

{activeCollection?.name}

+
+
+
setEditDropdown(!editDropdown)} + id="edit-dropdown" + className="inline-flex rounded-md cursor-pointer hover:bg-white hover:border-sky-500 border-sky-100 border duration-100 p-1" + > + +
+ {editDropdown ? ( + , + }, + { + name: "Edit Collection", + icon: , + }, + { + name: "Delete Collection", + icon: , + }, + ]} + onClickOutside={(e: Event) => { + const target = e.target as HTMLInputElement; + if (target.id !== "edit-dropdown") setEditDropdown(false); + }} + className="absolute top-7 left-0 z-10 w-44" + /> + ) : null} +
+
{linksByCollection.map((e, i) => { return ; })}