Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

side bar #1384

Merged
merged 4 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused import.

The update function imported from the lodash library is not used anywhere in the file. Please remove this import to avoid unnecessary bundle size and potential performance issues.

Apply this diff to remove the unused import:

-import { update } from "lodash";
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use stateid not current tenant id

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldnt do this within sandbox app
history ,push is recommended

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mithunhegde-egov the logic should be written for else section this section is working fine

} 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