From cdf0a1eee768c10228dd6c6fca7cb237b6c2dab1 Mon Sep 17 00:00:00 2001 From: Hari Krishna Date: Mon, 4 Mar 2024 12:28:21 +0000 Subject: [PATCH] added list of sub orgs --- frontend/src/views/Admin.jsx | 112 +++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/frontend/src/views/Admin.jsx b/frontend/src/views/Admin.jsx index f653bd2c..e6dc8bc0 100755 --- a/frontend/src/views/Admin.jsx +++ b/frontend/src/views/Admin.jsx @@ -1102,6 +1102,40 @@ If you're interested, please let me know a time that works for you, or set up a toast("Error getting current organization"); }); }; +const handleGetSubOrgs = (orgId) => { + + if (serverside !== true && window.location.search !== undefined && window.location.search !== null) { + const urlSearchParams = new URLSearchParams(window.location.search); + const params = Object.fromEntries(urlSearchParams.entries()); + const foundorgid = params["org_id"]; + if (foundorgid !== undefined && foundorgid !== null) { + orgId = foundorgid; + } + } + + if (orgId.length === 0) { + toast("Organization ID not defined. Please contact us on https://shuffler.io if this persists logout."); + return; + } + + fetch(`${globalUrl}/api/v1/subOrgs/${orgId}`, { + method: "GET", + credentials: "include", + headers: { + "Content-Type": "application/json", + }, + }) + .then((response) => { + return response.json(); + }) + .then((responseJson) => { + setSubOrgs(responseJson); + }) + .catch((error) => { + console.log("Error getting sub orgs: ", error); + toast("Error getting sub organizations"); + }); +}; const inviteUser = (data) => { //console.log("INPUT: ", data); @@ -4678,6 +4712,84 @@ If you're interested, please let me know a time that works for you, or set up a backgroundColor: theme.palette.inputColor, }} /> + +{subOrgs.length > 0 ? ( + +
+

Your Sub Organizations of the Current Organization

+
+ + + + + + + + + + + + {subOrgs.map((data, index) => { + const imagesize = 40; + const imageStyle = { + width: imagesize, + height: imagesize, + pointerEvents: "none", + }; + const image = + data.image === "" ? ( + {data.name} + ) : ( + {data.name} + ); + + var bgColor = "#27292d"; + if (index % 2 === 0) { + bgColor = "#1f2023"; + } + + return ( + + + + + + + ); + })} + + + + +
+) : ( + + No Sub-Organizations available. + +)} +
+

All Tenants

+
+ +