From 1c706ebf829871fc2f360a46380f992d29061b55 Mon Sep 17 00:00:00 2001 From: johnnadeluy Date: Thu, 18 Apr 2024 15:47:55 +0200 Subject: [PATCH] Add fallback for Team members with no team --- src/pages/TeamMembers/TeamMembers.tsx | 2 +- src/services/teamMembers.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/TeamMembers/TeamMembers.tsx b/src/pages/TeamMembers/TeamMembers.tsx index 3108e2be..d64c32d3 100644 --- a/src/pages/TeamMembers/TeamMembers.tsx +++ b/src/pages/TeamMembers/TeamMembers.tsx @@ -44,7 +44,7 @@ const TeamMembers = () => { text={section_name} /> ), - team: teams.length, + team: teams?.length ?? 0, epost: principal_name, data_admin: groups.filter((group) => group.uniform_name.endsWith('data-admins')).length, seksjon: section_name, // Makes section name searchable and sortable in table by including the field diff --git a/src/services/teamMembers.ts b/src/services/teamMembers.ts index 3d02cd7e..5f06b0f0 100644 --- a/src/services/teamMembers.ts +++ b/src/services/teamMembers.ts @@ -92,7 +92,7 @@ export const fetchManagedUsersManagers = async (principalName: string): Promise< } delete prepData._embedded - return prepData + return { ...prepData, teams: prepData.teams?.length ? prepData.teams : [] } }) ) @@ -138,7 +138,7 @@ export const fetchAllUsers = async (): Promise => { ...user._embedded, } delete prepUserData._embedded - return prepUserData + return { ...prepUserData, teams: prepUserData.teams?.length ? prepUserData.teams : [] } }) delete prepData._embedded