From 21fd9ef41618d1eec8187da4d56792ac67552fe6 Mon Sep 17 00:00:00 2001 From: Sohit Kumar <79898903+sohitkumar@users.noreply.github.com> Date: Tue, 1 Oct 2024 13:52:39 +0530 Subject: [PATCH 1/6] (add) : window.env_vars --- src/App.js | 2 +- src/common/constants/UrlConstants.js | 6 ++--- src/common/utils/utils.js | 4 ++-- .../src/common/sections/second/Section.js | 22 +++++++++---------- src/features/routes.js | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/App.js b/src/App.js index 8a8664d5..4d0a74ec 100755 --- a/src/App.js +++ b/src/App.js @@ -9,7 +9,7 @@ import featureRoutes from "features/routes"; import { Helmet } from "react-helmet"; import { getMetaData } from "common/utils/MetaData"; const MainComponent = lazy(() => Promise.resolve({ default: featureRoutes })); -const instance = process.env.REACT_APP_INSTANCE; +const instance = window?.ENV_VARS?.REACT_APP_INSTANCE || process.env.REACT_APP_INSTANCE; function App() { const { title, description, faviconImage } = getMetaData(instance); diff --git a/src/common/constants/UrlConstants.js b/src/common/constants/UrlConstants.js index 9b145005..d715dcfe 100644 --- a/src/common/constants/UrlConstants.js +++ b/src/common/constants/UrlConstants.js @@ -1,11 +1,11 @@ const UrlConstant = { base_url: - Window?.ENV_VARS?.REACT_APP_BASEURL || process.env.REACT_APP_BASEURL, + window?.ENV_VARS?.REACT_APP_BASEURL || process.env.REACT_APP_BASEURL, base_url_without_slash: - Window?.ENV_VARS?.REACT_APP_BASEURL_without_slash || + window?.ENV_VARS?.REACT_APP_BASEURL_without_slash || process.env.REACT_APP_BASEURL_without_slash, view_data_connector: - Window?.ENV_VARS?.REACT_APP_BASEURL_without_slash_view_data || + window?.ENV_VARS?.REACT_APP_BASEURL_without_slash_view_data || process.env.REACT_APP_BASEURL_without_slash_view_data, login: "accounts/login/", diff --git a/src/common/utils/utils.js b/src/common/utils/utils.js index 672ebd48..b872f136 100644 --- a/src/common/utils/utils.js +++ b/src/common/utils/utils.js @@ -472,12 +472,12 @@ export function findType() { export function checkProjectFor(name) { console.log( - Window?.ENV_VARS?.REACT_APP_PROJECT_FOR, + window?.ENV_VARS?.REACT_APP_PROJECT_FOR, process.env.REACT_APP_PROJECT_FOR, name ); if ( - (Window?.ENV_VARS?.REACT_APP_PROJECT_FOR || + (window?.ENV_VARS?.REACT_APP_PROJECT_FOR === name || process.env.REACT_APP_PROJECT_FOR) === name ) { return true; diff --git a/src/features/default/src/common/sections/second/Section.js b/src/features/default/src/common/sections/second/Section.js index 80756597..e6143a86 100644 --- a/src/features/default/src/common/sections/second/Section.js +++ b/src/features/default/src/common/sections/second/Section.js @@ -37,11 +37,11 @@ const Section = () => { { marginRight: mobile || tablet || miniLaptop ? "" : "28px", }} > - {process.env.REACT_APP_INSTANCE === "EADP" || - process.env.REACT_APP_INSTANCE === "KADP" || - process.env.REACT_APP_INSTANCE === "ETH_MOA" + {window?.ENV_VARS?.REACT_APP_INSTANCE === "EADP" || process.env.REACT_APP_INSTANCE === "EADP" || + window?.ENV_VARS?.REACT_APP_INSTANCE === "KADP" || process.env.REACT_APP_INSTANCE === "KADP" || + window?.ENV_VARS?.REACT_APP_INSTANCE === "ETH_MOA" || process.env.REACT_APP_INSTANCE === "ETH_MOA" ? "With Data sharing great things will happen" - : process.env.REACT_APP_INSTANCE === "VISTAAR" + : window?.ENV_VARS?.REACT_APP_INSTANCE === "VISTAAR" || process.env.REACT_APP_INSTANCE === "VISTAAR" ? "With Content distribution great things will happen" : "With Content distribution great things will happen"} @@ -113,14 +113,14 @@ const Section = () => { } ${GlobalStyles.highlighted_text_in_home}`} > - {process.env.REACT_APP_INSTANCE === "EADP" || - process.env.REACT_APP_INSTANCE === "KADP" || - process.env.REACT_APP_INSTANCE === "ETH_MOA" + {window?.ENV_VARS?.REACT_APP_INSTANCE === "EADP" || process.env.REACT_APP_INSTANCE === "EADP" || + window?.ENV_VARS?.REACT_APP_INSTANCE === "KADP" || process.env.REACT_APP_INSTANCE === "KADP" || + window?.ENV_VARS?.REACT_APP_INSTANCE === "ETH_MOA" || process.env.REACT_APP_INSTANCE === "ETH_MOA" ? `We enable seamless data sharing, breaks down silos, and builds trust among organisations. The platform consolidates fragmented data, standardises data, and aids in better data categorization, enhancing its usability and value.` - : process.env.REACT_APP_INSTANCE === "VISTAAR" + : (window?.ENV_VARS?.REACT_APP_INSTANCE === "VISTAAR" || process.env.REACT_APP_INSTANCE === "VISTAAR") ? `We enable seamless content upload of all formats, and builds unified approach. The platforms integrate all data or content across all states and departments and effectively delivers to front line diff --git a/src/features/routes.js b/src/features/routes.js index 46c1291d..96816a7f 100644 --- a/src/features/routes.js +++ b/src/features/routes.js @@ -3,7 +3,7 @@ try { featureRoutes = require(`./default/src/routes/index`).default; } catch (error) { console.warn( - `Failed to load routes for ${process.env.REACT_APP_INSTANCE}`, + `Failed to load routes for ${window?.ENV_VARS?.REACT_APP_INSTANCE || process.env.REACT_APP_INSTANCE}`, error ); featureRoutes = () =>
Feature set not supported or not found
; From 1a91c47b4d5b311c6e3541f8607644c4e83120f6 Mon Sep 17 00:00:00 2001 From: sohitkumar Date: Tue, 1 Oct 2024 14:07:00 +0530 Subject: [PATCH 2/6] (add) : env_vars --- src/App.js | 5 +- .../ParticipantForm/ParticipantFormNew.js | 3 +- .../src/Components/Datasets_New/AddDataSet.js | 3 +- .../src/Components/Datasets_New/DataSets.js | 3 +- src/features/default/src/Layout/Datahub.js | 25 ++++++---- .../default/src/Layout/GuestRoutes.js | 12 +++-- .../src/Views/Dashboard/DashboardNew.js | 11 +++-- .../src/Views/GuestUser/GuestUserHomeNew.js | 16 ++++--- .../ParticipantAndCoStewardDetailsNew.js | 3 +- .../src/common/sections/second/Section.js | 47 ++++++++++++------- .../src/common/sections/third/Section.js | 12 +++-- src/features/routes.js | 4 +- 12 files changed, 91 insertions(+), 53 deletions(-) diff --git a/src/App.js b/src/App.js index 4d0a74ec..54b128d7 100755 --- a/src/App.js +++ b/src/App.js @@ -9,10 +9,13 @@ import featureRoutes from "features/routes"; import { Helmet } from "react-helmet"; import { getMetaData } from "common/utils/MetaData"; const MainComponent = lazy(() => Promise.resolve({ default: featureRoutes })); -const instance = window?.ENV_VARS?.REACT_APP_INSTANCE || process.env.REACT_APP_INSTANCE; +const instance = + window?.ENV_VARS?.REACT_APP_INSTANCE || process.env.REACT_APP_INSTANCE; function App() { const { title, description, faviconImage } = getMetaData(instance); + console.log(window?.ENV_VARS); + console.log(process.env); return ( diff --git a/src/features/default/src/Components/Card/ParticipantForm/ParticipantFormNew.js b/src/features/default/src/Components/Card/ParticipantForm/ParticipantFormNew.js index 6701af29..daab23b8 100644 --- a/src/features/default/src/Components/Card/ParticipantForm/ParticipantFormNew.js +++ b/src/features/default/src/Components/Card/ParticipantForm/ParticipantFormNew.js @@ -36,7 +36,8 @@ import MuiPhoneNumber from "material-ui-phone-number"; import { isPhoneValid } from "../../NewOnboarding/utils"; import { getCountryData, getDefaultCountryCode } from "common/utils/utils"; const ParticipantFormNew = (props) => { - const instance = process.env.REACT_APP_INSTANCE; + const instance = + window?.ENV_VARS?.REACT_APP_INSTANCE || process.env.REACT_APP_INSTANCE; const { callToast, callLoader } = useContext(FarmStackContext); const { title, isEditModeOn, userType } = props; diff --git a/src/features/default/src/Components/Datasets_New/AddDataSet.js b/src/features/default/src/Components/Datasets_New/AddDataSet.js index 2eff690b..670c636e 100644 --- a/src/features/default/src/Components/Datasets_New/AddDataSet.js +++ b/src/features/default/src/Components/Datasets_New/AddDataSet.js @@ -53,7 +53,8 @@ function TabPanel(props) { } const AddDataSet = (props) => { - const instance = process.env.REACT_APP_INSTANCE; + const instance = + window?.ENV_VARS?.REACT_APP_INSTANCE || process.env.REACT_APP_INSTANCE; const history = useHistory(); const { callLoader, callToast } = useContext(FarmStackContext); const theme = useTheme(); diff --git a/src/features/default/src/Components/Datasets_New/DataSets.js b/src/features/default/src/Components/Datasets_New/DataSets.js index 9dfbd195..c7a68e19 100644 --- a/src/features/default/src/Components/Datasets_New/DataSets.js +++ b/src/features/default/src/Components/Datasets_New/DataSets.js @@ -60,7 +60,8 @@ const cardSx = { }; const DataSets = (props) => { const { user, breadcrumbFromRoute } = props; - const instance = process.env.REACT_APP_INSTANCE; + const instance = + window?.ENV_VARS?.REACT_APP_INSTANCE || process.env.REACT_APP_INSTANCE; const { callLoader, callToast } = useContext(FarmStackContext); const history = useHistory(); diff --git a/src/features/default/src/Layout/Datahub.js b/src/features/default/src/Layout/Datahub.js index 95fd923c..748b2b40 100644 --- a/src/features/default/src/Layout/Datahub.js +++ b/src/features/default/src/Layout/Datahub.js @@ -211,9 +211,10 @@ function Datahub(props) { {globalConfig?.navBar === "DEFAULT" ? ( ) : null} - {(globalConfig?.navBar === "EADP" || globalConfig?.navBar === "ETH_MOA") && ( - -)} + {(globalConfig?.navBar === "EADP" || + globalConfig?.navBar === "ETH_MOA") && ( + + )} {globalConfig?.navBar === "VISTAAR" && ( )} @@ -242,7 +243,8 @@ function Datahub(props) { component={ParticipantsAndCoStewardDetailsNew} /> )} - {process.env.REACT_APP_INSTANCE !== "KADP" && + {(window?.ENV_VARS?.REACT_APP_INSTANCE !== "KADP" || + process.env.REACT_APP_INSTANCE !== "KADP") && isCoStewardsEnabled && ( )} - {process.env.REACT_APP_INSTANCE !== "KADP" && + {(window?.ENV_VARS?.REACT_APP_INSTANCE !== "KADP" || + process.env.REACT_APP_INSTANCE !== "KADP") && isCoStewardsEnabled && ( )} - {process.env.REACT_APP_INSTANCE !== "KADP" && + {(window?.ENV_VARS?.REACT_APP_INSTANCE !== "KADP" || + process.env.REACT_APP_INSTANCE !== "KADP") && isCoStewardsEnabled && ( )} - {process.env.REACT_APP_INSTANCE !== "KADP" && + {(window?.ENV_VARS?.REACT_APP_INSTANCE !== "KADP" || + process.env.REACT_APP_INSTANCE !== "KADP") && isCoStewardsEnabled && ( )} - {(globalConfig?.footer === "EADP" || globalConfig?.footer === "ETH_MOA") && !footerMatch && ( - - )} + {(globalConfig?.footer === "EADP" || + globalConfig?.footer === "ETH_MOA") && + !footerMatch && } {globalConfig?.footer === "KADP" && ( )} diff --git a/src/features/default/src/Layout/GuestRoutes.js b/src/features/default/src/Layout/GuestRoutes.js index 7d760a30..74c7bd7e 100644 --- a/src/features/default/src/Layout/GuestRoutes.js +++ b/src/features/default/src/Layout/GuestRoutes.js @@ -138,7 +138,8 @@ const GuestRoutes = () => { } /> ) : null} - {(globalConfig?.navBar === "EADP" || globalConfig?.navBar === "ETH_MOA") && ( + {(globalConfig?.navBar === "EADP" || + globalConfig?.navBar === "ETH_MOA") && ( { path="/home/participants/view/:id" component={GuestUserParticipantsDetails} /> - {process.env.REACT_APP_INSTANCE !== "KADP" && ( + {(window?.ENV_VARS?.REACT_APP_INSTANCE !== "KADP" || + process.env.REACT_APP_INSTANCE !== "KADP") && ( )} - {process.env.REACT_APP_INSTANCE !== "KADP" && ( + {(window?.ENV_VARS?.REACT_APP_INSTANCE !== "KADP" || + process.env.REACT_APP_INSTANCE !== "KADP") && ( { } /> )} - {(globalConfig?.footer === "EADP" || globalConfig?.footer === "ETH_MOA") && ( + {(globalConfig?.footer === "EADP" || + globalConfig?.footer === "ETH_MOA") && ( - {process.env.REACT_APP_INSTANCE === "ETH_MOA" && ( + {(window?.ENV_VARS?.REACT_APP_INSTANCE === "ETH_MOA" || + process.env.REACT_APP_INSTANCE === "ETH_MOA") && (