Skip to content

Commit

Permalink
side bar
Browse files Browse the repository at this point in the history
  • Loading branch information
mithunhegde-egov committed Sep 12, 2024
1 parent 815f9fa commit 6530440
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import React, { useRef, useEffect, useState } from "react";
import { Sidebar, Loader } from "@egovernments/digit-ui-components";
import { useTranslation } from "react-i18next";
import { useHistory } from "react-router-dom";
import { update } from "lodash";

const DIGIT_UI_CONTEXTS = ["digit-ui", "works-ui", "workbench-ui", "health-ui", "sanitation-ui", "core-ui", "mgramseva-web", "sandbox-ui"];

const EmployeeSideBar = () => {
const { isLoading, data } = Digit.Hooks.useAccessControl();
const isMultiRootTenant = Digit.Utils.getMultiRootTenant();
const { t } = useTranslation();
const history = useHistory();
const tenantId = Digit.ULBService.getCurrentTenantId();

function extractLeftIcon(data = {}) {
for (const key in data) {
Expand Down Expand Up @@ -83,22 +86,29 @@ const EmployeeSideBar = () => {
const navigateToRespectiveURL = (history = {}, url = "") => {
if (url == "/") {
return;
}
}
if (url?.indexOf(`/${window?.contextPath}`) === -1) {
const hostUrl = window.location.origin;
const updatedURL = DIGIT_UI_CONTEXTS?.every((e) => url?.indexOf(`/${e}`) === -1) ? hostUrl + "/employee/" + url : hostUrl + url;
window.location.href = updatedURL;
let updatedUrl=null;
if(isMultiRootTenant){
url=url.replace("/sandbox-ui/employee", `/sandbox-ui/${tenantId}/employee`);
updatedUrl = hostUrl + url;
}
else{
updatedUrl = DIGIT_UI_CONTEXTS?.every((e) => url?.indexOf(`/${e}`) === -1) ? hostUrl + "/employee/" + url : hostUrl + url;
}
window.location.href = updatedUrl;
} else {
history.push(url);
}
}
};

const onItemSelect = ({ item, index, parentIndex }) => {
if (item?.navigationUrl) {
navigateToRespectiveURL(history, item?.navigationUrl);
} else {
return;
}
}
};

function transformData(data) {
Expand Down Expand Up @@ -148,4 +158,4 @@ const EmployeeSideBar = () => {
);
};

export default EmployeeSideBar;
export default EmployeeSideBar;
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ function Jurisdiction({
});
const getSubTenants = () => TenantMngmtSearch?.filter((e) => e.code === Digit.ULBService.getCurrentTenantId()) || [];
const subTenantList = getSubTenants();

useEffect(() => {
useEffect(() => {
if (Digit.Utils.getMultiRootTenant()) {
selectboundary(subTenantList);
}
Expand Down Expand Up @@ -278,7 +277,7 @@ function Jurisdiction({
isMandatory={true}
option={gethierarchylistdata(hierarchylist) || []}
select={selectHierarchy}
optionKey="code"
optionKey={Digit.Utils.getMultiRootTenant() ? "code" : "i18nKey"}
t={t}
/>
</LabelFieldPair>
Expand Down

0 comments on commit 6530440

Please sign in to comment.