From 8863f4a167f3ced22622fc0989a47ae5dd774b1d Mon Sep 17 00:00:00 2001 From: nickviola Date: Tue, 12 Mar 2024 20:38:22 -0500 Subject: [PATCH 1/5] Modify getOrgsURL based on user type to filter in frontend/src/components/OrganizationList/OrganizationList.tsx --- .../src/components/OrganizationList/OrganizationList.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/OrganizationList/OrganizationList.tsx b/frontend/src/components/OrganizationList/OrganizationList.tsx index f958bfcf..2af8d919 100644 --- a/frontend/src/components/OrganizationList/OrganizationList.tsx +++ b/frontend/src/components/OrganizationList/OrganizationList.tsx @@ -16,7 +16,14 @@ export const OrganizationList: React.FC<{ const [organizations, setOrganizations] = useState([]); const [dialogOpen, setDialogOpen] = useState(false); const history = useHistory(); - const getOrgsURL = `/v2/organizations/`; + const regionId = user?.regionId; + let getOrgsURL: any; + + if (user?.userType == 'regionalAdmin') { + getOrgsURL = `/organizations/regionId/${regionId}`; + } else { + getOrgsURL = `/v2/organizations/`; + } const orgCols: GridColDef[] = [ { field: 'name', headerName: 'Organization', minWidth: 100, flex: 2 }, From 51c8b87c706d740c47aa9c1c4e17d5b15f941332 Mon Sep 17 00:00:00 2001 From: nickviola Date: Wed, 13 Mar 2024 13:56:58 -0500 Subject: [PATCH 2/5] Modify getOrgsURL based on user type to filter in frontend/src/components/OrganizationList/OrganizationList.tsx --- .../OrganizationList/OrganizationList.tsx | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/OrganizationList/OrganizationList.tsx b/frontend/src/components/OrganizationList/OrganizationList.tsx index 2af8d919..5b838b96 100644 --- a/frontend/src/components/OrganizationList/OrganizationList.tsx +++ b/frontend/src/components/OrganizationList/OrganizationList.tsx @@ -1,4 +1,4 @@ -import React, { useState, useCallback } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; import EditNoteOutlinedIcon from '@mui/icons-material/EditNoteOutlined'; import { Organization } from 'types'; import { Alert, Box, Button, IconButton, Grid } from '@mui/material'; @@ -17,13 +17,16 @@ export const OrganizationList: React.FC<{ const [dialogOpen, setDialogOpen] = useState(false); const history = useHistory(); const regionId = user?.regionId; - let getOrgsURL: any; - if (user?.userType == 'regionalAdmin') { - getOrgsURL = `/organizations/regionId/${regionId}`; - } else { - getOrgsURL = `/v2/organizations/`; - } + const getOrgsUrl = () => { + if (user?.userType == 'regionalAdmin') { + return `/organizations/regionId/${regionId}`; + } else { + return `/v2/organizations/`; + } + }; + + const orgsUrl = getOrgsUrl() as String; const orgCols: GridColDef[] = [ { field: 'name', headerName: 'Organization', minWidth: 100, flex: 2 }, @@ -69,7 +72,7 @@ export const OrganizationList: React.FC<{ const fetchOrganizations = useCallback(async () => { try { - const rows = await apiGet(getOrgsURL); + const rows = await apiGet(orgsURL); // rows.forEach((obj) => { // // obj.userCount = obj.userRoles.length; // obj.tagNames = obj.tags.map((tag) => tag.name); @@ -78,9 +81,9 @@ export const OrganizationList: React.FC<{ } catch (e) { console.error(e); } - }, [apiGet, getOrgsURL]); + }, [apiGet, orgsURL]); - React.useEffect(() => { + useEffect(() => { if (!parent) fetchOrganizations(); else { setOrganizations(parent.children); From 726cf9066fc89e8a97b2c9f04a0380fd55648eed Mon Sep 17 00:00:00 2001 From: nickviola Date: Wed, 13 Mar 2024 14:06:17 -0500 Subject: [PATCH 3/5] Fix typo in getOrgsUrl function calls --- frontend/src/components/OrganizationList/OrganizationList.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/OrganizationList/OrganizationList.tsx b/frontend/src/components/OrganizationList/OrganizationList.tsx index 5b838b96..59c9d057 100644 --- a/frontend/src/components/OrganizationList/OrganizationList.tsx +++ b/frontend/src/components/OrganizationList/OrganizationList.tsx @@ -72,7 +72,7 @@ export const OrganizationList: React.FC<{ const fetchOrganizations = useCallback(async () => { try { - const rows = await apiGet(orgsURL); + const rows = await apiGet(orgsUrl); // rows.forEach((obj) => { // // obj.userCount = obj.userRoles.length; // obj.tagNames = obj.tags.map((tag) => tag.name); @@ -81,7 +81,7 @@ export const OrganizationList: React.FC<{ } catch (e) { console.error(e); } - }, [apiGet, orgsURL]); + }, [apiGet, orgsUrl]); useEffect(() => { if (!parent) fetchOrganizations(); From 3d5be1669d51cb7311321b2a40c20d13c82f00dd Mon Sep 17 00:00:00 2001 From: nickviola Date: Wed, 13 Mar 2024 15:00:42 -0500 Subject: [PATCH 4/5] Fix typo in getOrgsUrl function calls --- frontend/src/components/OrganizationList/OrganizationList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/OrganizationList/OrganizationList.tsx b/frontend/src/components/OrganizationList/OrganizationList.tsx index 59c9d057..9da9a46f 100644 --- a/frontend/src/components/OrganizationList/OrganizationList.tsx +++ b/frontend/src/components/OrganizationList/OrganizationList.tsx @@ -19,7 +19,7 @@ export const OrganizationList: React.FC<{ const regionId = user?.regionId; const getOrgsUrl = () => { - if (user?.userType == 'regionalAdmin') { + if (user?.userType === 'regionalAdmin') { return `/organizations/regionId/${regionId}`; } else { return `/v2/organizations/`; From fd768ea2d47e5ab436bac7c83fdfc8e77c578561 Mon Sep 17 00:00:00 2001 From: nickviola Date: Fri, 15 Mar 2024 11:12:26 -0500 Subject: [PATCH 5/5] Fix typo in string type in OrganizationList.tsx --- frontend/src/components/OrganizationList/OrganizationList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/OrganizationList/OrganizationList.tsx b/frontend/src/components/OrganizationList/OrganizationList.tsx index 9da9a46f..8321f388 100644 --- a/frontend/src/components/OrganizationList/OrganizationList.tsx +++ b/frontend/src/components/OrganizationList/OrganizationList.tsx @@ -26,7 +26,7 @@ export const OrganizationList: React.FC<{ } }; - const orgsUrl = getOrgsUrl() as String; + const orgsUrl = getOrgsUrl() as string; const orgCols: GridColDef[] = [ { field: 'name', headerName: 'Organization', minWidth: 100, flex: 2 },