improved DX
This commit is contained in:
parent
a36769c521
commit
9e4502c015
|
@ -192,24 +192,24 @@ export default function CollectionCard({ collection, className }: Props) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
|
{editCollectionModal ? (
|
||||||
<EditCollectionModal
|
<EditCollectionModal
|
||||||
isOpen={editCollectionModal}
|
|
||||||
onClose={() => setEditCollectionModal(false)}
|
onClose={() => setEditCollectionModal(false)}
|
||||||
modalId={"edit-collection-modal" + collection.id}
|
|
||||||
activeCollection={collection}
|
activeCollection={collection}
|
||||||
/>
|
/>
|
||||||
|
) : undefined}
|
||||||
|
{editCollectionSharingModal ? (
|
||||||
<EditCollectionSharingModal
|
<EditCollectionSharingModal
|
||||||
isOpen={editCollectionSharingModal}
|
|
||||||
onClose={() => setEditCollectionSharingModal(false)}
|
onClose={() => setEditCollectionSharingModal(false)}
|
||||||
modalId={"edit-collection-sharing-modal" + collection.id}
|
|
||||||
activeCollection={collection}
|
activeCollection={collection}
|
||||||
/>
|
/>
|
||||||
|
) : undefined}
|
||||||
|
{deleteCollectionModal ? (
|
||||||
<DeleteCollectionModal
|
<DeleteCollectionModal
|
||||||
isOpen={deleteCollectionModal}
|
|
||||||
onClose={() => setDeleteCollectionModal(false)}
|
onClose={() => setDeleteCollectionModal(false)}
|
||||||
modalId={"delete-collection-modal" + collection.id}
|
|
||||||
activeCollection={collection}
|
activeCollection={collection}
|
||||||
/>
|
/>
|
||||||
|
) : undefined}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ export default function LinkCard({ link, count, className }: Props) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const [newLinkModal, setNewLinkModal] = useState(false);
|
const [editLinkModal, setEditLinkModal] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
@ -168,7 +168,7 @@ export default function LinkCard({ link, count, className }: Props) {
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
(document?.activeElement as HTMLElement)?.blur();
|
(document?.activeElement as HTMLElement)?.blur();
|
||||||
setNewLinkModal(true);
|
setEditLinkModal(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Edit
|
Edit
|
||||||
|
@ -291,12 +291,12 @@ export default function LinkCard({ link, count, className }: Props) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{editLinkModal ? (
|
||||||
<EditLinkModal
|
<EditLinkModal
|
||||||
isOpen={newLinkModal}
|
onClose={() => setEditLinkModal(false)}
|
||||||
onClose={() => setNewLinkModal(false)}
|
|
||||||
modalId={"edit-link-modal" + link.id}
|
|
||||||
activeLink={link}
|
activeLink={link}
|
||||||
/>
|
/>
|
||||||
|
) : undefined}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Tab } from "@headlessui/react";
|
||||||
import CollectionInfo from "./CollectionInfo";
|
import CollectionInfo from "./CollectionInfo";
|
||||||
import { CollectionIncludingMembersAndLinkCount } from "@/types/global";
|
import { CollectionIncludingMembersAndLinkCount } from "@/types/global";
|
||||||
import TeamManagement from "./TeamManagement";
|
import TeamManagement from "./TeamManagement";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import DeleteCollection from "./DeleteCollection";
|
import DeleteCollection from "./DeleteCollection";
|
||||||
import ViewTeam from "./ViewTeam";
|
import ViewTeam from "./ViewTeam";
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { MouseEventHandler, ReactNode } from "react";
|
import { MouseEventHandler, ReactNode, useEffect } from "react";
|
||||||
import ClickAwayHandler from "@/components/ClickAwayHandler";
|
import ClickAwayHandler from "@/components/ClickAwayHandler";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { faChevronLeft } from "@fortawesome/free-solid-svg-icons";
|
import { faClose } from "@fortawesome/free-solid-svg-icons";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
toggleModal: Function;
|
toggleModal: Function;
|
||||||
|
@ -14,17 +14,14 @@ export default function Modal({ toggleModal, className, children }: Props) {
|
||||||
<div className="overflow-y-auto py-2 fixed top-0 bottom-0 right-0 left-0 bg-black bg-opacity-10 backdrop-blur-sm flex justify-center items-center fade-in z-30">
|
<div className="overflow-y-auto py-2 fixed top-0 bottom-0 right-0 left-0 bg-black bg-opacity-10 backdrop-blur-sm flex justify-center items-center fade-in z-30">
|
||||||
<ClickAwayHandler
|
<ClickAwayHandler
|
||||||
onClickOutside={toggleModal}
|
onClickOutside={toggleModal}
|
||||||
className={`m-auto ${className || ""}`}
|
className={`m-auto w-11/12 max-w-2xl ${className || ""}`}
|
||||||
>
|
>
|
||||||
<div className="slide-up relative border-neutral-content rounded-2xl border-solid border shadow-lg p-5 bg-base-100">
|
<div className="slide-up m-auto relative border-neutral-content rounded-2xl border-solid border shadow-2xl p-5 bg-base-100">
|
||||||
<div
|
<div
|
||||||
onClick={toggleModal as MouseEventHandler<HTMLDivElement>}
|
onClick={toggleModal as MouseEventHandler<HTMLDivElement>}
|
||||||
className="absolute top-5 left-5 inline-flex rounded-md cursor-pointer hover:bg-slate-200 hover:dark:bg-neutral-700 duration-100 z-20 p-2"
|
className="absolute top-3 right-3 btn btn-sm outline-none btn-circle btn-ghost"
|
||||||
>
|
>
|
||||||
<FontAwesomeIcon
|
<FontAwesomeIcon icon={faClose} className="w-4 h-4 text-neutral" />
|
||||||
icon={faChevronLeft}
|
|
||||||
className="w-4 h-4 text-neutral"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,52 +1,32 @@
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import TextInput from "@/components/TextInput";
|
import TextInput from "@/components/TextInput";
|
||||||
import useCollectionStore from "@/store/collections";
|
import useCollectionStore from "@/store/collections";
|
||||||
import toast, { Toaster } from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import {
|
import {
|
||||||
faFolder,
|
|
||||||
faRightFromBracket,
|
faRightFromBracket,
|
||||||
faTrashCan,
|
faTrashCan,
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
} from "@fortawesome/free-solid-svg-icons";
|
||||||
import { HexColorPicker } from "react-colorful";
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { CollectionIncludingMembersAndLinkCount } from "@/types/global";
|
import { CollectionIncludingMembersAndLinkCount } from "@/types/global";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import usePermissions from "@/hooks/usePermissions";
|
import usePermissions from "@/hooks/usePermissions";
|
||||||
|
import Modal from "../Modal";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
modalId: string;
|
|
||||||
isOpen: boolean;
|
|
||||||
onClose: Function;
|
onClose: Function;
|
||||||
activeCollection: CollectionIncludingMembersAndLinkCount;
|
activeCollection: CollectionIncludingMembersAndLinkCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function DeleteCollectionModal({
|
export default function DeleteCollectionModal({
|
||||||
modalId,
|
|
||||||
isOpen,
|
|
||||||
onClose,
|
onClose,
|
||||||
activeCollection,
|
activeCollection,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const modal = document.getElementById(modalId);
|
|
||||||
|
|
||||||
const [collection, setCollection] =
|
const [collection, setCollection] =
|
||||||
useState<CollectionIncludingMembersAndLinkCount>(activeCollection);
|
useState<CollectionIncludingMembersAndLinkCount>(activeCollection);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
modal?.scrollTo(0, 0);
|
|
||||||
|
|
||||||
setCollection(activeCollection);
|
setCollection(activeCollection);
|
||||||
setInputField("");
|
}, []);
|
||||||
|
|
||||||
modal?.addEventListener("close", () => {
|
|
||||||
onClose();
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
modal?.addEventListener("close", () => {
|
|
||||||
onClose();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}, [isOpen]);
|
|
||||||
|
|
||||||
const [submitLoader, setSubmitLoader] = useState(false);
|
const [submitLoader, setSubmitLoader] = useState(false);
|
||||||
const { removeCollection } = useCollectionStore();
|
const { removeCollection } = useCollectionStore();
|
||||||
|
@ -74,7 +54,7 @@ export default function DeleteCollectionModal({
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
toast.success(`Deleted.`);
|
toast.success(`Deleted.`);
|
||||||
(document.getElementById(modalId) as any).close();
|
onClose();
|
||||||
router.push("/collections");
|
router.push("/collections");
|
||||||
} else toast.error(response.data as string);
|
} else toast.error(response.data as string);
|
||||||
|
|
||||||
|
@ -83,26 +63,7 @@ export default function DeleteCollectionModal({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<dialog
|
<Modal toggleModal={onClose}>
|
||||||
id={modalId}
|
|
||||||
className="modal backdrop-blur-sm overflow-y-auto p-5"
|
|
||||||
open={isOpen}
|
|
||||||
>
|
|
||||||
<Toaster
|
|
||||||
position="top-center"
|
|
||||||
reverseOrder={false}
|
|
||||||
toastOptions={{
|
|
||||||
className:
|
|
||||||
"border border-sky-100 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div className="modal-box max-h-full overflow-y-visible border border-neutral-content w-11/12 max-w-2xl">
|
|
||||||
<form method="dialog">
|
|
||||||
<button className="btn btn-sm outline-none btn-circle btn-ghost absolute right-3 top-3">
|
|
||||||
✕
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<p className="text-xl mb-5 font-thin text-red-500">
|
<p className="text-xl mb-5 font-thin text-red-500">
|
||||||
{permissions === true ? "Delete" : "Leave"} Collection
|
{permissions === true ? "Delete" : "Leave"} Collection
|
||||||
</p>
|
</p>
|
||||||
|
@ -144,8 +105,8 @@ export default function DeleteCollectionModal({
|
||||||
Warning: Deleting this collection will permanently erase all
|
Warning: Deleting this collection will permanently erase all
|
||||||
its contents
|
its contents
|
||||||
</b>
|
</b>
|
||||||
, and it will become inaccessible to everyone, including
|
, and it will become inaccessible to everyone, including members
|
||||||
members with previous access.
|
with previous access.
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
@ -171,10 +132,6 @@ export default function DeleteCollectionModal({
|
||||||
{permissions === true ? "Delete" : "Leave"} Collection
|
{permissions === true ? "Delete" : "Leave"} Collection
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Modal>
|
||||||
<form method="dialog" className="modal-backdrop">
|
|
||||||
<button>close</button>
|
|
||||||
</form>
|
|
||||||
</dialog>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,37 +6,17 @@ import { faFolder } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { HexColorPicker } from "react-colorful";
|
import { HexColorPicker } from "react-colorful";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { CollectionIncludingMembersAndLinkCount } from "@/types/global";
|
import { CollectionIncludingMembersAndLinkCount } from "@/types/global";
|
||||||
|
import Modal from "../Modal";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
modalId: string;
|
|
||||||
isOpen: boolean;
|
|
||||||
onClose: Function;
|
onClose: Function;
|
||||||
activeCollection: CollectionIncludingMembersAndLinkCount;
|
activeCollection: CollectionIncludingMembersAndLinkCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function EditCollectionModal({
|
export default function EditCollectionModal({
|
||||||
modalId,
|
|
||||||
isOpen,
|
|
||||||
onClose,
|
onClose,
|
||||||
activeCollection,
|
activeCollection,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const modal = document.getElementById(modalId);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
modal?.scrollTo(0, 0);
|
|
||||||
setCollection(activeCollection);
|
|
||||||
|
|
||||||
modal?.addEventListener("close", () => {
|
|
||||||
onClose();
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
modal?.addEventListener("close", () => {
|
|
||||||
onClose();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}, [isOpen]);
|
|
||||||
|
|
||||||
const [collection, setCollection] =
|
const [collection, setCollection] =
|
||||||
useState<CollectionIncludingMembersAndLinkCount>(activeCollection);
|
useState<CollectionIncludingMembersAndLinkCount>(activeCollection);
|
||||||
|
|
||||||
|
@ -60,7 +40,7 @@ export default function EditCollectionModal({
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
toast.success(`Updated!`);
|
toast.success(`Updated!`);
|
||||||
(document.getElementById(modalId) as any).close();
|
onClose();
|
||||||
} else toast.error(response.data as string);
|
} else toast.error(response.data as string);
|
||||||
|
|
||||||
setSubmitLoader(false);
|
setSubmitLoader(false);
|
||||||
|
@ -68,26 +48,7 @@ export default function EditCollectionModal({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<dialog
|
<Modal toggleModal={onClose}>
|
||||||
id={modalId}
|
|
||||||
className="modal backdrop-blur-sm overflow-y-auto p-5"
|
|
||||||
open={isOpen}
|
|
||||||
>
|
|
||||||
<Toaster
|
|
||||||
position="top-center"
|
|
||||||
reverseOrder={false}
|
|
||||||
toastOptions={{
|
|
||||||
className:
|
|
||||||
"border border-sky-100 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div className="modal-box max-h-full overflow-y-visible border border-neutral-content w-11/12 max-w-2xl">
|
|
||||||
<form method="dialog">
|
|
||||||
<button className="btn btn-sm outline-none btn-circle btn-ghost absolute right-3 top-3">
|
|
||||||
✕
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<p className="text-xl mb-5 font-thin">Edit Collection Info</p>
|
<p className="text-xl mb-5 font-thin">Edit Collection Info</p>
|
||||||
|
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
|
@ -124,9 +85,7 @@ export default function EditCollectionModal({
|
||||||
</div>
|
</div>
|
||||||
<HexColorPicker
|
<HexColorPicker
|
||||||
color={collection.color}
|
color={collection.color}
|
||||||
onChange={(e) =>
|
onChange={(e) => setCollection({ ...collection, color: e })}
|
||||||
setCollection({ ...collection, color: e })
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -153,10 +112,6 @@ export default function EditCollectionModal({
|
||||||
Save
|
Save
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Modal>
|
||||||
<form method="dialog" className="modal-backdrop">
|
|
||||||
<button>close</button>
|
|
||||||
</form>
|
|
||||||
</dialog>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,22 +14,17 @@ import useAccountStore from "@/store/account";
|
||||||
import usePermissions from "@/hooks/usePermissions";
|
import usePermissions from "@/hooks/usePermissions";
|
||||||
import ProfilePhoto from "../ProfilePhoto";
|
import ProfilePhoto from "../ProfilePhoto";
|
||||||
import addMemberToCollection from "@/lib/client/addMemberToCollection";
|
import addMemberToCollection from "@/lib/client/addMemberToCollection";
|
||||||
|
import Modal from "../Modal";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
modalId: string;
|
|
||||||
isOpen: boolean;
|
|
||||||
onClose: Function;
|
onClose: Function;
|
||||||
activeCollection: CollectionIncludingMembersAndLinkCount;
|
activeCollection: CollectionIncludingMembersAndLinkCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function EditCollectionSharingModal({
|
export default function EditCollectionSharingModal({
|
||||||
modalId,
|
|
||||||
isOpen,
|
|
||||||
onClose,
|
onClose,
|
||||||
activeCollection,
|
activeCollection,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const modal = document.getElementById(modalId);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchOwner = async () => {
|
const fetchOwner = async () => {
|
||||||
const owner = await getPublicUserData(collection.ownerId as number);
|
const owner = await getPublicUserData(collection.ownerId as number);
|
||||||
|
@ -38,19 +33,8 @@ export default function EditCollectionSharingModal({
|
||||||
|
|
||||||
fetchOwner();
|
fetchOwner();
|
||||||
|
|
||||||
modal?.scrollTo(0, 0);
|
|
||||||
setCollection(activeCollection);
|
setCollection(activeCollection);
|
||||||
|
}, []);
|
||||||
modal?.addEventListener("close", () => {
|
|
||||||
onClose();
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
modal?.addEventListener("close", () => {
|
|
||||||
onClose();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}, [isOpen]);
|
|
||||||
|
|
||||||
const [collection, setCollection] =
|
const [collection, setCollection] =
|
||||||
useState<CollectionIncludingMembersAndLinkCount>(activeCollection);
|
useState<CollectionIncludingMembersAndLinkCount>(activeCollection);
|
||||||
|
@ -75,7 +59,7 @@ export default function EditCollectionSharingModal({
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
toast.success(`Updated!`);
|
toast.success(`Updated!`);
|
||||||
(document.getElementById(modalId) as any).close();
|
onClose();
|
||||||
} else toast.error(response.data as string);
|
} else toast.error(response.data as string);
|
||||||
|
|
||||||
setSubmitLoader(false);
|
setSubmitLoader(false);
|
||||||
|
@ -110,26 +94,7 @@ export default function EditCollectionSharingModal({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<dialog
|
<Modal toggleModal={onClose}>
|
||||||
id={modalId}
|
|
||||||
className="modal backdrop-blur-sm overflow-y-auto p-5"
|
|
||||||
open={isOpen}
|
|
||||||
>
|
|
||||||
<Toaster
|
|
||||||
position="top-center"
|
|
||||||
reverseOrder={false}
|
|
||||||
toastOptions={{
|
|
||||||
className:
|
|
||||||
"border border-sky-100 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div className="modal-box max-h-full overflow-y-visible border border-neutral-content w-11/12 max-w-2xl">
|
|
||||||
<form method="dialog">
|
|
||||||
<button className="btn btn-sm outline-none btn-circle btn-ghost absolute right-3 top-3">
|
|
||||||
✕
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<p className="text-xl font-thin mb-5">
|
<p className="text-xl font-thin mb-5">
|
||||||
{permissions === true ? "Share and Collaborate" : "Team"}
|
{permissions === true ? "Share and Collaborate" : "Team"}
|
||||||
</p>
|
</p>
|
||||||
|
@ -151,9 +116,7 @@ export default function EditCollectionSharingModal({
|
||||||
}
|
}
|
||||||
className="checkbox checkbox-primary"
|
className="checkbox checkbox-primary"
|
||||||
/>
|
/>
|
||||||
<span className="label-text">
|
<span className="label-text">Make this a public collection</span>
|
||||||
Make this a public collection
|
|
||||||
</span>
|
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<p className="text-neutral text-sm">
|
<p className="text-neutral text-sm">
|
||||||
|
@ -244,9 +207,7 @@ export default function EditCollectionSharingModal({
|
||||||
<div className="flex items-center gap-2 w-full">
|
<div className="flex items-center gap-2 w-full">
|
||||||
<ProfilePhoto
|
<ProfilePhoto
|
||||||
src={
|
src={
|
||||||
collectionOwner.image
|
collectionOwner.image ? collectionOwner.image : undefined
|
||||||
? collectionOwner.image
|
|
||||||
: undefined
|
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
|
@ -262,9 +223,7 @@ export default function EditCollectionSharingModal({
|
||||||
Admin
|
Admin
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-neutral">
|
<p className="text-neutral">@{collectionOwner.username}</p>
|
||||||
@{collectionOwner.username}
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -285,9 +244,7 @@ export default function EditCollectionSharingModal({
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const updatedMembers = collection.members.filter(
|
const updatedMembers = collection.members.filter(
|
||||||
(member) => {
|
(member) => {
|
||||||
return (
|
return member.user.username !== e.user.username;
|
||||||
member.user.username !== e.user.username
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
setCollection({
|
setCollection({
|
||||||
|
@ -484,10 +441,6 @@ export default function EditCollectionSharingModal({
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Modal>
|
||||||
<form method="dialog" className="modal-backdrop">
|
|
||||||
<button>close</button>
|
|
||||||
</form>
|
|
||||||
</dialog>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,22 +10,14 @@ import toast from "react-hot-toast";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { faLink } from "@fortawesome/free-solid-svg-icons";
|
import { faLink } from "@fortawesome/free-solid-svg-icons";
|
||||||
|
import Modal from "../Modal";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
modalId: string;
|
|
||||||
isOpen: boolean;
|
|
||||||
onClose: Function;
|
onClose: Function;
|
||||||
activeLink: LinkIncludingShortenedCollectionAndTags;
|
activeLink: LinkIncludingShortenedCollectionAndTags;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function EditLinkModal({
|
export default function EditLinkModal({ onClose, activeLink }: Props) {
|
||||||
modalId,
|
|
||||||
isOpen,
|
|
||||||
onClose,
|
|
||||||
activeLink,
|
|
||||||
}: Props) {
|
|
||||||
const modal = document.getElementById(modalId);
|
|
||||||
|
|
||||||
const [link, setLink] =
|
const [link, setLink] =
|
||||||
useState<LinkIncludingShortenedCollectionAndTags>(activeLink);
|
useState<LinkIncludingShortenedCollectionAndTags>(activeLink);
|
||||||
|
|
||||||
|
@ -58,20 +50,8 @@ export default function EditLinkModal({
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
modal?.scrollTo(0, 0);
|
|
||||||
|
|
||||||
setLink(activeLink);
|
setLink(activeLink);
|
||||||
|
}, []);
|
||||||
modal?.addEventListener("close", () => {
|
|
||||||
onClose();
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
modal?.addEventListener("close", () => {
|
|
||||||
onClose();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}, [isOpen]);
|
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
if (!submitLoader) {
|
if (!submitLoader) {
|
||||||
|
@ -87,7 +67,7 @@ export default function EditLinkModal({
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
toast.success(`Updated!`);
|
toast.success(`Updated!`);
|
||||||
(document.getElementById(modalId) as any).close();
|
onClose();
|
||||||
} else toast.error(response.data as string);
|
} else toast.error(response.data as string);
|
||||||
|
|
||||||
setSubmitLoader(false);
|
setSubmitLoader(false);
|
||||||
|
@ -97,26 +77,7 @@ export default function EditLinkModal({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<dialog
|
<Modal toggleModal={onClose}>
|
||||||
id={modalId}
|
|
||||||
className="modal backdrop-blur-sm overflow-y-auto p-5"
|
|
||||||
open={isOpen}
|
|
||||||
>
|
|
||||||
<Toaster
|
|
||||||
position="top-center"
|
|
||||||
reverseOrder={false}
|
|
||||||
toastOptions={{
|
|
||||||
className:
|
|
||||||
"border border-sky-100 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div className="modal-box max-h-full overflow-y-visible border border-neutral-content w-11/12 max-w-2xl">
|
|
||||||
<form method="dialog">
|
|
||||||
<button className="btn btn-sm outline-none btn-circle btn-ghost absolute right-3 top-3">
|
|
||||||
✕
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<p className="text-xl mb-5 font-thin">Edit Link</p>
|
<p className="text-xl mb-5 font-thin">Edit Link</p>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
|
@ -198,10 +159,6 @@ export default function EditLinkModal({
|
||||||
Save
|
Save
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Modal>
|
||||||
<form method="dialog" className="modal-backdrop">
|
|
||||||
<button>close</button>
|
|
||||||
</form>
|
|
||||||
</dialog>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,20 +6,13 @@ import { faFolder } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { HexColorPicker } from "react-colorful";
|
import { HexColorPicker } from "react-colorful";
|
||||||
import { Collection } from "@prisma/client";
|
import { Collection } from "@prisma/client";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
|
import Modal from "../Modal";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
modalId: string;
|
|
||||||
isOpen: boolean;
|
|
||||||
onClose: Function;
|
onClose: Function;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function NewCollectionModal({
|
export default function NewCollectionModal({ onClose }: Props) {
|
||||||
modalId,
|
|
||||||
isOpen,
|
|
||||||
onClose,
|
|
||||||
}: Props) {
|
|
||||||
const modal = document.getElementById(modalId);
|
|
||||||
|
|
||||||
const initial = {
|
const initial = {
|
||||||
name: "",
|
name: "",
|
||||||
description: "",
|
description: "",
|
||||||
|
@ -29,20 +22,8 @@ export default function NewCollectionModal({
|
||||||
const [collection, setCollection] = useState<Partial<Collection>>(initial);
|
const [collection, setCollection] = useState<Partial<Collection>>(initial);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
modal?.scrollTo(0, 0);
|
|
||||||
|
|
||||||
modal?.addEventListener("close", () => {
|
|
||||||
onClose();
|
|
||||||
});
|
|
||||||
|
|
||||||
setCollection(initial);
|
setCollection(initial);
|
||||||
|
}, []);
|
||||||
return () => {
|
|
||||||
modal?.addEventListener("close", () => {
|
|
||||||
onClose();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}, [isOpen]);
|
|
||||||
|
|
||||||
const [submitLoader, setSubmitLoader] = useState(false);
|
const [submitLoader, setSubmitLoader] = useState(false);
|
||||||
const { addCollection } = useCollectionStore();
|
const { addCollection } = useCollectionStore();
|
||||||
|
@ -64,7 +45,7 @@ export default function NewCollectionModal({
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
toast.success("Created!");
|
toast.success("Created!");
|
||||||
(document.getElementById(modalId) as any).close();
|
onClose();
|
||||||
} else toast.error(response.data as string);
|
} else toast.error(response.data as string);
|
||||||
|
|
||||||
setSubmitLoader(false);
|
setSubmitLoader(false);
|
||||||
|
@ -72,26 +53,7 @@ export default function NewCollectionModal({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<dialog
|
<Modal toggleModal={onClose}>
|
||||||
id={modalId}
|
|
||||||
className="modal backdrop-blur-sm overflow-y-auto p-5"
|
|
||||||
open={isOpen}
|
|
||||||
>
|
|
||||||
<Toaster
|
|
||||||
position="top-center"
|
|
||||||
reverseOrder={false}
|
|
||||||
toastOptions={{
|
|
||||||
className:
|
|
||||||
"border border-sky-100 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div className="modal-box max-h-full overflow-y-visible border border-neutral-content w-11/12 max-w-2xl">
|
|
||||||
<form method="dialog">
|
|
||||||
<button className="btn btn-sm outline-none btn-circle btn-ghost absolute right-3 top-3">
|
|
||||||
✕
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<p className="text-xl mb-5 font-thin">Create a New Collection</p>
|
<p className="text-xl mb-5 font-thin">Create a New Collection</p>
|
||||||
|
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
|
@ -128,9 +90,7 @@ export default function NewCollectionModal({
|
||||||
</div>
|
</div>
|
||||||
<HexColorPicker
|
<HexColorPicker
|
||||||
color={collection.color}
|
color={collection.color}
|
||||||
onChange={(e) =>
|
onChange={(e) => setCollection({ ...collection, color: e })}
|
||||||
setCollection({ ...collection, color: e })
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -157,10 +117,6 @@ export default function NewCollectionModal({
|
||||||
Create Collection
|
Create Collection
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Modal>
|
||||||
<form method="dialog" className="modal-backdrop">
|
|
||||||
<button>close</button>
|
|
||||||
</form>
|
|
||||||
</dialog>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,16 +10,13 @@ import { LinkIncludingShortenedCollectionAndTags } from "@/types/global";
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "next-auth/react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
|
import Modal from "../Modal";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
modalId: string;
|
|
||||||
isOpen: boolean;
|
|
||||||
onClose: Function;
|
onClose: Function;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function NewLinkModal({ modalId, isOpen, onClose }: Props) {
|
export default function NewLinkModal({ onClose }: Props) {
|
||||||
const modal = document.getElementById(modalId);
|
|
||||||
|
|
||||||
const { data } = useSession();
|
const { data } = useSession();
|
||||||
|
|
||||||
const initial = {
|
const initial = {
|
||||||
|
@ -71,7 +68,6 @@ export default function NewLinkModal({ modalId, isOpen, onClose }: Props) {
|
||||||
setResetCollectionSelection(Date.now().toString());
|
setResetCollectionSelection(Date.now().toString());
|
||||||
console.log(link);
|
console.log(link);
|
||||||
|
|
||||||
modal?.scrollTo(0, 0);
|
|
||||||
setOptionsExpanded(false);
|
setOptionsExpanded(false);
|
||||||
if (router.query.id) {
|
if (router.query.id) {
|
||||||
const currentCollection = collections.find(
|
const currentCollection = collections.find(
|
||||||
|
@ -99,17 +95,7 @@ export default function NewLinkModal({ modalId, isOpen, onClose }: Props) {
|
||||||
ownerId: data?.user.id as number,
|
ownerId: data?.user.id as number,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
}, []);
|
||||||
modal?.addEventListener("close", () => {
|
|
||||||
onClose();
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
modal?.addEventListener("close", () => {
|
|
||||||
onClose();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}, [isOpen]);
|
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
if (!submitLoader) {
|
if (!submitLoader) {
|
||||||
|
@ -125,7 +111,7 @@ export default function NewLinkModal({ modalId, isOpen, onClose }: Props) {
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
toast.success(`Created!`);
|
toast.success(`Created!`);
|
||||||
(document?.getElementById(modalId) as any)?.close();
|
onClose();
|
||||||
} else toast.error(response.data as string);
|
} else toast.error(response.data as string);
|
||||||
|
|
||||||
setSubmitLoader(false);
|
setSubmitLoader(false);
|
||||||
|
@ -135,26 +121,7 @@ export default function NewLinkModal({ modalId, isOpen, onClose }: Props) {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<dialog
|
<Modal toggleModal={onClose}>
|
||||||
id={modalId}
|
|
||||||
className="modal backdrop-blur-sm overflow-y-auto p-5"
|
|
||||||
open={isOpen}
|
|
||||||
>
|
|
||||||
<Toaster
|
|
||||||
position="top-center"
|
|
||||||
reverseOrder={false}
|
|
||||||
toastOptions={{
|
|
||||||
className:
|
|
||||||
"border border-sky-100 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div className="modal-box max-h-full overflow-y-visible border border-neutral-content w-11/12 max-w-2xl">
|
|
||||||
<form method="dialog">
|
|
||||||
<button className="btn btn-sm outline-none btn-circle btn-ghost absolute right-3 top-3">
|
|
||||||
✕
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<p className="text-xl mb-5 font-thin">Create a New Link</p>
|
<p className="text-xl mb-5 font-thin">Create a New Link</p>
|
||||||
<div className="grid grid-flow-row-dense sm:grid-cols-5 gap-3">
|
<div className="grid grid-flow-row-dense sm:grid-cols-5 gap-3">
|
||||||
<div className="sm:col-span-3 col-span-5">
|
<div className="sm:col-span-3 col-span-5">
|
||||||
|
@ -232,10 +199,6 @@ export default function NewLinkModal({ modalId, isOpen, onClose }: Props) {
|
||||||
Create Link
|
Create Link
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Modal>
|
||||||
<form method="dialog" className="modal-backdrop">
|
|
||||||
<button>close</button>
|
|
||||||
</form>
|
|
||||||
</dialog>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,16 +162,12 @@ export default function Navbar() {
|
||||||
</ClickAwayHandler>
|
</ClickAwayHandler>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
<NewLinkModal
|
{newLinkModal ? (
|
||||||
isOpen={newLinkModal}
|
<NewLinkModal onClose={() => setNewLinkModal(false)} />
|
||||||
onClose={() => setNewLinkModal(false)}
|
) : undefined}
|
||||||
modalId="new-link-modal-nav"
|
{newCollectionModal ? (
|
||||||
/>
|
<NewCollectionModal onClose={() => setNewCollectionModal(false)} />
|
||||||
<NewCollectionModal
|
) : undefined}
|
||||||
isOpen={newCollectionModal}
|
|
||||||
onClose={() => setNewCollectionModal(false)}
|
|
||||||
modalId="new-collection-modal-nav"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,9 @@ export default function NoLinksFound({ text }: Props) {
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<NewLinkModal
|
{newLinkModal ? (
|
||||||
isOpen={newLinkModal}
|
<NewLinkModal onClose={() => setNewLinkModal(false)} />
|
||||||
onClose={() => setNewLinkModal(false)}
|
) : undefined}
|
||||||
modalId="new-link-modal"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,24 +233,24 @@ export default function Index() {
|
||||||
</div>
|
</div>
|
||||||
{activeCollection ? (
|
{activeCollection ? (
|
||||||
<>
|
<>
|
||||||
|
{editCollectionModal ? (
|
||||||
<EditCollectionModal
|
<EditCollectionModal
|
||||||
isOpen={editCollectionModal}
|
|
||||||
onClose={() => setEditCollectionModal(false)}
|
onClose={() => setEditCollectionModal(false)}
|
||||||
modalId={"edit-collection-modal" + activeCollection.id}
|
|
||||||
activeCollection={activeCollection}
|
activeCollection={activeCollection}
|
||||||
/>
|
/>
|
||||||
|
) : undefined}
|
||||||
|
{editCollectionSharingModal ? (
|
||||||
<EditCollectionSharingModal
|
<EditCollectionSharingModal
|
||||||
isOpen={editCollectionSharingModal}
|
|
||||||
onClose={() => setEditCollectionSharingModal(false)}
|
onClose={() => setEditCollectionSharingModal(false)}
|
||||||
modalId={"edit-collection-sharing-modal" + activeCollection.id}
|
|
||||||
activeCollection={activeCollection}
|
activeCollection={activeCollection}
|
||||||
/>
|
/>
|
||||||
|
) : undefined}
|
||||||
|
{deleteCollectionModal ? (
|
||||||
<DeleteCollectionModal
|
<DeleteCollectionModal
|
||||||
isOpen={deleteCollectionModal}
|
|
||||||
onClose={() => setDeleteCollectionModal(false)}
|
onClose={() => setDeleteCollectionModal(false)}
|
||||||
modalId={"delete-collection-modal" + activeCollection.id}
|
|
||||||
activeCollection={activeCollection}
|
activeCollection={activeCollection}
|
||||||
/>
|
/>
|
||||||
|
) : undefined}
|
||||||
</>
|
</>
|
||||||
) : undefined}
|
) : undefined}
|
||||||
</MainLayout>
|
</MainLayout>
|
||||||
|
|
|
@ -126,11 +126,9 @@ export default function Collections() {
|
||||||
</>
|
</>
|
||||||
) : undefined}
|
) : undefined}
|
||||||
</div>
|
</div>
|
||||||
<NewCollectionModal
|
{newCollectionModal ? (
|
||||||
isOpen={newCollectionModal}
|
<NewCollectionModal onClose={() => setNewCollectionModal(false)} />
|
||||||
onClose={() => setNewCollectionModal(false)}
|
) : undefined}
|
||||||
modalId="new-collection-modal-1"
|
|
||||||
/>
|
|
||||||
</MainLayout>
|
</MainLayout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,11 +315,9 @@ export default function Dashboard() {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<NewLinkModal
|
{newLinkModal ? (
|
||||||
isOpen={newLinkModal}
|
<NewLinkModal onClose={() => setNewLinkModal(false)} />
|
||||||
onClose={() => setNewLinkModal(false)}
|
) : undefined}
|
||||||
modalId="new-link-modal"
|
|
||||||
/>
|
|
||||||
</MainLayout>
|
</MainLayout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,12 +228,12 @@ export default function PublicCollections() {
|
||||||
</p> */}
|
</p> */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{editCollectionSharingModal ? (
|
||||||
<EditCollectionSharingModal
|
<EditCollectionSharingModal
|
||||||
isOpen={editCollectionSharingModal}
|
|
||||||
onClose={() => setEditCollectionSharingModal(false)}
|
onClose={() => setEditCollectionSharingModal(false)}
|
||||||
modalId={"edit-collection-sharing-modal" + collection.id}
|
|
||||||
activeCollection={collection}
|
activeCollection={collection}
|
||||||
/>
|
/>
|
||||||
|
) : undefined}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<></>
|
||||||
|
|
|
@ -69,7 +69,7 @@ body {
|
||||||
}
|
}
|
||||||
|
|
||||||
.slide-up {
|
.slide-up {
|
||||||
animation: slide-up-animation 70ms;
|
animation: slide-up-animation 200ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
.slide-down {
|
.slide-down {
|
||||||
|
|
Ŝarĝante…
Reference in New Issue