From 271231120ce16b8852a27a74f7bc6b8cd2213769 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 29 May 2023 02:44:44 +0330 Subject: [PATCH] improvements --- components/CollectionCard.tsx | 4 ---- components/LinkList.tsx | 2 +- components/Modal/Collection/CollectionInfo.tsx | 17 ++--------------- components/Modal/Collection/TeamManagement.tsx | 10 +++++----- components/Navbar.tsx | 9 ++++----- .../controllers/collections/updateCollection.ts | 1 + .../migration.sql | 1 + prisma/schema.prisma | 1 + 8 files changed, 15 insertions(+), 30 deletions(-) rename prisma/migrations/{20230523040650_init => 20230528224940_init}/migration.sql (98%) diff --git a/components/CollectionCard.tsx b/components/CollectionCard.tsx index 6508cff..5efac28 100644 --- a/components/CollectionCard.tsx +++ b/components/CollectionCard.tsx @@ -96,7 +96,6 @@ export default function ({ - {expandDropdown ? ( ) : null} - {editCollectionModal ? ( ) : null} - {collectionMembersModal ? ( ) : null} - {deleteCollectionModal ? ( { const target = e.target as HTMLElement; diff --git a/components/Modal/Collection/CollectionInfo.tsx b/components/Modal/Collection/CollectionInfo.tsx index 145517f..158e9a5 100644 --- a/components/Modal/Collection/CollectionInfo.tsx +++ b/components/Modal/Collection/CollectionInfo.tsx @@ -5,23 +5,10 @@ import React, { useState } from "react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { - faClose, - faPenToSquare, - faPlus, - faTrashCan, - faUser, - faUserPlus, -} from "@fortawesome/free-solid-svg-icons"; +import { faPenToSquare, faPlus } from "@fortawesome/free-solid-svg-icons"; import useCollectionStore from "@/store/collections"; -import { CollectionIncludingMembers, Member } from "@/types/global"; -import { useSession } from "next-auth/react"; -import Modal from "@/components/Modal"; -import DeleteCollection from "@/components/Modal/Collection/DeleteCollection"; +import { CollectionIncludingMembers } from "@/types/global"; import RequiredBadge from "../../RequiredBadge"; -import addMemberToCollection from "@/lib/client/addMemberToCollection"; -import ImageWithFallback from "../../ImageWithFallback"; -import Checkbox from "../../Checkbox"; type Props = { toggleCollectionModal: Function; diff --git a/components/Modal/Collection/TeamManagement.tsx b/components/Modal/Collection/TeamManagement.tsx index df399fa..d370b57 100644 --- a/components/Modal/Collection/TeamManagement.tsx +++ b/components/Modal/Collection/TeamManagement.tsx @@ -30,8 +30,6 @@ export default function TeamManagement({ const [collection, setCollection] = useState(activeCollection); - const [isPublic, setIsPublic] = useState(false); - const currentURL = new URL(document.URL); const publicCollectionURL = `${currentURL.origin}/public/collections/${collection.id}`; @@ -87,15 +85,17 @@ export default function TeamManagement({ setIsPublic(!isPublic)} + state={collection.isPublic} + onClick={() => + setCollection({ ...collection, isPublic: !collection.isPublic }) + } />

This will let Anyone to view this collection.

- {isPublic ? ( + {collection.isPublic ? (

Public Link (Click to copy)

setProfileDropdown(!profileDropdown)} id="profile-dropdown" > {account.profilePic ? ( ) : ( )} -
+

{account.name} diff --git a/lib/api/controllers/collections/updateCollection.ts b/lib/api/controllers/collections/updateCollection.ts index 1e6f436..1d51130 100644 --- a/lib/api/controllers/collections/updateCollection.ts +++ b/lib/api/controllers/collections/updateCollection.ts @@ -35,6 +35,7 @@ export default async function ( data: { name: collection.name, description: collection.description, + isPublic: collection.isPublic, members: { create: collection.members.map((e) => ({ user: { connect: { email: e.user.email } }, diff --git a/prisma/migrations/20230523040650_init/migration.sql b/prisma/migrations/20230528224940_init/migration.sql similarity index 98% rename from prisma/migrations/20230523040650_init/migration.sql rename to prisma/migrations/20230528224940_init/migration.sql index 351f017..f317c9c 100644 --- a/prisma/migrations/20230523040650_init/migration.sql +++ b/prisma/migrations/20230528224940_init/migration.sql @@ -16,6 +16,7 @@ CREATE TABLE "Collection" ( "id" SERIAL NOT NULL, "name" TEXT NOT NULL, "description" TEXT NOT NULL DEFAULT '', + "isPublic" BOOLEAN NOT NULL DEFAULT false, "ownerId" INTEGER NOT NULL, "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, diff --git a/prisma/schema.prisma b/prisma/schema.prisma index f80505e..10f14df 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -29,6 +29,7 @@ model Collection { id Int @id @default(autoincrement()) name String description String @default("") + isPublic Boolean @default(false) owner User @relation(fields: [ownerId], references: [id]) ownerId Int members UsersAndCollections[]