From 85296022522c08933bb097538573ae774bfdf298 Mon Sep 17 00:00:00 2001 From: daniel31x13 Date: Tue, 19 Dec 2023 18:28:48 -0500 Subject: [PATCH] improved user experience --- components/Modal.tsx | 2 +- .../EditCollectionSharingModal.tsx | 307 ++++++++++++------ 2 files changed, 217 insertions(+), 92 deletions(-) diff --git a/components/Modal.tsx b/components/Modal.tsx index baabcbe..ac74785 100644 --- a/components/Modal.tsx +++ b/components/Modal.tsx @@ -23,7 +23,7 @@ export default function Modal({ toggleModal, className, children }: Props) { className || "" }`} > -
+
} className="absolute top-4 right-3 btn btn-sm outline-none btn-circle btn-ghost z-10" diff --git a/components/ModalContent/EditCollectionSharingModal.tsx b/components/ModalContent/EditCollectionSharingModal.tsx index 1aea017..de769c0 100644 --- a/components/ModalContent/EditCollectionSharingModal.tsx +++ b/components/ModalContent/EditCollectionSharingModal.tsx @@ -186,129 +186,254 @@ export default function EditCollectionSharingModal({ {collection?.members[0]?.user && ( <> -
+
-

{collectionOwner.name}

-

@{collectionOwner.username}

+

+ {collectionOwner.name} +

+

+ @{collectionOwner.username} +

-

- Owner -

+

Owner

+
+ {collection.members .sort((a, b) => (a.userId as number) - (b.userId as number)) .map((e, i) => { + const roleLabel = + e.canCreate && e.canUpdate && e.canDelete + ? "Admin" + : e.canCreate && !e.canUpdate && !e.canDelete + ? "Contributor" + : !e.canCreate && !e.canUpdate && !e.canDelete + ? "Viewer" + : undefined; + return ( -
-
-
-
- + <> +
+
+
+
+ +
+
+

+ {e.user.name} +

+

+ @{e.user.username} +

+
-
-

{e.user.name}

-

@{e.user.username}

-
-
-
- {permissions === true && ( - { - const updatedMembers = collection.members.filter( - (member) => { - return member.user.username !== e.user.username; - } - ); - setCollection({ - ...collection, - members: updatedMembers, - }); - }} - /> - )} - -
+
{permissions === true ? ( - +
+
+ {roleLabel} + +
+
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
) : (

- { - (e.canCreate && e.canUpdate && e.canDelete) - ? "Admin" - : (e.canCreate) - ? 'Contributor' - : 'Viewer' - } + {roleLabel}

)} + + {permissions === true && ( + { + const updatedMembers = + collection.members.filter((member) => { + return ( + member.user.username !== e.user.username + ); + }); + setCollection({ + ...collection, + members: updatedMembers, + }); + }} + /> + )}
-
+
+ ); - }) - } + })}
)}