Skip to content

Commit

Permalink
mobile sidebar redirection and cleanup of the sidebar redundant eleme…
Browse files Browse the repository at this point in the history
…nts (#1502)

* mobile sidebar redirection working

* review changes

* removed unused imports

* sidebar fixes
  • Loading branch information
mithunhegde-egov authored Oct 21, 2024
1 parent 299e6f5 commit a428e40
Showing 1 changed file with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { Loader } from "@egovernments/digit-ui-components";
import React, { useState, Fragment,useEffect } from "react";
import { useTranslation } from "react-i18next";
import { useHistory } from "react-router-dom";
import SideBarMenu from "../../../config/sidebar-menu";
import ChangeCity from "../../ChangeCity";
import { defaultImage } from "../../utils";
import StaticCitizenSideBar from "./StaticCitizenSideBar";
import { MobileSidebar } from "@egovernments/digit-ui-components";
import { LogoutIcon } from "@egovernments/digit-ui-react-components";


const Profile = ({ info, stateName, t }) => {
const [profilePic, setProfilePic] = React.useState(null);
Expand Down Expand Up @@ -75,6 +76,7 @@ export const CitizenSideBar = ({
islinkDataLoading,
userProfile,
}) => {
const isMultiRootTenant=Digit.Utils.getMultiRootTenant()
const { data: storeData, isFetched } = Digit.Hooks.useStore.getInitData();
const selectedLanguage = Digit.StoreData.getCurrentLanguage();
const [profilePic, setProfilePic] = useState(null);
Expand Down Expand Up @@ -163,14 +165,31 @@ export const CitizenSideBar = ({
};

const handleModuleClick = (url) => {
url[0]==="/" ?
let updatedUrl=null;
if(Digit.Utils.getMultiRootTenant()){
updatedUrl=isEmployee?url.replace("/sandbox-ui/employee", `/sandbox-ui/${tenantId}/employee`): url.replace("/sandbox-ui/citizen", `/sandbox-ui/${tenantId}/citizen`);
history.push(updatedUrl);
toggleSidebar();
}
else{
url[0]==="/" ?
history.push(`/${window?.contextPath}/${isEmployee ? "employee" : "citizen"}${url}`) :
history.push(`/${window?.contextPath}/${isEmployee ? "employee" : "citizen"}/${url}`);
toggleSidebar();
toggleSidebar();
}



}

const redirectToLoginPage = () => {
history.push(`/${window?.contextPath}/citizen/login`);
if(isEmployee){
history.push(`/${window?.contextPath}/employee/user/language-selection`);
}
else{
history.push(`/${window?.contextPath}/citizen/login`);

}
closeSidebar();
};

Expand All @@ -179,8 +198,18 @@ export const CitizenSideBar = ({
}

let menuItems = [
...SideBarMenu(t, closeSidebar, redirectToLoginPage, isEmployee),
{
id: "login-btn",
element: "LOGIN",
text: t("CORE_COMMON_LOGIN"),
icon: <LogoutIcon className="icon" />,
populators: {
onClick: redirectToLoginPage,
},
},
];


let profileItem;
if (isFetched && user && user.access_token) {
profileItem = (
Expand Down Expand Up @@ -300,7 +329,13 @@ export const CitizenSideBar = ({
icon: item?.icon ? item?.icon : undefined
}));

const city = t(`TENANT_TENANTS_${stringReplaceAll(Digit.SessionStorage.get("Employee.tenantId"), ".", "_")?.toUpperCase()}`)
let city="";
if(Digit.Utils.getMultiRootTenant()){
city = t(`TENANT_TENANTS_${tenantId}`)
}
else{
city = t(`TENANT_TENANTS_${stringReplaceAll(Digit.SessionStorage.get("Employee.tenantId"), ".", "_")?.toUpperCase()}`)
}
const goToHome= () => {
if(isEmployee){
history.push(`/${window?.contextPath}/employee`);
Expand Down

0 comments on commit a428e40

Please sign in to comment.