From 392d98f0908c5c2b186c989f4f7fdd59b13e9ca3 Mon Sep 17 00:00:00 2001 From: daniel31x13 Date: Tue, 6 Feb 2024 07:46:57 -0500 Subject: [PATCH] bug fixed --- components/CollectionSelection.tsx | 3 +-- .../collections/collectionId/getCollectionById.ts | 1 - .../collections/collectionId/updateCollectionById.ts | 1 - lib/api/controllers/collections/getCollections.ts | 1 - pages/collections/[id].tsx | 6 ++---- types/global.ts | 1 - 6 files changed, 3 insertions(+), 10 deletions(-) diff --git a/components/CollectionSelection.tsx b/components/CollectionSelection.tsx index e9aa758..cb66b14 100644 --- a/components/CollectionSelection.tsx +++ b/components/CollectionSelection.tsx @@ -55,8 +55,7 @@ const CollectionItem = ({ active: string; collections: CollectionIncludingMembersAndLinkCount[]; }) => { - const hasChildren = - collection.subCollections && collection.subCollections.length > 0; + const hasChildren = collections.some((e) => e.parentId === collection.id); const router = useRouter(); diff --git a/lib/api/controllers/collections/collectionId/getCollectionById.ts b/lib/api/controllers/collections/collectionId/getCollectionById.ts index e508399..46478b8 100644 --- a/lib/api/controllers/collections/collectionId/getCollectionById.ts +++ b/lib/api/controllers/collections/collectionId/getCollectionById.ts @@ -16,7 +16,6 @@ export default async function getCollectionById( _count: { select: { links: true }, }, - subCollections: true, members: { include: { user: { diff --git a/lib/api/controllers/collections/collectionId/updateCollectionById.ts b/lib/api/controllers/collections/collectionId/updateCollectionById.ts index ea75002..e300662 100644 --- a/lib/api/controllers/collections/collectionId/updateCollectionById.ts +++ b/lib/api/controllers/collections/collectionId/updateCollectionById.ts @@ -75,7 +75,6 @@ export default async function updateCollection( _count: { select: { links: true }, }, - subCollections: true, members: { include: { user: { diff --git a/lib/api/controllers/collections/getCollections.ts b/lib/api/controllers/collections/getCollections.ts index 9f75d31..3742163 100644 --- a/lib/api/controllers/collections/getCollections.ts +++ b/lib/api/controllers/collections/getCollections.ts @@ -12,7 +12,6 @@ export default async function getCollection(userId: number) { _count: { select: { links: true }, }, - subCollections: true, members: { include: { user: { diff --git a/pages/collections/[id].tsx b/pages/collections/[id].tsx index be55933..6c23d40 100644 --- a/pages/collections/[id].tsx +++ b/pages/collections/[id].tsx @@ -124,8 +124,7 @@ export default function Index() {

- {activeCollection.subCollections && - activeCollection.subCollections.length > 0 ? ( + {collections.some((e) => e.parentId === activeCollection.id) ? (
View Sub-Collections @@ -260,8 +259,7 @@ export default function Index() {

{activeCollection?.description}

) : undefined} - {/* {activeCollection?.subCollections && - activeCollection?.subCollections.length > 0 ? ( + {/* {collections.some((e) => e.parentId === activeCollection.id) ? (
Sub-Collections
diff --git a/types/global.ts b/types/global.ts index a872516..3c8de79 100644 --- a/types/global.ts +++ b/types/global.ts @@ -35,7 +35,6 @@ export interface CollectionIncludingMembersAndLinkCount createdAt?: string; _count?: { links: number }; members: Member[]; - subCollections: CollectionIncludingMembersAndLinkCount[]; } export interface TagIncludingLinkCount extends Tag {