From 25ce5a1ee16553f791a1a729811e55ff9a8ea668 Mon Sep 17 00:00:00 2001 From: Bram Borggreve Date: Mon, 18 Nov 2024 14:48:45 -0500 Subject: [PATCH] fix: make sure to show communities without roles --- .../src/lib/api-community-data.service.ts | 4 -- .../ui/src/lib/community-ui-list-item.tsx | 65 ++++++++++--------- .../ui/src/lib/community-ui-list.tsx | 20 +++--- 3 files changed, 44 insertions(+), 45 deletions(-) diff --git a/libs/api/community/data-access/src/lib/api-community-data.service.ts b/libs/api/community/data-access/src/lib/api-community-data.service.ts index 38f6f4ba..7d193888 100644 --- a/libs/api/community/data-access/src/lib/api-community-data.service.ts +++ b/libs/api/community/data-access/src/lib/api-community-data.service.ts @@ -40,10 +40,6 @@ export class ApiCommunityDataService { async getCommunities(username: string) { return this.core.data.community.findMany({ - where: { - // Ensure that the role has at least one condition - roles: { some: { conditions: { some: {} } } }, - }, include: { roles: { // Ensure that the role has at least one condition diff --git a/libs/web/community/ui/src/lib/community-ui-list-item.tsx b/libs/web/community/ui/src/lib/community-ui-list-item.tsx index eba68e9e..c90bc4c7 100644 --- a/libs/web/community/ui/src/lib/community-ui-list-item.tsx +++ b/libs/web/community/ui/src/lib/community-ui-list-item.tsx @@ -18,6 +18,7 @@ export function CommunityUiListItem({ to?: string username: string }) { + const hasRoles = item.roles?.length const rolesAssigned = item.roles?.filter((role) => role.member) const rolesAvailable = item.roles?.filter((role) => !role.member) return ( @@ -31,36 +32,40 @@ export function CommunityUiListItem({ - }> - - - Roles assigned to {isAuthUser ? 'you' : username} - - {rolesAssigned?.length ? ( - - ) : ( - - )} - - - - Available roles - - {rolesAvailable?.length ? ( - - ) : ( - - )} - - + {hasRoles ? ( + }> + + + Roles assigned to {isAuthUser ? 'you' : username} + + {rolesAssigned?.length ? ( + + ) : ( + + )} + + + + Available roles + + {rolesAvailable?.length ? ( + + ) : ( + + )} + + + ) : ( + + )} ) diff --git a/libs/web/community/ui/src/lib/community-ui-list.tsx b/libs/web/community/ui/src/lib/community-ui-list.tsx index cdc20d86..f3ff92af 100644 --- a/libs/web/community/ui/src/lib/community-ui-list.tsx +++ b/libs/web/community/ui/src/lib/community-ui-list.tsx @@ -16,17 +16,15 @@ export function CommunityUiList({ } return ( - {communities - .filter((item) => item.roles?.length) - .map((item) => ( - - ))} + {communities.map((item) => ( + + ))} ) }