diff --git a/lib/api/controllers/links/updateLink.ts b/lib/api/controllers/links/updateLink.ts index d008c1ee..87954e17 100644 --- a/lib/api/controllers/links/updateLink.ts +++ b/lib/api/controllers/links/updateLink.ts @@ -32,16 +32,15 @@ export default async function updateLink( const isCollectionOwner = targetLink?.collection.ownerId === link.collection.ownerId && - link.collection.ownerId === userId && - targetLink?.collection.ownerId === userId; + link.collection.ownerId === userId; - const authorizedSwitchCollection = - !isCollectionOwner && targetLink?.collection.id === link.collection.id; + const unauthorizedSwitchCollection = + !isCollectionOwner && targetLink?.collection.id !== link.collection.id; - console.log(authorizedSwitchCollection); + console.log(isCollectionOwner); // Makes sure collection members (non-owners) cannot move a link to/from a collection. - if (!authorizedSwitchCollection) + if (unauthorizedSwitchCollection) return { response: "You can't move a link to/from a collection you don't own.", status: 401, @@ -59,15 +58,11 @@ export default async function updateLink( data: { name: link.name, description: link.description, - collection: - targetLink?.collection.ownerId === link.collection.ownerId && - link.collection.ownerId === userId - ? { - connect: { - id: link.collection.id, - }, - } - : undefined, + collection: { + connect: { + id: link.collection.id, + }, + }, tags: { set: [], connectOrCreate: link.tags.map((tag) => ({ @@ -104,14 +99,14 @@ export default async function updateLink( }, }); - if (targetLink.collection.id !== link.collection.id) { + if (targetLink?.collection.id !== link.collection.id) { await moveFile( - `archives/${targetLink.collection.id}/${link.id}.pdf`, + `archives/${targetLink?.collection.id}/${link.id}.pdf`, `archives/${link.collection.id}/${link.id}.pdf` ); await moveFile( - `archives/${targetLink.collection.id}/${link.id}.png`, + `archives/${targetLink?.collection.id}/${link.id}.png`, `archives/${link.collection.id}/${link.id}.png` ); } diff --git a/pages/choose-username.tsx b/pages/choose-username.tsx index 0dd385a1..c4f2f9ee 100644 --- a/pages/choose-username.tsx +++ b/pages/choose-username.tsx @@ -53,6 +53,7 @@ export default function Subscribe() { setInputedUsername(e.target.value)} /> diff --git a/pages/dashboard.tsx b/pages/dashboard.tsx index 5e784b8b..d6209c16 100644 --- a/pages/dashboard.tsx +++ b/pages/dashboard.tsx @@ -2,15 +2,13 @@ import useCollectionStore from "@/store/collections"; import { faChartSimple, faChevronDown, + faThumbTack, } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import MainLayout from "@/layouts/MainLayout"; import useLinkStore from "@/store/links"; import useTagStore from "@/store/tags"; import LinkCard from "@/components/LinkCard"; -import Link from "next/link"; -import CollectionCard from "@/components/CollectionCard"; -import { Disclosure, Transition } from "@headlessui/react"; import { useEffect, useState } from "react"; import useLinks from "@/hooks/useLinks"; @@ -21,20 +19,6 @@ export default function Dashboard() { const [numberOfLinks, setNumberOfLinks] = useState(0); - const [tagPinDisclosure, setTagPinDisclosure] = useState(() => { - const storedValue = - typeof window !== "undefined" && localStorage.getItem("tagPinDisclosure"); - return storedValue ? storedValue === "true" : true; - }); - - const [collectionPinDisclosure, setCollectionPinDisclosure] = - useState(() => { - const storedValue = - typeof window !== "undefined" && - localStorage.getItem("collectionPinDisclosure"); - return storedValue ? storedValue === "true" : true; - }); - const [linkPinDisclosure, setLinkPinDisclosure] = useState(() => { const storedValue = typeof window !== "undefined" && @@ -54,20 +38,6 @@ export default function Dashboard() { ); }, [collections]); - useEffect(() => { - localStorage.setItem( - "tagPinDisclosure", - tagPinDisclosure ? "true" : "false" - ); - }, [tagPinDisclosure]); - - useEffect(() => { - localStorage.setItem( - "collectionPinDisclosure", - collectionPinDisclosure ? "true" : "false" - ); - }, [collectionPinDisclosure]); - useEffect(() => { localStorage.setItem( "linkPinDisclosure", @@ -76,25 +46,22 @@ export default function Dashboard() { }, [linkPinDisclosure]); return ( - // ml-80 -
-
+
+
-

+

Dashboard

-
- -
-
+
+

{numberOfLinks}

@@ -103,7 +70,7 @@ export default function Dashboard() {

-
+

{collections.length}

@@ -112,7 +79,7 @@ export default function Dashboard() {

-
+

{tags.length}

@@ -122,143 +89,55 @@ export default function Dashboard() {
- {/*
*/} -
+
+
+ +

Pinned Links

+
+ {links.some((e) => e.pinnedBy && e.pinnedBy[0]) ? ( + + ) : undefined} +
{links.some((e) => e.pinnedBy && e.pinnedBy[0]) ? ( - -
- { - setLinkPinDisclosure(!linkPinDisclosure); - }} - className="flex justify-between gap-2 items-baseline shadow active:shadow-inner dark:bg-neutral-700 duration-100 py-2 px-4 rounded-full" - > -

- Pinned Links -

- -
- {linkPinDisclosure ? "Hide" : "Show"} - -
-
- - - - {links - .filter((e) => e.pinnedBy && e.pinnedBy[0]) - .map((e, i) => ( - - ))} - - -
-
+
+ {links + .filter((e) => e.pinnedBy && e.pinnedBy[0]) + .map((e, i) => ( + + ))} +
) : ( -
+

No Pinned Links

-

- You can Pin Links by clicking on the three dots on each Link and - clicking "Pin to Dashboard." +

+ You can Pin your favorite Links by clicking on the three dots on + each Link and clicking{" "} + Pin to Dashboard.

)} - - {/* -
- { - setCollectionPinDisclosure(!collectionPinDisclosure); - }} - className="flex justify-between gap-2 items-baseline shadow active:shadow-inner duration-100 py-2 px-4 rounded-full" - > -

Pinned Collections

- -
- {collectionPinDisclosure ? "Hide" : "Show"} - -
-
- - - {collections.slice(0, 5).map((e, i) => ( - - ))} - - -
-
*/} - - {/* -
- { - setTagPinDisclosure(!tagPinDisclosure); - }} - className="flex justify-between gap-2 items-baseline shadow active:shadow-inner duration-100 py-2 px-4 rounded-full" - > -

Pinned Tags

- -
- {tagPinDisclosure ? "Hide" : "Show"} - -
-
- - - {tags.slice(0, 19).map((e, i) => ( - - {e.name} - - ))} - - -
-
*/}
diff --git a/pages/forgot.tsx b/pages/forgot.tsx index d0c76ec7..25389ada 100644 --- a/pages/forgot.tsx +++ b/pages/forgot.tsx @@ -64,6 +64,7 @@ export default function Forgot() { type="email" placeholder="johnny@example.com" value={form.email} + className="bg-white" onChange={(e) => setForm({ ...form, email: e.target.value })} />
diff --git a/pages/login.tsx b/pages/login.tsx index 2b771631..1655218a 100644 --- a/pages/login.tsx +++ b/pages/login.tsx @@ -62,6 +62,7 @@ export default function Login() { setForm({ ...form, username: e.target.value })} />
@@ -75,6 +76,7 @@ export default function Login() { type="password" placeholder="••••••••••••••" value={form.password} + className="bg-white" onChange={(e) => setForm({ ...form, password: e.target.value })} /> {emailEnabled && ( diff --git a/pages/register.tsx b/pages/register.tsx index 2602a2ef..c719cb53 100644 --- a/pages/register.tsx +++ b/pages/register.tsx @@ -111,6 +111,7 @@ export default function Register() { setForm({ ...form, name: e.target.value })} />
@@ -124,6 +125,7 @@ export default function Register() { setForm({ ...form, username: e.target.value })} />
@@ -139,6 +141,7 @@ export default function Register() { type="email" placeholder="johnny@example.com" value={form.email} + className="bg-white" onChange={(e) => setForm({ ...form, email: e.target.value })} />
@@ -153,6 +156,7 @@ export default function Register() { type="password" placeholder="••••••••••••••" value={form.password} + className="bg-white" onChange={(e) => setForm({ ...form, password: e.target.value })} />
@@ -166,6 +170,7 @@ export default function Register() { type="password" placeholder="••••••••••••••" value={form.passwordConfirmation} + className="bg-white" onChange={(e) => setForm({ ...form, passwordConfirmation: e.target.value }) } diff --git a/styles/globals.css b/styles/globals.css index f715204e..5b3f4d4e 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -47,6 +47,21 @@ animation: slide-up-animation 70ms; } +.slide-down { + animation: slide-down-animation 70ms; +} + +@keyframes slide-down-animation { + 0% { + transform: translateY(-15%); + opacity: 0; + } + 100% { + transform: translateY(0); + opacity: 1; + } +} + @keyframes slide-up-animation { 0% { transform: translateY(15%);