From 6619525fd145a8720980a55062551f28963a5061 Mon Sep 17 00:00:00 2001 From: Maxime Same-kotto Date: Thu, 4 Jan 2024 22:31:32 +0100 Subject: [PATCH] FIX: admin get for admin in the nested route of admin --- src/view/Admin/OrganisationUsers.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/view/Admin/OrganisationUsers.js b/src/view/Admin/OrganisationUsers.js index 7949f2e..74b152f 100644 --- a/src/view/Admin/OrganisationUsers.js +++ b/src/view/Admin/OrganisationUsers.js @@ -9,10 +9,12 @@ import { API_URL } from "../../config/API"; import UsersTable from "../../component/UserTable"; import { AuthContext } from "../../services/AuthProvider"; import { AdminSideBar } from "../../component/admin/SideBar"; +import { useParams } from "react-router-dom"; export default function AdminOrganisationUsers() { const theme = useTheme(); const [IsSetup, setIsSetup] = useState(false); + const params = useParams(); const [users, setUsers] = useState([]); const [organisations, setOrganisations] = useState([]); @@ -22,7 +24,7 @@ export default function AdminOrganisationUsers() { useEffect(() => { const init = async () => { try { - let userRes = await axios.get(`${API_URL}/api/accounts/admin`, { + let userRes = await axios.get(`${API_URL}/api/organisations/${params.id}`, { headers: { Authorization: `Bearer ${token}`, }, @@ -30,8 +32,9 @@ export default function AdminOrganisationUsers() { setUsers(userRes.data); } catch (e) { - logout(); - window.location.replace("/"); + console.log(e) + //logout(); + //window.location.replace("/"); } let orgRes = await axios.get(`${API_URL}/api/organisations`, {