From 55018931e6ae8fa9c1ae428a11f0e91b7fafa1b4 Mon Sep 17 00:00:00 2001 From: bnguyen-bcgsc Date: Mon, 25 Mar 2024 13:09:59 -0700 Subject: [PATCH] - DEVSU-2246 - Fix issue where number of reports was not showing in projects - Implement admin rights to Number of Reports and Number of User columns - General linting --- app/views/ProjectsView/columnDefs.ts | 2 +- app/views/ProjectsView/index.tsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/ProjectsView/columnDefs.ts b/app/views/ProjectsView/columnDefs.ts index 27f545089..6fb48d931 100644 --- a/app/views/ProjectsView/columnDefs.ts +++ b/app/views/ProjectsView/columnDefs.ts @@ -16,7 +16,7 @@ const readOnlyColDefs = [ }, { headerName: 'Number of reports', - valueGetter: ({ data }) => data?.reports?.length, + valueGetter: ({ data }) => Number(data?.reportCount), }, { headerName: 'Number of users', diff --git a/app/views/ProjectsView/index.tsx b/app/views/ProjectsView/index.tsx index eb4de48db..35808f7c7 100644 --- a/app/views/ProjectsView/index.tsx +++ b/app/views/ProjectsView/index.tsx @@ -26,14 +26,14 @@ const Projects = (): JSX.Element => { useEffect(() => { const getData = async () => { - const projectsResp = await api.get('/project?admin=true').request(); + const projectsResp = await api.get(`/project?admin=${adminAccess}`).request(); setProjects(projectsResp); setLoading(false); }; getData(); - }, []); + }, [adminAccess]); const handleEditStart = (rowData) => { setShowDialog(true); @@ -41,7 +41,7 @@ const Projects = (): JSX.Element => { }; const handleDelete = useCallback(async ({ ident }) => { - // eslint-disable-next-line no-restricted-globals + // eslint-disable-next-line no-restricted-globals, no-alert if (confirm('Are you sure you want to remove this project?')) { await api.del(`/project/${ident}`, {}).request(); const newProjects = projects.filter((project) => project.ident !== ident);