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

Application Management Updated #1359

Merged
merged 24 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
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
4 changes: 2 additions & 2 deletions micro-ui/web/micro-ui-internals/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"@egovernments/digit-ui-module-dss": "1.8.1",
"@egovernments/digit-ui-module-core": "1.8.2-beta.18",
"@egovernments/digit-ui-module-common": "1.8.0",
"@egovernments/digit-ui-module-hrms": "1.8.0",
"@egovernments/digit-ui-module-hrms": "1.8.1-beta.1",
"@egovernments/digit-ui-module-utilities": "1.0.1-beta.39",
"@egovernments/digit-ui-module-open-payment":"0.0.1",
"@egovernments/digit-ui-module-engagement": "1.5.20",
"@egovernments/digit-ui-components": "0.0.2-beta.31",
"@egovernments/digit-ui-react-components": "1.8.2-beta.12",
"@egovernments/digit-ui-react-components": "1.8.2-beta.13",
"@egovernments/digit-ui-module-sandbox": "0.0.1",
"http-proxy-middleware": "^1.0.5",
"react": "17.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
<div id="root"></div>
</body>

</html>
</html>
4 changes: 3 additions & 1 deletion micro-ui/web/micro-ui-internals/example/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ const initDigitUI = () => {
const pathname = window.location.pathname;
const context = window?.globalConfigs?.getConfig("CONTEXT_PATH");
const start = pathname.indexOf(context) + context.length + 1;
const end = pathname.indexOf("employee");
const employeeIndex = pathname.indexOf("employee");
const citizenIndex = pathname.indexOf("citizen");
const end = (employeeIndex !== -1) ? employeeIndex : (citizenIndex !== -1) ? citizenIndex : -1;
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
const tenant = end > start ? pathname.substring(start, end).replace(/\/$/, "") : "";
window.contextPath = window?.globalConfigs?.getConfig("CONTEXT_PATH") + `${tenant ? `/${tenant}` : ""}` || "digit-ui";
window.globalPath = window?.globalConfigs?.getConfig("CONTEXT_PATH") || "digit-ui";
Expand Down
3 changes: 2 additions & 1 deletion micro-ui/web/micro-ui-internals/example/src/setupProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ module.exports = function (app) {
"/project-factory",
"/project-factory/v1/data/_autoGenerateBoundaryCode",
"/billing-service/bill/v2/_fetchbill",
"/tenant-management"
"/tenant-management",
"/default-data-handler"
].forEach((location) => app.use(location, createProxy));
["/pb-egov-assets"].forEach((location) => app.use(location, assetsProxy));
["/mdms-v2/v2/_create"].forEach((location) => app.use(location, mdmsProxy));
Expand Down
4 changes: 2 additions & 2 deletions micro-ui/web/micro-ui-internals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dev:example": "cd example && yarn start",
"dev:core": "cd packages/modules/core && yarn start",
"devD:dss": "cd packages/modules/dss && yarn start",
"devD:hrms": "cd packages/modules/hrms && yarn start",
"dev:hrms": "cd packages/modules/hrms && yarn start",
"devD:common": "cd packages/modules/common && yarn start",
"devD:utilities": "cd packages/modules/utilities && yarn start",
"dev:workbench": "cd packages/modules/workbench && yarn start",
Expand Down Expand Up @@ -73,7 +73,7 @@
"lodash": "4.17.21",
"microbundle-crl": "0.13.11",
"@egovernments/digit-ui-components": "0.0.2-beta.31",
"@egovernments/digit-ui-react-components": "1.8.2-beta.12",
"@egovernments/digit-ui-react-components": "1.8.2-beta.13",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-hook-form": "6.15.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ input[type="number"] {
.citizen-form-wrapper {
width: calc(100% - 219px);
display: flex;
justify-content: center;
justify-content: flex-start;
margin-top: 1rem;
padding-left: 16px;
padding-right: 16px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
align-self: flex-start;
margin-bottom: 3rem;
font-size: 14px;
margin-top: -2.5rem;
margin-top: -0.5rem;
color: #505a5f;
font-family: "Roboto";
}
Expand Down Expand Up @@ -240,7 +240,7 @@
margin-top: 0.5rem;
}
.sandbox-url-footer {
margin-top: -1.5rem;
margin-top: 0.5rem;
}
.digit-button-primary {
width: 100%;
Expand All @@ -254,3 +254,82 @@
color: #00703c !important;
}
}
.sandbox-url-wrapper {
display: flex;
width: 100%;
.digit-text-input-field.urlInputText {
}
.digit-button-secondary.large.copyButton {
width: 30%;
padding: 0;
}
}

.setupMasterSetupActionBar {
margin-top: 2.5rem;
margin-bottom: -1rem;
margin-left: -1rem;
margin-right: -1rem;
z-index: 1000;
box-shadow: 0 -0.063rem 0.125rem 0 rgba(0, 0, 0, 0.14902);
padding: 1.5rem;
display: flex;
flex-direction: row-reverse;
}
.digit-employee-card.sandboxSetupMasterInfo {
.h1.headerFlex {
display: flex;
gap: 1rem;
align-items: center;
}
.digit-card-header.subHeader {
font-size: 1.5rem;
font-weight: 700;
color: unset !important;
}
}
.digit-card-header.setupMaster-subheading {
font-size: 1.5rem;
color: unset !important;
margin-left: 1.5rem;
}
.digit-popup-wrapper.masterHandlerPopup {
.digit-popup-header {
.header-close-container {
.digit-popup-close {
display: none !important;
}
}
}
}
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
.digit-topbar-ulb {
.state {
width: 80px;
height: 19px;
}
}
.digit-popup-footer.masterHandlerPopUpFooter {
.digit-popup-footer-buttons {
margin-left: unset;
width: 100%;
justify-content: center;
}
}
.main.center-container.citizen-home-container {
z-index: 100;
justify-content: flex-start;
}
.SideBarStatic {
z-index: 10;
height: 100vh;
}
.citizen-home-footer {
position: absolute;
bottom: 0;
}
.citizen-form-wrapper {
justify-content: flex-start;
.citizen-card-input.citizen-card-input--front {
margin-bottom: 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const useStore = ({ stateCode, moduleCode, language ,modulePrefix = "rain
export const useInitStore = (stateCode, enabledModules,modulePrefix = "rainmaker" ) => {
const { isLoading, error, isError, data } = useQuery(
["initStore", stateCode, enabledModules,modulePrefix],
() => StoreService.digitInitData(stateCode, enabledModules ,modulePrefix),
() => StoreService.digitInitData(stateCode, enabledModules ,modulePrefix, window?.globalPath === "sandbox-ui" ? true : false),
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should use this flag MULTI_ROOT_TENANT ,
introduce a util function to interact with Globalconfig
that util function to be called everywhere

var multiRootTenant = true;
@NabeelAyubee

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

{
staleTime: Infinity,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const mdmsV1Path = window?.globalConfigs?.getConfig("MDMS_V1_CONTEXT_PATH") || "
const mdmsV2Path = window?.globalConfigs?.getConfig("MDMS_V2_CONTEXT_PATH") || "mdms-v2";
const Urls = {
MDMS: `/${mdmsV1Path}/v1/_search`,
TenantConfigSearch: `/tenant-management/tenant/config/_search`,
WorkFlow: `/egov-workflow-v2/egov-wf/businessservice/_search`,
WorkFlowProcessSearch: `/egov-workflow-v2/egov-wf/process/_search`,
localization: `/localization/messages/v1/_search`,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ServiceRequest } from "../atoms/Utils/Request";
import Urls from "../atoms/urls";

export const TenantConfigSearch = {
tenant: (stateCode) =>
ServiceRequest({
serviceName: "tenantConfigSearch",
url: Urls.TenantConfigSearch,
data: {},
useCache: true,
params: { code: stateCode },
}),
};
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { LocalizationService } from "../../elements/Localization/service";
import { MdmsService } from "../../elements/MDMS";
import { Storage } from "../../atoms/Utils/Storage";
import { ApiCacheService } from "../../atoms/ApiCacheService";
import { TenantConfigSearch } from "../../elements/TenantConfigService";

const getImgUrl = (url, fallbackUrl) => {
if (!url && fallbackUrl) {
Expand Down Expand Up @@ -30,7 +31,7 @@ const addLogo = (id, url, fallbackUrl = "") => {

const renderTenantLogos = (stateInfo, tenants) => {
addLogo(stateInfo.code, stateInfo.logoUrl);
tenants.forEach((tenant) => {
tenants?.forEach((tenant) => {
addLogo(tenant.code, tenant.logoId, stateInfo.logoUrl);
});
};
Expand All @@ -54,21 +55,25 @@ export const StoreService = {
});
return await Promise.all(allBoundries);
},
digitInitData: async (stateCode, enabledModules , modulePrefix) => {
digitInitData: async (stateCode, enabledModules, modulePrefix, tenantConfigFetch) => {
const { MdmsRes } = await MdmsService.init(stateCode);
const stateInfo = MdmsRes["common-masters"]?.StateInfo?.[0]||{};
const uiHomePage = MdmsRes["common-masters"]?.uiHomePage?.[0]||{};
const stateInfo = MdmsRes["common-masters"]?.StateInfo?.[0] || {};
const uiHomePage = MdmsRes["common-masters"]?.uiHomePage?.[0] || {};
const tenantConfigs = await TenantConfigSearch.tenant(stateCode);
const tenantConfigSearch = tenantConfigs?.tenantConfigs ? tenantConfigs?.tenantConfigs : null;
const localities = {};
const revenue_localities = {};
const initData = {
languages: stateInfo.hasLocalisation ? stateInfo.languages : [{ label: "ENGLISH", value: Digit.Utils.getDefaultLanguage() }],
stateInfo: {
code: stateInfo.code,
name: stateInfo.name,
logoUrl: stateInfo.logoUrl,
statelogo: stateInfo.statelogo,
logoUrlWhite: stateInfo.logoUrlWhite,
bannerUrl: stateInfo.bannerUrl,
code: tenantConfigFetch ? tenantConfigSearch?.[0]?.code : stateInfo.code,
Copy link
Collaborator

Choose a reason for hiding this comment

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

put these contents inside a function, which gets triggered only during
MULTI_ROOT_TENANT

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

name: tenantConfigFetch ? tenantConfigSearch?.[0]?.name : stateInfo.name,
logoUrl: tenantConfigFetch ? tenantConfigSearch?.[0]?.documents?.find((item) => item.type === "logoUrl")?.url : stateInfo.logoUrl,
statelogo: tenantConfigFetch ? tenantConfigSearch?.[0]?.documents?.find((item) => item.type === "statelogo")?.url : stateInfo.statelogo,
logoUrlWhite: tenantConfigFetch
? tenantConfigSearch?.[0]?.documents?.find((item) => item.type === "logoUrlWhite")?.url
: stateInfo.logoUrlWhite,
bannerUrl: tenantConfigFetch ? tenantConfigSearch?.[0]?.documents?.find((item) => item.type === "bannerUrl")?.url : stateInfo.bannerUrl,
},
localizationModules: stateInfo.localizationModules,
modules: MdmsRes?.tenant?.citymodule?.filter((module) => module?.active)?.filter((module) => enabledModules?.includes(module?.code))?.sort((x,y)=>x?.order-y?.order)|| [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@ export const ULBService = {
*/
getCurrentTenantId: () => {
// TODO: change when setter is done.

const user = UserService.getUser();
if (user?.extraRoleInfo) {
const isDsoRoute = Digit.Utils.detectDsoRoute(window.location.pathname);
if (isDsoRoute) {
return user.extraRoleInfo?.tenantId;
}
}

//TODO: fix tenant id from userinfo
const tenantId =
user?.info?.type === "EMPLOYEE" && user?.info?.tenantId ? user?.info?.tenantId : window?.globalConfigs.getConfig("STATE_LEVEL_TENANT_ID");
const tenantId = user?.info?.type === "EMPLOYEE" && user?.info?.tenantId ? user?.info?.tenantId : window?.globalConfigs.getConfig("STATE_LEVEL_TENANT_ID");
return tenantId;
},
/**
Expand All @@ -56,7 +57,9 @@ export const ULBService = {
const pathname = window.location.pathname;
const context = window?.globalConfigs?.getConfig("CONTEXT_PATH");
const start = pathname.indexOf(context) + context.length + 1;
const end = pathname.indexOf("employee");
const employeeIndex = pathname.indexOf("employee");
const citizenIndex = pathname.indexOf("citizen");
const end = (employeeIndex !== -1) ? employeeIndex : (citizenIndex !== -1) ? citizenIndex : -1;
const tenant = end > start ? pathname.substring(start, end).replace(/\/$/, "") : "";

return isMultiRootTenant && tenant ? tenant : window?.globalConfigs?.getConfig("STATE_LEVEL_TENANT_ID");
Expand All @@ -74,7 +77,7 @@ export const ULBService = {
getCurrentUlb: () => {
const initData = StoreService.getInitData();
const tenantId = ULBService.getCurrentTenantId();
return initData?.tenants?.find((tenant) => tenant?.code === tenantId)||ULBService.getStateId();
return initData?.tenants?.find((tenant) => tenant?.code === tenantId) || ULBService.getStateId();
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
}
/**
* Custom method to get citizen's current selected city
Expand All @@ -88,12 +91,12 @@ export const ULBService = {
*
* @returns {String}
*/,
getCitizenCurrentTenant: (selectedCity=false) => {
const homeCity=Digit.SessionStorage.get("CITIZEN.COMMON.HOME.CITY")?.code;
if(selectedCity){
getCitizenCurrentTenant: (selectedCity = false) => {
const homeCity = Digit.SessionStorage.get("CITIZEN.COMMON.HOME.CITY")?.code;
if (selectedCity) {
return homeCity;
}
return homeCity|| Digit.UserService.getUser()?.info?.permanentCity || ULBService.getStateId();
return homeCity || Digit.UserService.getUser()?.info?.permanentCity || ULBService.getStateId();
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
},
/**
* Custom method to get all ulb's which the loggedin employee has access to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ const pgrAccess = () => {
const userInfo = Digit.UserService.getUser();
const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code);
const pgrRoles = ["PGR_LME", "PGR-ADMIN", "CSR", "CEMP", "FEMP", "DGRO", "ULB Operator", "GRO", "GO", "RO", "GA"];

if (window.globalPath === "sandbox-ui") {
pgrRoles.push("SUPERUSER");
}
const PGR_ACCESS = userRoles?.filter((role) => pgrRoles.includes(role));

return PGR_ACCESS?.length > 0;
Expand Down Expand Up @@ -303,7 +305,7 @@ const receiptsAccess = () => {
const RECEIPTS_ACCESS = userRoles?.filter((role) => receiptsRoles?.includes(role));
return RECEIPTS_ACCESS?.length > 0;
};
const hrmsRoles = ["HRMS_ADMIN"];
const hrmsRoles = ["HRMS_ADMIN","SUPERUSER"];
const hrmsAccess = () => {
const userInfo = Digit.UserService.getUser();
const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"@egovernments/digit-ui-components": "0.0.2-beta.31",
"@egovernments/digit-ui-react-components": "1.8.2-beta.12",
"@egovernments/digit-ui-react-components": "1.8.2-beta.13",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-i18next": "11.16.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const componentsToRegister = {
ChangeCity,
ChangeLanguage,
PrivacyComponent,
OtpComponent
OtpComponent,
};

export const initCoreComponents = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ const Redircter = () => {
class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { error: null, errorStack: null, hasError: false };
this.state = { error: null, errorStack: null, hasError: false, module: null, action: null, info: null };
}

static getDerivedStateFromError(error) {
// Update state so the next render will show the fallback UI.
return { error: error?.message, hasError: true, errorStack: error?.stack };
return { error: error?.message, hasError: true, errorStack: error?.stack, module: error?.module, action: error?.action, info: error?.info };
}

componentDidCatch(error, errorInfo) {
Expand All @@ -40,7 +40,7 @@ class ErrorBoundary extends React.Component {
return (
<div className="error-boundary">
<Redircter />
<ErrorComponent initData={this.props.initData} />
<ErrorComponent initData={this.props.initData} errorData={this.state} />

{/* <summary>Something went wrong</summary>
<details style={{ whiteSpace: "pre-wrap" }}>
Expand Down
Loading