Skip to content

Commit

Permalink
fix for handling when the logged in user doesn't have any groups
Browse files Browse the repository at this point in the history
  • Loading branch information
ganning127 authored Aug 28, 2024
1 parent c4e1347 commit 1db0b0d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions veda-auth-portal/src/components/Groups/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const Groups = () => {
if (!userGroups.isPending && userGroups.data) {
const lowerSearch = search.toLowerCase();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
filteredGroups = userGroups.data.groups.filter((group: any) => {
filteredGroups = userGroups?.data?.groups?.filter((group: any) => {
return group.name?.toLowerCase().includes(lowerSearch)
|| group.description?.toLowerCase().includes(lowerSearch)
|| group.owner_id?.toLowerCase().includes(lowerSearch);
Expand Down Expand Up @@ -94,7 +94,7 @@ export const Groups = () => {
<Tbody>
{
// eslint-disable-next-line @typescript-eslint/no-explicit-any
filteredGroups.map((group: any) => {
filteredGroups?.map((group: any) => {
return (
<Tr key={group.id}>
<Td>
Expand All @@ -121,10 +121,19 @@ export const Groups = () => {
})
}
</Tbody>
{
((!filteredGroups) || (!filteredGroups.data) || (filteredGroups.data?.groups?.length === 0)) && (
<Tbody>
<Tr>
<Td colSpan={5} textAlign='center'>
No groups found
</Td>
</Tr>
</Tbody>
)
}
</Table>
</TableContainer>


</NavContainer>
)
}

0 comments on commit 1db0b0d

Please sign in to comment.