diff --git a/micro-ui/web/micro-ui-internals/example/package.json b/micro-ui/web/micro-ui-internals/example/package.json index 0d36ca5a625..00cd69f136b 100644 --- a/micro-ui/web/micro-ui-internals/example/package.json +++ b/micro-ui/web/micro-ui-internals/example/package.json @@ -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", diff --git a/micro-ui/web/micro-ui-internals/example/public/index.html b/micro-ui/web/micro-ui-internals/example/public/index.html index 54d67aa1210..44d50910291 100644 --- a/micro-ui/web/micro-ui-internals/example/public/index.html +++ b/micro-ui/web/micro-ui-internals/example/public/index.html @@ -24,4 +24,4 @@
- \ No newline at end of file + diff --git a/micro-ui/web/micro-ui-internals/example/src/index.js b/micro-ui/web/micro-ui-internals/example/src/index.js index 2fe226ec483..abfc8a9170c 100644 --- a/micro-ui/web/micro-ui-internals/example/src/index.js +++ b/micro-ui/web/micro-ui-internals/example/src/index.js @@ -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; 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"; diff --git a/micro-ui/web/micro-ui-internals/example/src/setupProxy.js b/micro-ui/web/micro-ui-internals/example/src/setupProxy.js index 8b80311fdb0..e4d96aefb02 100644 --- a/micro-ui/web/micro-ui-internals/example/src/setupProxy.js +++ b/micro-ui/web/micro-ui-internals/example/src/setupProxy.js @@ -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)); diff --git a/micro-ui/web/micro-ui-internals/package.json b/micro-ui/web/micro-ui-internals/package.json index 2eeabaf59ba..b46933a7627 100644 --- a/micro-ui/web/micro-ui-internals/package.json +++ b/micro-ui/web/micro-ui-internals/package.json @@ -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", @@ -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", diff --git a/micro-ui/web/micro-ui-internals/packages/css/package.json b/micro-ui/web/micro-ui-internals/packages/css/package.json index 941be736930..dad66a98283 100644 --- a/micro-ui/web/micro-ui-internals/packages/css/package.json +++ b/micro-ui/web/micro-ui-internals/packages/css/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-css", - "version": "1.8.2-beta.20", + "version": "1.8.2-beta.21", "license": "MIT", "main": "dist/index.css", "author": "Jagankumar ", diff --git a/micro-ui/web/micro-ui-internals/packages/css/src/index.scss b/micro-ui/web/micro-ui-internals/packages/css/src/index.scss index dc1b9de8341..68c86c61c4e 100644 --- a/micro-ui/web/micro-ui-internals/packages/css/src/index.scss +++ b/micro-ui/web/micro-ui-internals/packages/css/src/index.scss @@ -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; diff --git a/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/sandbox.scss b/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/sandbox.scss index 7345361a20d..54e1c14fcca 100644 --- a/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/sandbox.scss +++ b/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/sandbox.scss @@ -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"; } @@ -240,7 +240,7 @@ margin-top: 0.5rem; } .sandbox-url-footer { - margin-top: -1.5rem; + margin-top: 0.5rem; } .digit-button-primary { width: 100%; @@ -254,3 +254,86 @@ 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; + } + } + } +} +.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-form-wrapper { + justify-content: flex-start; + .citizen-card-input.citizen-card-input--front { + margin-bottom: 0; + } +} +.action-bar-wrap{ + .menu-wrap{ + p{ + margin: 0 !important; + } + } +} \ No newline at end of file diff --git a/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/index.js b/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/index.js index 49c902d937b..9be2ca6ca29 100644 --- a/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/index.js +++ b/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/index.js @@ -89,6 +89,7 @@ import useGetFAQsJSON from "./useGetFAQsJSON"; import useGetHowItWorksJSON from "./useHowItWorksJSON"; import { usePrivacyContext } from "./usePrivacyContext"; import useStaticData from "./useStaticData"; +import { useTenantManagementSearch } from "./useTenantManagementSearch"; @@ -210,7 +211,8 @@ const Hooks = { useStaticData, useDynamicData, useBulkPdfDetails, - useLocation + useLocation, + useTenantManagementSearch }; export default Hooks; diff --git a/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/useTenantManagementSearch.js b/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/useTenantManagementSearch.js new file mode 100644 index 00000000000..ae61bbfb29c --- /dev/null +++ b/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/useTenantManagementSearch.js @@ -0,0 +1,23 @@ +import { useQuery } from "react-query"; + +const tenantManagementSearchService = async ({ stateId, includeSubTenants = true, filter, pagination }) => { + const response = await Digit.CustomService.getResponse({ + url: "/tenant-management/tenant/_search", + body: { + apiOperation: "SEARCH", + }, + params: { + code: stateId, + includeSubTenants: includeSubTenants, + }, + }); + return response?.Tenants; +}; + +export const useTenantManagementSearch = ({ stateId, includeSubTenants = true, filter, pagination, config = {} }) => { + return useQuery( + ["SEARCH_TENANT_MANAGEMENT", stateId, filter, includeSubTenants, pagination], + () => tenantManagementSearchService({ stateId, includeSubTenants, filter, pagination }), + config + ); +}; diff --git a/micro-ui/web/micro-ui-internals/packages/libraries/src/services/atoms/urls.js b/micro-ui/web/micro-ui-internals/packages/libraries/src/services/atoms/urls.js index b14bb453e3d..778ae369ac2 100644 --- a/micro-ui/web/micro-ui-internals/packages/libraries/src/services/atoms/urls.js +++ b/micro-ui/web/micro-ui-internals/packages/libraries/src/services/atoms/urls.js @@ -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`, diff --git a/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/TenantConfigService.js b/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/TenantConfigService.js new file mode 100644 index 00000000000..33e42326452 --- /dev/null +++ b/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/TenantConfigService.js @@ -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 }, + }), +}; diff --git a/micro-ui/web/micro-ui-internals/packages/libraries/src/services/molecules/Store/service.js b/micro-ui/web/micro-ui-internals/packages/libraries/src/services/molecules/Store/service.js index 13016c84380..f3dc0eacb0d 100644 --- a/micro-ui/web/micro-ui-internals/packages/libraries/src/services/molecules/Store/service.js +++ b/micro-ui/web/micro-ui-internals/packages/libraries/src/services/molecules/Store/service.js @@ -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) { @@ -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); }); }; @@ -54,17 +55,38 @@ export const StoreService = { }); return await Promise.all(allBoundries); }, - digitInitData: async (stateCode, enabledModules , modulePrefix) => { + digitInitData: async (stateCode, enabledModules, modulePrefix) => { 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 tenantConfigFetch = Digit.Utils.getMultiRootTenant(); const localities = {}; const revenue_localities = {}; - const initData = { + const fetchTenantConfig = async () => { + const tenantConfigs = await TenantConfigSearch.tenant(stateCode); + const tenantConfigSearch = tenantConfigs?.tenantConfigs ? tenantConfigs?.tenantConfigs : null; + return { + languages: stateInfo.hasLocalisation ? stateInfo.languages : [{ label: "ENGLISH", value: Digit.Utils.getDefaultLanguage() }], + stateInfo: { + code: tenantConfigFetch ? tenantConfigSearch?.[0]?.code : stateInfo.code, + 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)|| [], + uiHomePage: uiHomePage + }; + }; + const initData = tenantConfigFetch ? await fetchTenantConfig() : { languages: stateInfo.hasLocalisation ? stateInfo.languages : [{ label: "ENGLISH", value: Digit.Utils.getDefaultLanguage() }], stateInfo: { code: stateInfo.code, - name: stateInfo.name, + name: stateInfo.name, logoUrl: stateInfo.logoUrl, statelogo: stateInfo.statelogo, logoUrlWhite: stateInfo.logoUrlWhite, @@ -74,8 +96,6 @@ export const StoreService = { modules: MdmsRes?.tenant?.citymodule?.filter((module) => module?.active)?.filter((module) => enabledModules?.includes(module?.code))?.sort((x,y)=>x?.order-y?.order)|| [], uiHomePage: uiHomePage }; - - initData.selectedLanguage = Digit.SessionStorage.get("locale") || initData.languages[0].value; ApiCacheService.saveSetting(MdmsRes["DIGIT-UI"]?.ApiCachingSettings); diff --git a/micro-ui/web/micro-ui-internals/packages/libraries/src/services/molecules/Ulb/index.js b/micro-ui/web/micro-ui-internals/packages/libraries/src/services/molecules/Ulb/index.js index 41d62051594..6335279ea2a 100644 --- a/micro-ui/web/micro-ui-internals/packages/libraries/src/services/molecules/Ulb/index.js +++ b/micro-ui/web/micro-ui-internals/packages/libraries/src/services/molecules/Ulb/index.js @@ -29,6 +29,7 @@ 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); @@ -36,9 +37,9 @@ export const ULBService = { 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; }, /** @@ -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"); @@ -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(); } /** * Custom method to get citizen's current selected city @@ -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(); }, /** * Custom method to get all ulb's which the loggedin employee has access to diff --git a/micro-ui/web/micro-ui-internals/packages/libraries/src/utils/index.js b/micro-ui/web/micro-ui-internals/packages/libraries/src/utils/index.js index 6eef77a4731..30bfa59b010 100644 --- a/micro-ui/web/micro-ui-internals/packages/libraries/src/utils/index.js +++ b/micro-ui/web/micro-ui-internals/packages/libraries/src/utils/index.js @@ -123,6 +123,18 @@ const getStaticMapUrl = (latitude, longitude) => { const getLocaleRegion = () => { return window?.globalConfigs?.getConfig("LOCALE_REGION") || "IN"; }; + +const getMultiRootTenant = () => { + return window?.globalConfigs?.getConfig("MULTI_ROOT_TENANT") || false; +}; + +const getGlobalContext = () => { + return window?.globalConfigs?.getConfig("CONTEXT_PATH") || null; +}; + +const getOTPBasedLogin = () => { + return window?.globalConfigs?.getConfig("OTP_BASED_LOGIN") || false; +}; /** * Custom util to get the default locale * @@ -187,7 +199,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 (Digit.Utils.getMultiRootTenant()) { + pgrRoles.push("SUPERUSER"); + } const PGR_ACCESS = userRoles?.filter((role) => pgrRoles.includes(role)); return PGR_ACCESS?.length > 0; @@ -303,7 +317,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); @@ -311,6 +325,14 @@ const hrmsAccess = () => { return HRMS_ACCESS?.length > 0; }; +const sandboxAccess = () => { + const sandboxRoles = ["SUPERUSER"]; + const userInfo = Digit.UserService.getUser(); + const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code); + const SANDBOX_ACCESS = userRoles?.filter((role) => sandboxRoles?.includes(role)); + return SANDBOX_ACCESS?.length > 0; +}; + const wsAccess = () => { const userInfo = Digit.UserService.getUser(); const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code); @@ -378,5 +400,9 @@ export default { ...privacy, getDefaultLanguage, getLocaleDefault, - getLocaleRegion + getLocaleRegion, + getMultiRootTenant, + getGlobalContext, + getOTPBasedLogin, + sandboxAccess }; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/core/package.json b/micro-ui/web/micro-ui-internals/packages/modules/core/package.json index 21a99fabcfa..8951d95c4c4 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/core/package.json +++ b/micro-ui/web/micro-ui-internals/packages/modules/core/package.json @@ -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", diff --git a/micro-ui/web/micro-ui-internals/packages/modules/core/src/Module.js b/micro-ui/web/micro-ui-internals/packages/modules/core/src/Module.js index d7beef867e3..f9374c23234 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/core/src/Module.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/core/src/Module.js @@ -120,7 +120,7 @@ const componentsToRegister = { ChangeCity, ChangeLanguage, PrivacyComponent, - OtpComponent + OtpComponent, }; export const initCoreComponents = () => { diff --git a/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/ErrorBoundaries.js b/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/ErrorBoundaries.js index 42b619b3c7a..61ff0d99d61 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/ErrorBoundaries.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/ErrorBoundaries.js @@ -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) { @@ -40,7 +40,7 @@ class ErrorBoundary extends React.Component { return (
- + {/* Something went wrong
diff --git a/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/ErrorComponent.js b/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/ErrorComponent.js index de347f17efe..e1cbe998713 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/ErrorComponent.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/ErrorComponent.js @@ -19,11 +19,19 @@ const ErrorConfig = { }, }; +const ModuleBasedErrorConfig = { + sandbox: { + imgUrl: `https://s3.ap-south-1.amazonaws.com/egov-qa-assets/error-image.png`, + infoMessage: "WRONG_TENANT_SIGN_UP", + buttonInfo: "CREATE_TENANT_ERROR_BUTTON", + }, +}; + const ErrorComponent = (props) => { const { type = "error" } = Digit.Hooks.useQueryParams(); - const config = ErrorConfig[type]; + const module = props?.errorData?.module; const { t } = useTranslation(); - + const config = module ? ModuleBasedErrorConfig[module] : ErrorConfig[type]; const stateInfo = props.stateInfo; return ( @@ -33,7 +41,7 @@ const ErrorComponent = (props) => {

{t(config.infoMessage)}

+
{t("SANDBOX_URL_FOOT")}
diff --git a/micro-ui/web/micro-ui-internals/packages/modules/dss/package.json b/micro-ui/web/micro-ui-internals/packages/modules/dss/package.json index 0a0a933c14b..7dad46c7ed2 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/dss/package.json +++ b/micro-ui/web/micro-ui-internals/packages/modules/dss/package.json @@ -18,7 +18,7 @@ "react-router-dom": "5.3.0" }, "dependencies": { - "@egovernments/digit-ui-react-components": "1.8.2-beta.12", + "@egovernments/digit-ui-react-components": "1.8.2-beta.13", "@egovernments/digit-ui-module-utilities":"1.0.1-beta.39", "jsonpath": "^1.1.1", "react": "17.0.2", diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hrms/package.json b/micro-ui/web/micro-ui-internals/packages/modules/hrms/package.json index e9e8e2df20a..e54496b6890 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hrms/package.json +++ b/micro-ui/web/micro-ui-internals/packages/modules/hrms/package.json @@ -15,7 +15,7 @@ "prepublish": "yarn build" }, "dependencies": { - "@egovernments/digit-ui-react-components": "1.5.22", + "@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", diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/Module.js b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/Module.js index 614e1ec816c..a7745f92a14 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/Module.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/Module.js @@ -31,7 +31,7 @@ export const HRMSModule = ({ stateCode, userType, tenants }) => { const { path, url } = useRouteMatch(); if (!Digit.Utils.hrmsAccess()) { return null; - } + } if (userType === "employee") { return ; } else return null; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/InboxFilter.js b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/InboxFilter.js index ded77d1672a..847fd67388d 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/InboxFilter.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/InboxFilter.js @@ -54,7 +54,7 @@ const Filter = ({ searchParams, onFilterChange, onSearch, removeParam, ...props }); useEffect(() => { - if (tenantId.code) { + if (tenantId?.code) { setSearchParams({ ..._searchParams, tenantId: tenantId.code }); } }, [tenantId]); diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/Utils/index.js b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/Utils/index.js index 7f0149bf764..e2440e56001 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/Utils/index.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/Utils/index.js @@ -63,8 +63,8 @@ export const getCityThatUserhasAccess = (cities = []) => { let roleObject = {}; userInfo?.info?.roles.map((roleData) => { roleObject[roleData?.code] = roleObject[roleData?.code] ? [...roleObject[roleData?.code], roleData?.tenantId] : [roleData?.tenantId] }); const tenant = Digit.ULBService.getCurrentTenantId(); - if (roleObject[Digit.Utils?.hrmsRoles?.[0]].includes(Digit.ULBService.getStateId())) { + if (roleObject?.[Digit.Utils?.hrmsRoles?.[0]]?.includes(Digit.ULBService.getStateId())) { return cities; } - return cities.filter(city => roleObject[Digit.Utils?.hrmsRoles?.[0]]?.includes(city?.code)); + return cities?.filter(city => roleObject?.[Digit.Utils?.hrmsRoles?.[0]]?.includes(city?.code)); } \ No newline at end of file diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/hrmscard.js b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/hrmscard.js index 649c5ac3c2b..e1addbad56a 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/hrmscard.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/hrmscard.js @@ -7,39 +7,51 @@ const HRMSCard = () => { if (!ADMIN) { return null; } - const { t } = useTranslation(); - const tenantId = Digit.ULBService.getCurrentTenantId(); - const { isLoading, isError, error, data, ...rest } = Digit.Hooks.hrms.useHRMSCount(tenantId); + const { t } = useTranslation(); + const tenantId = Digit.ULBService.getCurrentTenantId(); + const { isLoading, isError, error, data, ...rest } = Digit.Hooks.hrms.useHRMSCount(tenantId); - const propsForModuleCard = { - Icon : , - moduleName: t("ACTION_TEST_HRMS"), - kpis: [ - { - count: isLoading ? "-" : data?.EmployeCount?.totalEmployee, - label: t("TOTAL_EMPLOYEES"), - link: `/${window?.contextPath}/employee/hrms/inbox` - }, - { - count: isLoading ? "-" : data?.EmployeCount?.activeEmployee, - label: t("ACTIVE_EMPLOYEES"), - link: `/${window?.contextPath}/employee/hrms/inbox` - } - ], - links: [ - { - label: t("HR_HOME_SEARCH_RESULTS_HEADING"), - link: `/${window?.contextPath}/employee/hrms/inbox` - }, - { - label: t("HR_COMMON_CREATE_EMPLOYEE_HEADER"), - link: `/${window?.contextPath}/employee/hrms/create` - } - ] - } + let role = ["SUPERUSER"]; - return + let propsForSandbox = [ + { + label: t("CONFIGURE_MASTER"), + link: `/${window?.contextPath}/employee/sandbox/application-management/setup-master?module=HRMS`, + isOutsideModule: true, + roles: role, + }, + ]; + propsForSandbox = propsForSandbox.filter((link) => (link?.roles ? Digit.Utils.didEmployeeHasAtleastOneRole(link.roles) : true)); + + const propsForModuleCard = { + Icon: , + moduleName: t("ACTION_TEST_HRMS"), + kpis: [ + { + count: isLoading ? "-" : data?.EmployeCount?.totalEmployee, + label: t("TOTAL_EMPLOYEES"), + link: `/${window?.contextPath}/employee/hrms/inbox`, + }, + { + count: isLoading ? "-" : data?.EmployeCount?.activeEmployee, + label: t("ACTIVE_EMPLOYEES"), + link: `/${window?.contextPath}/employee/hrms/inbox`, + }, + ], + links: [ + { + label: t("HR_HOME_SEARCH_RESULTS_HEADING"), + link: `/${window?.contextPath}/employee/hrms/inbox`, + }, + { + label: t("HR_COMMON_CREATE_EMPLOYEE_HEADER"), + link: `/${window?.contextPath}/employee/hrms/create`, + }, + ...propsForSandbox, + ], + }; + + return ; }; export default HRMSCard; - diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/SelectEmployeeGender.js b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/SelectEmployeeGender.js index 9bbc1599732..96d1b317a8b 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/SelectEmployeeGender.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/SelectEmployeeGender.js @@ -47,7 +47,7 @@ const SelectEmployeeGender = ({ t, config, onSelect, formData = {}, userType, re
{ const [focusIndex, setFocusIndex] = useState(-1); function getdepartmentdata() { - return data?.MdmsRes?.["common-masters"]?.Department.map((ele) => { + return data?.MdmsRes?.["common-masters"]?.Department?.map((ele) => { ele["i18key"] = t("COMMON_MASTERS_DEPARTMENT_" + ele.code); return ele; }); } function getdesignationdata() { - return data?.MdmsRes?.["common-masters"]?.Designation.map((ele) => { + return data?.MdmsRes?.["common-masters"]?.Designation?.map((ele) => { ele["i18key"] = t("COMMON_MASTERS_DESIGNATION_" + ele.code); return ele; }); diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/jurisdiction.js b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/jurisdiction.js index 51e8f662617..dfe2471e899 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/jurisdiction.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/jurisdiction.js @@ -1,17 +1,17 @@ -import { CardLabel, Dropdown, LabelFieldPair, Loader, RemoveableTag ,MultiSelectDropdown} from "@egovernments/digit-ui-react-components"; +import { CardLabel, Dropdown, LabelFieldPair, Loader, RemoveableTag, MultiSelectDropdown } from "@egovernments/digit-ui-react-components"; import React, { useEffect, useState } from "react"; import cleanup from "../Utils/cleanup"; // import MultiSelectDropdown from "./Multiselect"; const makeDefaultValues = (sessionFormData) => { - return sessionFormData?.Jurisdictions?.map((ele,index)=>{ + return sessionFormData?.Jurisdictions?.map((ele, index) => { return { key: index, hierarchy: { code: ele?.hierarchy, name: ele?.hierarchy, }, - boundaryType: { label: ele?.boundaryType, i18text:ele.boundaryType ?`EGOV_LOCATION_BOUNDARYTYPE_${ele.boundaryType?.toUpperCase()}`:null }, + boundaryType: { label: ele?.boundaryType, i18text: ele.boundaryType ? `EGOV_LOCATION_BOUNDARYTYPE_${ele.boundaryType?.toUpperCase()}` : null }, boundary: { code: ele?.boundary }, roles: ele?.roles, } @@ -24,10 +24,10 @@ const Jurisdictions = ({ t, config, onSelect, userType, formData }) => { const { data: data = {}, isLoading } = Digit.Hooks.hrms.useHrmsMDMS(tenantId, "egov-hrms", "HRMSRolesandDesignation") || {}; const employeeCreateSession = Digit.Hooks.useSessionStorage("NEW_EMPLOYEE_CREATE", {}); - const [sessionFormData,setSessionFormData, clearSessionFormData] = employeeCreateSession; + const [sessionFormData, setSessionFormData, clearSessionFormData] = employeeCreateSession; const isEdit = window.location.href.includes("hrms/edit") const [jurisdictions, setjurisdictions] = useState( - !isEdit && sessionFormData?.Jurisdictions?.length>0 ? makeDefaultValues(sessionFormData) : ( formData?.Jurisdictions || [ + !isEdit && sessionFormData?.Jurisdictions?.length > 0 ? makeDefaultValues(sessionFormData) : (formData?.Jurisdictions || [ { id: undefined, key: 1, @@ -51,7 +51,7 @@ const Jurisdictions = ({ t, config, onSelect, userType, formData }) => { }; res = cleanup(res); if (jurisdiction?.roles) { - res["roles"] = jurisdiction?.roles.map((ele) => { + res["roles"] = jurisdiction?.roles?.map((ele) => { delete ele.description; return ele; }); @@ -113,7 +113,7 @@ const Jurisdictions = ({ t, config, onSelect, userType, formData }) => { const [focusIndex, setFocusIndex] = useState(-1); function gethierarchylistdata() { - return data?.MdmsRes?.["egov-location"]["TenantBoundary"].map((ele) => ele.hierarchyType); + return data?.MdmsRes?.["egov-location"]["TenantBoundary"]?.map((ele) => ele.hierarchyType); } function getboundarydata() { @@ -121,7 +121,7 @@ const Jurisdictions = ({ t, config, onSelect, userType, formData }) => { } function getroledata() { - return data?.MdmsRes?.["ACCESSCONTROL-ROLES"].roles.map(role => { return { code: role.code, name: role?.name ? role?.name : " " , labelKey: 'ACCESSCONTROL_ROLES_ROLES_' + role.code } }); + return data?.MdmsRes?.["ACCESSCONTROL-ROLES"]?.roles?.map(role => { return { code: role.code, name: role?.name ? role?.name : " ", labelKey: 'ACCESSCONTROL_ROLES_ROLES_' + role.code } }); } if (isLoading) { @@ -169,8 +169,11 @@ function Jurisdiction({ roleoption, index, }) { + + const [BoundaryType, selectBoundaryType] = useState([]); const [Boundary, selectboundary] = useState([]); + const cities = Digit.Utils.getMultiRootTenant() ? Digit.Hooks.pgr.useTenants() : null; useEffect(() => { selectBoundaryType( data?.MdmsRes?.["egov-location"]["TenantBoundary"] @@ -181,10 +184,28 @@ function Jurisdiction({ ); }, [jurisdiction?.hierarchy, data?.MdmsRes]); const tenant = Digit.ULBService.getCurrentTenantId(); + + const { data: TenantMngmtSearch, isLoading: isLoadingTenantMngmtSearch } = Digit.Hooks.useTenantManagementSearch({ + stateId: Digit.ULBService.getStateId(), + includeSubTenants: true, + config : { + enabled: Digit.Utils.getMultiRootTenant() + } + }); + const getSubTenants = () => TenantMngmtSearch?.filter((e) => e.code === Digit.ULBService.getCurrentTenantId()) || []; + const subTenantList = getSubTenants(); + useEffect(() => { - selectboundary(data?.MdmsRes?.tenant?.tenants.filter(city => city.code != Digit.ULBService.getStateId()).map(city => { return { ...city, i18text: Digit.Utils.locale.getCityLocale(city.code) } })); + if (Digit.Utils.getMultiRootTenant()) { + selectboundary(subTenantList); + } + else { + selectboundary(data?.MdmsRes?.tenant?.tenants.filter(city => city.code != Digit.ULBService.getStateId()).map(city => { return { ...city, i18text: Digit.Utils.locale.getCityLocale(city.code) } })); + } }, [jurisdiction?.boundaryType, data?.MdmsRes]); + + useEffect(() => { if (Boundary?.length > 0) { selectedboundary(Boundary?.filter((ele) => ele.code == jurisdiction?.boundary?.code)[0]); @@ -217,7 +238,7 @@ function Jurisdiction({ res.push(ob?.[1]); }); - res?.forEach(resData => {resData.labelKey = 'ACCESSCONTROL_ROLES_ROLES_' + resData.code}) + res?.forEach(resData => { resData.labelKey = 'ACCESSCONTROL_ROLES_ROLES_' + resData.code }) setjurisdictions((pre) => pre.map((item) => (item.key === jurisdiction.key ? { ...item, roles: res } : item))); }; @@ -283,7 +304,7 @@ function Jurisdiction({ disable={Boundary?.length === 0} option={Boundary} select={selectedboundary} - optionKey="i18text" + optionKey={Digit.Utils.getMultiRootTenant() ? "code" : "i18text"} t={t} /> diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/createEmployee.js b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/createEmployee.js index 75005bbbc35..e96ead54bf4 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/createEmployee.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/createEmployee.js @@ -137,7 +137,6 @@ const CreateEmployee = () => { - const onSubmit = (data) => { if (data.Jurisdictions.filter(juris => juris.tenantId == tenantId).length == 0) { setShowToast({ key: true, label: "ERR_BASE_TENANT_MANDATORY" }); diff --git a/micro-ui/web/micro-ui-internals/packages/modules/open-payment/package.json b/micro-ui/web/micro-ui-internals/packages/modules/open-payment/package.json index 813872277e2..2dc71946773 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/open-payment/package.json +++ b/micro-ui/web/micro-ui-internals/packages/modules/open-payment/package.json @@ -18,7 +18,7 @@ "react-router-dom": "5.3.0" }, "dependencies": { - "@egovernments/digit-ui-react-components": "1.8.2-beta.4", + "@egovernments/digit-ui-react-components": "1.8.2-beta.13", "@egovernments/digit-ui-components": "0.0.2-beta.18", "react": "17.0.2", "react-dom": "17.0.2", diff --git a/micro-ui/web/micro-ui-internals/packages/modules/pgr/package.json b/micro-ui/web/micro-ui-internals/packages/modules/pgr/package.json index 39bea749219..a630eb76658 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/pgr/package.json +++ b/micro-ui/web/micro-ui-internals/packages/modules/pgr/package.json @@ -18,7 +18,7 @@ "react-router-dom": "5.3.0" }, "dependencies": { - "@egovernments/digit-ui-react-components": "1.8.2-beta.12", + "@egovernments/digit-ui-react-components": "1.8.2-beta.13", "lodash.merge": "^4.6.2", "react": "17.0.2", "react-dom": "17.0.2", diff --git a/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/components/PGRCard.js b/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/components/PGRCard.js index 55b9b3726d5..96c3ee7d32c 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/components/PGRCard.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/components/PGRCard.js @@ -21,16 +21,32 @@ const PGRCard = () => { - let propsForCSR =[ - { - label: t("ES_PGR_NEW_COMPLAINT"), - link: `/${window?.contextPath}/employee/pgr/complaint/create`, - role: "CSR" - } - ] + let role = ["CSR"]; + +if (Digit.Utils.getMultiRootTenant()) { + role.push("SUPERUSER"); +} - propsForCSR = propsForCSR.filter(link => link.role && Digit.Utils.didEmployeeHasRole(link.role) ); +let propsForCSR = [ + { + label: t("ES_PGR_NEW_COMPLAINT"), + link: `/${window?.contextPath}/employee/pgr/complaint/create`, + roles: role + } +]; + + +let propsForSandbox = [ + { + label: t("CONFIGURE_MASTER"), + link: `/${window?.contextPath}/employee/sandbox/application-management/setup-master?module=PGR`, + isOutsideModule : true, + roles: role + } +]; + propsForCSR = propsForCSR.filter(link => link?.roles ? Digit.Utils.didEmployeeHasAtleastOneRole(link.roles) : true ); + propsForSandbox = propsForSandbox.filter(link => link?.roles ? Digit.Utils.didEmployeeHasAtleastOneRole(link.roles) : true ); const propsForModuleCard = { Icon: , moduleName: t("ES_PGR_HEADER_COMPLAINT"), @@ -49,7 +65,8 @@ const PGRCard = () => { label: t("ES_PGR_INBOX"), link: `/${window?.contextPath}/employee/pgr/inbox` }, - ...propsForCSR + ...propsForCSR, + ...propsForSandbox ] } diff --git a/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/pages/citizen/ComplaintDetails.js b/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/pages/citizen/ComplaintDetails.js index c4fd9bc9b65..175aa9f3b95 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/pages/citizen/ComplaintDetails.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/pages/citizen/ComplaintDetails.js @@ -23,7 +23,7 @@ import TimeLine from "../../components/TimeLine"; const WorkflowComponent = ({ complaintDetails, id, getWorkFlow, zoomImage }) => { const tenantId = Digit.SessionStorage.get("CITIZEN.COMMON.HOME.CITY")?.code || complaintDetails.service.tenantId; let workFlowDetails = Digit.Hooks.useWorkflowDetails({ tenantId: tenantId, id, moduleCode: "PGR" }); - const { data: ComplainMaxIdleTime, isLoading: ComplainMaxIdleTimeLoading } = Digit.Hooks.pgr.useMDMS.ComplainClosingTime(tenantId?.split(".")[0]); + // const { data: ComplainMaxIdleTime, isLoading: ComplainMaxIdleTimeLoading } = Digit.Hooks.pgr.useMDMS.ComplainClosingTime(tenantId?.split(".")[0]); useEffect(() => { getWorkFlow(workFlowDetails.data); @@ -43,7 +43,7 @@ const WorkflowComponent = ({ complaintDetails, id, getWorkFlow, zoomImage }) => rating={complaintDetails.audit.rating} zoomImage={zoomImage} complaintDetails={complaintDetails} - ComplainMaxIdleTime={ComplainMaxIdleTime} + // ComplainMaxIdleTime={ComplainMaxIdleTime} /> ) ); diff --git a/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/pages/citizen/Create/Steps/SelectAddress.js b/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/pages/citizen/Create/Steps/SelectAddress.js index 9741b1bd34b..4e13a8e5cc2 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/pages/citizen/Create/Steps/SelectAddress.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/pages/citizen/Create/Steps/SelectAddress.js @@ -1,17 +1,47 @@ import React, { useEffect, useState, useRef } from "react"; import { CardLabel, Dropdown, FormStep, RadioButtons } from "@egovernments/digit-ui-react-components"; +import { subtract } from "lodash"; const SelectAddress = ({ t, config, onSelect, value }) => { const allCities = Digit.Hooks.pgr.useTenants(); const cities = value?.pincode ? allCities.filter((city) => city?.pincode?.some((pin) => pin == value["pincode"])) : allCities; + // Define the requestCriteria +let requestCriteria = null; + +// Check the value of window.globalPath + +const { data: TenantMngmtSearch, isLoading: isLoadingTenantMngmtSearch } = Digit.Hooks.useTenantManagementSearch({ + stateId: Digit.ULBService.getStateId(), + includeSubTenants: true, + config : { + enabled: Digit.Utils.getMultiRootTenant() + } +}); const [selectedCity, setSelectedCity] = useState(() => { const { city_complaint } = value; return city_complaint ? city_complaint : null; }); + + const { isLoading: hierarchyLOading, data:hierarchyType } = Digit.Hooks.useCustomMDMS( + Digit.ULBService.getStateId(), + "sandbox-ui", + [ + { name: "ModuleMasterConfig",filter:'[?(@.module == "PGR")].master[?(@.type == "boundary")]' + + } + ], + { + select: (data) => { + const formattedData = data?.["sandbox-ui"]?.["ModuleMasterConfig"] + return formattedData?.[0]?.code; + }, + } + ); + const { data: fetchedLocalities } = Digit.Hooks.useBoundaryLocalities( selectedCity?.code, - "admin", + hierarchyType, { enabled: !!selectedCity, }, @@ -51,10 +81,14 @@ const SelectAddress = ({ t, config, onSelect, value }) => {
{t("MYCITY_CODE_LABEL")} - {cities?.length < 5 ? ( - + {(Digit.Utils.getMultiRootTenant() ? TenantMngmtSearch?.length : cities?.length) < 5 ? ( + ) : ( - + )} {selectedCity && localities && {t("CS_CREATECOMPLAINT_MOHALLA")}} {selectedCity && localities && ( diff --git a/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/pages/employee/CreateComplaint/index.js b/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/pages/employee/CreateComplaint/index.js index a3313270966..6c8df59a414 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/pages/employee/CreateComplaint/index.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/pages/employee/CreateComplaint/index.js @@ -10,24 +10,62 @@ import { createComplaint } from "../../../redux/actions/index"; export const CreateComplaint = ({ parentUrl }) => { const cities = Digit.Hooks.pgr.useTenants(); + const stateId = Digit.ULBService.getStateId(); + const { t } = useTranslation(); const getCities = () => cities?.filter((e) => e.code === Digit.ULBService.getCurrentTenantId()) || []; + +// Use the requestCriteria only if it's not null +const { data: subTenants, refetch, isLoading: isLoadingSubTenants } = { data: null, refetch: () => {}, isLoading: false }; + +const { data: TenantMngmtSearch, isLoading: isLoadingTenantMngmtSearch } = Digit.Hooks.useTenantManagementSearch({ + stateId: stateId, + includeSubTenants: true, + config : { + enabled: Digit.Utils.getMultiRootTenant() + } +}); + + const getSubTenants = () => Digit.Utils.getMultiRootTenant() ? TenantMngmtSearch?.filter((e) => e.code === Digit.ULBService.getCurrentTenantId()) : subTenants?.filter((e) => e.code === Digit.ULBService.getCurrentTenantId()); + const [complaintType, setComplaintType] = useState({}); const [subTypeMenu, setSubTypeMenu] = useState([]); const [subType, setSubType] = useState({}); const [pincode, setPincode] = useState(""); - const [selectedCity, setSelectedCity] = useState(getCities()[0] ? getCities()[0] : null); + const [selectedCity, setSelectedCity] = useState( + Digit.Utils.getMultiRootTenant() + ? getSubTenants()?.[0] || null + : getCities()?.[0] || null + ); + + const cityData = Digit.Utils.getMultiRootTenant() ? getSubTenants() : getCities(); + + const { isLoading: hierarchyLOading, data: hierarchyType } = Digit.Hooks.useCustomMDMS( + Digit.ULBService.getStateId(), + "sandbox-ui", + [ + { name: "ModuleMasterConfig",filter:'[?(@.module == "PGR")].master[?(@.type == "boundary")]' + + } + ], + { + select: (data) => { + const formattedData = data?.["sandbox-ui"]?.["ModuleMasterConfig"] + return formattedData?.[0]?.code; + }, + } + ); const { data: fetchedLocalities } = Digit.Hooks.useBoundaryLocalities( - getCities()[0]?.code, - "admin", - { - enabled: !!getCities()[0], - }, - t - ); + cityData?.[0]?.code, + hierarchyType, + { + enabled: !!cityData?.[0], + }, + t +); const [localities, setLocalities] = useState(fetchedLocalities); const [selectedLocality, setSelectedLocality] = useState(null); @@ -57,8 +95,9 @@ export const CreateComplaint = ({ parentUrl }) => { }, [fetchedLocalities]); useEffect(() => { + if(!Digit.Utils.getMultiRootTenant()){ const city = cities.find((obj) => obj.pincode?.find((item) => item == pincode)); - if (city?.code&&city?.code === getCities()[0]?.code) { + if (city?.code&&city?.code === getCities()?.[0]?.code) { setPincodeNotValid(false); setSelectedCity(city); setSelectedLocality(null); @@ -71,8 +110,10 @@ export const CreateComplaint = ({ parentUrl }) => { } else { setPincodeNotValid(true); } + } }, [pincode]); + async function selectedType(value) { if (value.key !== complaintType.key) { if (value.key === "Others") { @@ -111,9 +152,17 @@ export const CreateComplaint = ({ parentUrl }) => { const onSubmit = async (data) => { if (!canSubmit) return; const cityCode = selectedCity.code; - const city = selectedCity.city.name; - const district = selectedCity.city.name; - const region = selectedCity.city.name; + const city = Digit.Utils.getMultiRootTenant() + ? selectedCity.name + : selectedCity.city.name; + + const district = Digit.Utils.getMultiRootTenant() + ? selectedCity.name + : selectedCity.city.name; + + const region = Digit.Utils.getMultiRootTenant() + ? selectedCity.name + : selectedCity.city.name; const localityCode = selectedLocality.code; const localityName = selectedLocality.name; const landmark = data.landmark; @@ -210,10 +259,12 @@ export const CreateComplaint = ({ parentUrl }) => { isMandatory selected={selectedCity} freeze={true} - option={getCities()} + option={ + Digit.Utils.getMultiRootTenant() ? getSubTenants() : getCities() + } id="city" select={selectCity} - optionKey="i18nKey" + optionKey={Digit.Utils.getMultiRootTenant() ? "name" : "i18nKey"} t={t} /> ), diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/package.json b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/package.json index 93baad0872d..ce7db6919e3 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/package.json +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/package.json @@ -18,7 +18,7 @@ "react-router-dom": "5.3.0" }, "dependencies": { - "@egovernments/digit-ui-react-components": "1.8.2-beta.12", + "@egovernments/digit-ui-react-components": "1.8.2-beta.13", "@egovernments/digit-ui-components": "0.0.2-beta.18", "react": "17.0.2", "react-date-range": "^1.4.0", diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/Module.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/Module.js index fa6f1138b58..7c181bbb902 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/Module.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/Module.js @@ -10,6 +10,7 @@ export const SandboxModule = ({ stateCode, userType, tenants }) => { const { path, url } = useRouteMatch(); const tenantId = Digit.ULBService.getCurrentTenantId(); const moduleCode = ["sandbox"]; + const MDMSmoduleCode = [`rainmaker-mdms`, `rainmaker-workbench`, `rainmaker-schema`]; const language = Digit.StoreData.getCurrentLanguage(); const { isLoading, data: store } = Digit.Services.useStore({ stateCode, @@ -18,7 +19,15 @@ export const SandboxModule = ({ stateCode, userType, tenants }) => { modulePrefix: "digit", }); - if (isLoading) { + const { isLoading: isMDMSLoading, data: MDMSstore } = Digit.Services.useStore({ + stateCode, + MDMSmoduleCode, + language, + }); + if (!Digit.Utils.sandboxAccess()) { + return null; + } + if (isLoading && isMDMSLoading) { return ; } return ; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/components/SandboxCard.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/components/SandboxCard.js index ca89a85a3d8..d2b2ac9fcf7 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/components/SandboxCard.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/components/SandboxCard.js @@ -8,6 +8,10 @@ const SandboxCard = () => { const ROLES = { SUPERUSER: ["SUPERUSER"], }; + + if (!Digit.Utils.sandboxAccess()) { + return null; + } const propsForModuleCard = { Icon: , moduleName: t("SANDBOX_CARD_HEADER"), @@ -16,18 +20,18 @@ const SandboxCard = () => { { label: t("SANDBOX_TENANT_CREATE_HOMECARD_LABEL"), link: `/${window?.contextPath}/employee/sandbox/tenant-management/create`, - // roles: ROLES.SUPERUSER, + roles: ROLES.SUPERUSER, }, { label: t("SANDBOX_TENANT_SEARCH_HOMECARD_LABEL"), link: `/${window?.contextPath}/employee/sandbox/tenant-management/search`, - // roles: ROLES.SUPERUSER, - }, - { - label: t("SANDBOX_APPLICATION_MANAGEMENT_HOMECARD_LABEL"), - link: `/${window?.contextPath}/employee/sandbox/application-management/home`, - // roles: ROLES.SUPERUSER, + roles: ROLES.SUPERUSER, }, + // { + // label: t("SANDBOX_APPLICATION_MANAGEMENT_HOMECARD_LABEL"), + // link: `/${window?.contextPath}/employee/sandbox/application-management/home`, + // roles: ROLES.SUPERUSER, + // }, ], }; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/UICustomizations.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/UICustomizations.js index c42cb548851..8207b8ba785 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/UICustomizations.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/UICustomizations.js @@ -180,7 +180,7 @@ export const UICustomizations = { preProcess: (data, additionalDetails) => { const tenantId = Digit.ULBService.getCurrentTenantId(); data.params = { - tenantId: tenantId + tenantId: tenantId, }; data.body = { RequestInfo: data.body.RequestInfo }; data.body.MdmsCriteria = { @@ -200,7 +200,7 @@ export const UICustomizations = { const temp = data?.MdmsRes?.["sandbox-ui"]?.ModuleMasterConfig?.find((item) => item?.module === additionalDetails?.moduleName); return { module: temp?.module, - master: temp?.master?.filter((item) => item.type === "module" || item.type === "common"), + master: temp?.master?.filter((item) => item.type === "module" || item.type === "common" || item.type === "boundary"), }; }; @@ -224,30 +224,35 @@ export const UICustomizations = { value?.split(".")?.[1] }`} > - {value?.split(".")?.[0]} + {t(`SANDBOX_${value?.split(".")?.[0]}`)} ); case "SANDBOX_MASTER_NAME": - return row?.code?.split(".")?.[1] ? row?.code?.split(".")?.[1] : row?.code?.split(".")?.[0]; + return row?.code?.split(".")?.[1] ? t(`SANDBOX_${row?.code?.split(".")?.[1]}`) : t(`SANDBOX_${row?.code?.split(".")?.[0]}`); case "SANDBOX_MASTER_TYPE": - return value; + return t(`SANDBOX_${value}`); case "SANDBOX_ACTIONS": - const handleRedirect = (value) => { - window.history.pushState( - null, - "", - `/${window.contextPath}/employee/workbench/mdms-search-v2?moduleName=${value?.split(".")?.[0]}&masterName=${value?.split(".")?.[1]}` - ); - const navEvent = new PopStateEvent("popstate"); - window.dispatchEvent(navEvent); + const handleRedirect = (value, type) => { + if (type === "boundary") { + window.history.pushState(null, "", `/${window.contextPath}/employee/workbench/upload-boundary?hierarchyType=${value}&from=sandbox`); + const navEvent = new PopStateEvent("popstate"); + window.dispatchEvent(navEvent); + } else { + window.history.pushState( + null, + "", + `/${window.contextPath}/employee/workbench/mdms-search-v2?moduleName=${value?.split(".")?.[0]}&masterName=${value?.split(".")?.[1]}` + ); + const navEvent = new PopStateEvent("popstate"); + window.dispatchEvent(navEvent); + } }; - return (
- handleRedirect(row?.code)} /> + handleRedirect(row?.code, row?.type)} />
); default: diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantSearchConfig.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantSearchConfig.js index 488aa785150..81bb521fef6 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantSearchConfig.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantSearchConfig.js @@ -18,7 +18,6 @@ export const tenantSearchConfig = () => tableFormJsonPath: "requestBody.inbox", filterFormJsonPath: "requestBody.tenant", searchFormJsonPath: "requestBody.tenant", - }, sections: { search: { diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantUpdateConfig.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantUpdateConfig.js new file mode 100644 index 00000000000..2838103587a --- /dev/null +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/configs/tenantUpdateConfig.js @@ -0,0 +1,60 @@ +export const tenantUpdateConfig = [ + { + head: null, + body: [ + { + inline: true, + label: "SANDBOX_CREATE_TENANT_NAME_LABEL", + isMandatory: true, + key: "tenantName", + type: "text", + disable: true, + populators: { name: "tenantName", error: "Required", validation: { pattern: /^[A-Za-z0-9]+$/i } }, + }, + { + inline: true, + label: "SANDBOX_CREATE_TENANT_EMAIL_LABEL", + isMandatory: true, + key: "emailId", + type: "text", + disable: true, + populators: { name: "emailId", error: "Required", validation: { pattern: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/i } }, + }, + { + inline: true, + label: "SANDBOX_CREATE_TENANT_CODE_LABEL", + isMandatory: true, + key: "tenantCode", + type: "text", + disable: true, + populators: { name: "tenantCode", error: "Required", validation: { pattern: /^[A-Za-z0-9.]+$/i } }, + }, + { + isMandatory: false, + key: "isActive", + type: "dropdown", + label: "SANDBOX_CREATE_TENANT_ACTIVE_LABEL", + disable: false, + populators: { + name: "isActive", + optionsKey: "name", + error: " Required", + required: true, + options: [ + { + code: "true", + name: "TRUE", + active: true, + }, + { + code: "false", + name: "FALSE", + active: true, + }, + ], + }, + }, + ], + }, + ]; + \ No newline at end of file diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/hooks/index.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/hooks/index.js index 47137510d10..f837af04ab0 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/hooks/index.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/hooks/index.js @@ -1,16 +1,18 @@ import { useIndividualView } from "./useIndividualView"; import utils from "../utils"; +import useDefaultMasterHandler from "./useDefaultMasterHandler"; const sandbox = { - useIndividualView + useIndividualView, + useDefaultMasterHandler, }; const Hooks = { - sandbox + sandbox, }; const Utils = { browser: { - sandbox: () => { }, + sandbox: () => {}, }, sandbox: { ...utils, diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/hooks/useDefaultMasterHandler.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/hooks/useDefaultMasterHandler.js new file mode 100644 index 00000000000..72752fd020a --- /dev/null +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/hooks/useDefaultMasterHandler.js @@ -0,0 +1,26 @@ +import { useMutation } from "react-query"; + +const defaultMasterHandlerService = async (reqData, tenantId) => { + try { + const response = await Digit.CustomService.getResponse({ + url: "/default-data-handler/defaultdata/setup", + body: { + targetTenantId: tenantId, + module: reqData?.module, + onlySchemas: reqData?.onlySchemas, + }, + params: {}, + }); + return response; + } catch (error) { + throw new Error(error?.response?.data?.Errors?.[0].description); + } +}; + +const useDefaultMasterHandler = (tenantId) => { + return useMutation((reqData) => { + return defaultMasterHandlerService(reqData, tenantId); + }); +}; + +export default useDefaultMasterHandler; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/ApplicationHome.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/ApplicationHome.js index f95257835a2..9448b85ab13 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/ApplicationHome.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/ApplicationHome.js @@ -34,7 +34,8 @@ const ApplicationHome = () => { className="sandbox-module-card" label={t(`SANDBOX_APPLICATION_MODULE_${item?.module}`)} buttonLabel={t(`SANDBOX_VIEW`)} - onButtonClick={() => history.push(`/${window?.contextPath}/employee/sandbox/application-management/module?module=${item?.module}`)} + onButtonClick={() => history.push(`/${window?.contextPath}/employee/sandbox/application-management/setup-master?module=${item?.module}`)} + // onButtonClick={() => history.push(`/${window?.contextPath}/employee/sandbox/application-management/module?module=${item?.module}`)} /> ))}
diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/ModuleMasterTable.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/ModuleMasterTable.js index 36f919334d4..d9236e6b311 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/ModuleMasterTable.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/ModuleMasterTable.js @@ -1,6 +1,7 @@ -import React from "react"; +import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { Header, InboxSearchComposer } from "@egovernments/digit-ui-react-components"; +import { Button, PopUp, Toast } from "@egovernments/digit-ui-components"; import { useHistory, useLocation } from "react-router-dom"; import { moduleMasterConfig } from "./config/moduleMasterConfig"; @@ -11,11 +12,42 @@ const ModuleMasterTable = () => { const searchParams = new URLSearchParams(location.search); const module = searchParams.get("module"); const config = moduleMasterConfig(module); - + const tenantId = Digit.ULBService.getCurrentTenantId(); + const [showPopUp, setShowPopUp] = useState(true); + const { mutate: useDefaultMasterHandler } = Digit.Hooks.sandbox.useDefaultMasterHandler(tenantId); + const [showToast, setShowToast] = useState(null); const onClickRow = ({ original: row }) => { const value = row?.code; - history.push( - `/${window.contextPath}/employee/workbench/mdms-search-v2?moduleName=${value?.split(".")?.[0]}&masterName=${value?.split(".")?.[1]}` + const type = row?.type; + if (type === "boundary") { + history.push( + `/${window.contextPath}/employee/workbench/upload-boundary?hierarchyType=${value}&from=sandbox&module=${module}` + ); + } else { + history.push( + `/${window.contextPath}/employee/workbench/mdms-search-v2?moduleName=${value?.split(".")?.[0]}&masterName=${ + value?.split(".")?.[1] + }&from=sandbox&screen=applicationManagement&action=view` + ); + } + }; + const handleMasterData = async (check) => { + await useDefaultMasterHandler( + { + module: module, + onlySchemas: check, + }, + { + onError: (error, variables) => { + console.log(error); + setShowPopUp(false); + setShowToast({ key: "error", label: check ? "MANNUAL_MASTER_SETUP_ERROR" : "DEFAULT_MASTER_SETUP_ERROR", isError: true }); + }, + onSuccess: async (data) => { + setShowPopUp(false); + setShowToast({ key: "success", label: check ? "MANNUAL_MASTER_SETUP_SUCCESS" : "DEFAULT_MASTER_SETUP_SUCCESS" }); + }, + } ); }; return ( @@ -31,6 +63,47 @@ const ModuleMasterTable = () => { }} >
+ {showPopUp && ( + {t("SANDBOX_SETUP_MASTER_MODAL_TEXT")}]} + onOverlayClick={() => {}} + footerChildren={[ + + + + )} + {showMaster && ( + <> +
+ + {t(config?.header || "N/A")} +
+ {t(config?.description)} + {/* {Object.keys(moduleMasterData)?.length > 0 && + Object.keys(moduleMasterData)?.map((item, index) => ( +
  • + {t(item)} + {moduleMasterData?.[item]?.length > 0 && + moduleMasterData?.[item]?.map((subItem, subIndex) => ( +
  • + {subIndex + 1}. + {t(subItem)} + {subItem?.child?.length > 0 && + subItem.child.map((grandChild, grandIndex) => ( +
  • + {String.fromCharCode(97 + grandIndex)} . + {t(grandChild)} +
  • + ))} + + ))} + + ))} */} + {/*
    + {Object.entries(moduleMasterData).map(([type, categories], index) => ( +
    + {type.charAt(0).toUpperCase() + type.slice(1)} + {renderHierarchy(categories)} +
    + ))} +
    */} + { + return { + style: { + padding: "20px 18px", + fontSize: "16px", + whiteSpace: "normal", + }, + }; + }} + /> + {/*
    { + return Hello; + }, + }, + { + Header: t("HR_EMP_NAME_LABEL"), + disableSortBy: true, + Cell: ({ row }) => { + // return GetCell(`${row.original?.user?.name}`); + return Hello; + }, + }, + ]} + data={[{ label: "HR_EMP_NAME_LABEL" }, { label: "HELLO" }]} + getCellProps={(cellInfo) => { + return { + style: {}, + }; + }} + /> */} +
    + +
    + + )} + + ); +}; + +export default SetupMaster; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/config/moduleMasterConfig.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/config/moduleMasterConfig.js index 49ab4996c66..9196ad9efff 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/config/moduleMasterConfig.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/config/moduleMasterConfig.js @@ -85,11 +85,11 @@ export const moduleMasterConfig = (module) => ({ searchResult: { uiConfig: { columns: [ - { - label: "SANDBOX_MODULE_NAME", - jsonPath: "code", - additionalCustomization: true, - }, + // { + // label: "SANDBOX_MODULE_NAME", + // jsonPath: "code", + // additionalCustomization: true, + // }, { label: "SANDBOX_MASTER_NAME", jsonPath: "master", diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/config/setupMasterConfig.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/config/setupMasterConfig.js new file mode 100644 index 00000000000..fc86c889c11 --- /dev/null +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/config/setupMasterConfig.js @@ -0,0 +1,80 @@ +export const setupMasterConfig = { + tenantId: "pg", + moduleName: "commonUiConfig", + SetupMaster: [ + { + header: "COMPLAINT_MANAGEMENT", + module: "PGR", + active: true, + description: "COMPLAINT_MANAGEMENT_DESCRIPTION", + masterDescription: "COMPLAINT_MANAGEMENT_SETUP_MASTER_DESCRIPTION", + actionText: "SETUP_NOW", + features: [ + { + id: 1, + name: "COMPLAINT_MANAGEMENT_REGISTRATION_LOGIN_CREATION", + }, + { + id: 2, + name: "COMPLAINT_MANAGEMENT_LODGING_FILE", + }, + { + id: 3, + name: "COMPLAINT_MANAGEMENT_ASSIGNING_COMPLAINT", + }, + { + id: 4, + name: "COMPLAINT_MANAGEMENT_RESOLVING_COMPLAINT", + }, + { + id: 5, + name: "COMPLAINT_MANAGEMENT_MANAGE_COMPLAINTS", + }, + { + id: 6, + name: "COMPLAINT_MANAGEMENT_TRACK_COMPLAINTS", + }, + { + id: 7, + name: "COMPLAINT_MANAGEMENT_DASHBOARD_REPORTS", + }, + ], + }, + { + header: "HCM", + module: "HCM", + active: true, + description: "HCM_DESCRIPTION", + masterDescription: "HCM_SETUP_MASTER_DESCRIPTION", + actionText: "SETUP_NOW", + features: [ + { + id: 1, + name: "HCM_FEATURE_1", + }, + ], + }, + { + header: "HRMS", + module: "HRMS", + active: true, + description: "HRMS_DESCRIPTION", + masterDescription: "HRMS_SETUP_MASTER_DESCRIPTION", + actionText: "SETUP_NOW", + features: [ + { + id: 1, + name: "HRMS_REGISTRATION_LOGIN_CREATION", + }, + { + id: 2, + name: "HRMS_MODIFY_EMPLOYEE", + }, + { + id: 3, + name: "HRMS_VIEW_EMPLOYEE", + }, + ], + }, + ], +}; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/index.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/index.js index 337c874dc5f..f9daf343859 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/index.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/index.js @@ -9,6 +9,8 @@ import TenantView from "./tenantMgmt/TenantView"; import TenantCreate from "./tenantMgmt/TenantCreate"; import ApplicationHome from "./applicationMgmt/ApplicationHome"; import ModuleMasterTable from "./applicationMgmt/ModuleMasterTable"; +import TenantUpdate from "./tenantMgmt/TenantUpdate"; +import SetupMaster from "./applicationMgmt/SetupMaster"; const bredCrumbStyle = { maxWidth: "min-content" }; @@ -55,8 +57,10 @@ const App = ({ path, stateCode, userType, tenants }) => { } /> } /> } /> + } /> } /> } /> + } /> } /> diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js new file mode 100644 index 00000000000..30703accc14 --- /dev/null +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantUpdate.js @@ -0,0 +1,97 @@ +import React, { useState, useEffect } from "react"; +import { useTranslation } from "react-i18next"; +import { useHistory ,useLocation} from "react-router-dom"; +import { FormComposerV2, Header, Toast } from "@egovernments/digit-ui-react-components"; +import { transformCreateData } from "../../../utils/TenantUpdateUtil"; +import { tenantUpdateConfig } from "../../../configs/tenantUpdateConfig"; + +const fieldStyle = { marginRight: 0 }; + +const TenantUpdate = () => { + const location = useLocation(); + const { name,code,email} = location.state || {}; + const defaultValue = { + tenantName:name, + tenantCode:code, + emailId:email, + isActive:"" + }; + const tenantId = Digit.ULBService.getCurrentTenantId(); + const { t } = useTranslation(); + const history = useHistory(); + const [showToast, setShowToast] = useState(false); + + const closeToast = () => { + setTimeout(() => { + setShowToast(false); + }, 5000); + }; + const reqCreate = { + url: `/tenant-management/subTenant/_update`, + params: {}, + body: {}, + config: { + enable: false, + }, + }; + const mutation = Digit.Hooks.useCustomAPIMutationHook(reqCreate); + const onSubmit = async (data) => { + if(tenantId==code){ + setShowToast({ + label: t("SANDBOX_TENANT_CANNOT_UPDATE_TOAST"), + isError: true, + }); + } + else{ + await mutation.mutate( + { + url: `/tenant-management/subTenant/_update`, + body: transformCreateData(data), + config: { + enable: true, + }, + }, + { + onError: (error, variables) => { + setShowToast({ + label: error.toString(), + isError: true, + }); + setTimeout(() => { + setShowToast(false); + }, 5000); + }, + onSuccess: async (data) => { + setShowToast({ key: "success", label: t("SANDBOX_TENANT_UPDATE_SUCCESS_TOAST") }); + setTimeout(() => { + closeToast(); + history.push(`/${window?.contextPath}/employee/sandbox/tenant-management/search`); + }, 3000); + }, + } + ); + } + }; + return ( +
    +
    {t("SANDBOX_UPDATE_TENANT_HEADER")}
    + { + return { + ...config, + }; + })} + defaultValues={defaultValue} + onFormValueChange={(setValue, formData, formState, reset, setError, clearErrors, trigger, getValues) => {}} + onSubmit={(data) => onSubmit(data)} + fieldStyle={fieldStyle} + noBreakLine={true} + /> + + {showToast && setShowToast(false)} />} +
    + ); +}; + +export default TenantUpdate; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantView.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantView.js index ae0d4c3aed2..c33639bb885 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantView.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/tenantMgmt/TenantView.js @@ -32,7 +32,10 @@ const TenantView = () => { }, []); const onClickRow = ({ original: row }) => { - const value = row?.code; + const code = row?.code; + const name= row?.name; + const email=row?.email; + history.push(`/${window?.contextPath}/employee/sandbox/tenant-management/update`, {name,code,email}); }; return ( diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/utils/TenantUpdateUtil.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/utils/TenantUpdateUtil.js new file mode 100644 index 00000000000..fdee7c17a72 --- /dev/null +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/utils/TenantUpdateUtil.js @@ -0,0 +1,14 @@ +export const transformCreateData = (data) => { + const tenantId = Digit.ULBService.getCurrentTenantId(); + + return { + tenant: { + name: data.tenantName, + email: data.emailId, + code: data.tenantCode, + isActive:data.isActive.code, + parentId: tenantId, + }, + }; + }; + \ No newline at end of file diff --git a/micro-ui/web/micro-ui-internals/packages/modules/utilities/package.json b/micro-ui/web/micro-ui-internals/packages/modules/utilities/package.json index 7e6537a861e..09f4b4902de 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/utilities/package.json +++ b/micro-ui/web/micro-ui-internals/packages/modules/utilities/package.json @@ -20,7 +20,7 @@ "dependencies": { "@cyntler/react-doc-viewer": "1.10.3", "@egovernments/digit-ui-components": "0.0.2-beta.18", - "@egovernments/digit-ui-react-components": "1.8.2-beta.12", + "@egovernments/digit-ui-react-components": "1.8.2-beta.13", "axios": "^1.7.2", "react": "17.0.2", "react-date-range": "^1.4.0", diff --git a/micro-ui/web/micro-ui-internals/packages/modules/workbench/package.json b/micro-ui/web/micro-ui-internals/packages/modules/workbench/package.json index 8e642d31f1d..09f9f5941af 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/workbench/package.json +++ b/micro-ui/web/micro-ui-internals/packages/modules/workbench/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "@egovernments/digit-ui-components": "0.0.2-beta.18", - "@egovernments/digit-ui-react-components": "1.8.2-beta.12", + "@egovernments/digit-ui-react-components": "1.8.2-beta.13", "@rjsf/core": "5.10.0", "@rjsf/utils": "5.10.0", "@rjsf/validator-ajv8": "5.10.0", diff --git a/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/configs/searchMDMSConfig.js b/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/configs/searchMDMSConfig.js index 84edeb4b8f5..2847d5793de 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/configs/searchMDMSConfig.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/configs/searchMDMSConfig.js @@ -2,7 +2,7 @@ export const Config = { label: "WBH_SEARCH_MDMS", type: "search", actionLabel: "WBH_ADD_MDMS", - actionRoles: ["MDMS_ADMIN","CAMPAIGN_ADMIN"], + actionRoles: ["MDMS_ADMIN","CAMPAIGN_ADMIN","SUPERUSER"], actionLink: "workbench/mdms-add-v2", apiDetails: { serviceName: `/mdms-v2/v2/_search`, diff --git a/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSSearchv2.js b/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSSearchv2.js index c423e6c171a..32c1b68ec11 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSSearchv2.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSSearchv2.js @@ -24,6 +24,19 @@ const MDMSSearchv2 = () => { const history = useHistory(); let {masterName:modulee,moduleName:master,tenantId} = Digit.Hooks.useQueryParams() + let {from, screen, action} = Digit.Hooks.useQueryParams() + + const additionalParams = { + from: from, + screen: screen, + action: action + } + + Object.keys(additionalParams).forEach(key => { + if (additionalParams[key] === undefined || additionalParams[key] === null) { + delete additionalParams[key]; + } + }); const [availableSchemas, setAvailableSchemas] = useState([]); const [currentSchema, setCurrentSchema] = useState(null); @@ -157,15 +170,17 @@ const MDMSSearchv2 = () => { const handleAddMasterData = () => { let actionLink=updatedConfig?.actionLink + const additionalParamString = new URLSearchParams(additionalParams).toString(); if(modulee&&master){ - actionLink= `workbench/mdms-add-v2?moduleName=${master}&masterName=${modulee}` + actionLink= `workbench/mdms-add-v2?moduleName=${master}&masterName=${modulee}${additionalParamString ? "&"+additionalParamString : ""}` } - history.push(`/${window?.contextPath}/employee/${actionLink}`); + history.push(`/${window?.contextPath}/employee/${actionLink}${additionalParamString ? "&"+additionalParamString : ""}`); } const onClickRow = ({original:row}) => { const [moduleName,masterName] = row.schemaCode.split(".") - history.push(`/${window.contextPath}/employee/workbench/mdms-view?moduleName=${moduleName}&masterName=${masterName}&uniqueIdentifier=${row.uniqueIdentifier}`) + const additionalParamString = new URLSearchParams(additionalParams).toString(); + history.push(`/${window.contextPath}/employee/workbench/mdms-view?moduleName=${moduleName}&masterName=${masterName}&uniqueIdentifier=${row.uniqueIdentifier}${additionalParamString ? "&"+additionalParamString : ""}`) } if (isLoading) return ; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSView.js b/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSView.js index 456afcb757f..597bce22a2a 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSView.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/MDMSView.js @@ -10,6 +10,19 @@ const MDMSView = ({...props}) => { const { t } = useTranslation() const [showToast, setShowToast] = useState(false); let { moduleName, masterName, tenantId,uniqueIdentifier } = Digit.Hooks.useQueryParams(); + let {from, screen, action} = Digit.Hooks.useQueryParams() + + const additionalParams = { + from: from, + screen: screen, + action: action + } + + Object.keys(additionalParams).forEach(key => { + if (additionalParams[key] === undefined || additionalParams[key] === null) { + delete additionalParams[key]; + } + }); // const stateId = Digit.ULBService.getStateId(); tenantId = Digit.ULBService.getCurrentTenantId(); const fetchActionItems = (data) => { @@ -115,7 +128,8 @@ const MDMSView = ({...props}) => { const {action:actionSelected} = action //action===EDIT go to edit screen if(actionSelected==="EDIT") { - history.push(`/${window?.contextPath}/employee/workbench/mdms-edit?moduleName=${moduleName}&masterName=${masterName}&uniqueIdentifier=${uniqueIdentifier}`) + const additionalParamString = new URLSearchParams(additionalParams).toString(); + history.push(`/${window?.contextPath}/employee/workbench/mdms-edit?moduleName=${moduleName}&masterName=${masterName}&uniqueIdentifier=${uniqueIdentifier}${additionalParamString ? "&"+additionalParamString : ""}`) } //action===DISABLE || ENABLE call update api and show toast respectively else{ diff --git a/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/index.js b/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/index.js index 7323cd7b205..d345963aa9e 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/index.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/pages/employee/index.js @@ -21,8 +21,8 @@ const WorkbenchBreadCrumb = ({ location, defaultPath }) => { const { t } = useTranslation(); const search = useLocation().search; const fromScreen = new URLSearchParams(search).get("from") || null; - const pathVar = location.pathname.replace(defaultPath + '/', "").split("?")?.[0]; - const { masterName, moduleName, uniqueIdentifier } = Digit.Hooks.useQueryParams() + const pathVar = location.pathname.replace(defaultPath + "/", "").split("?")?.[0]; + const { masterName, moduleName, uniqueIdentifier, from, screen, action } = Digit.Hooks.useQueryParams(); const crumbs = [ { @@ -33,36 +33,39 @@ const WorkbenchBreadCrumb = ({ location, defaultPath }) => { { path: `/${window.contextPath}/employee/workbench/manage-master-data`, content: t(`WBH_MANAGE_MASTER_DATA`), - show: pathVar.includes("mdms-") ? true : false, + show: from ? false : pathVar.includes("mdms-") ? true : false, // query:`moduleName=${moduleName}&masterName=${masterName}` }, { path: `/${window.contextPath}/employee/workbench/localisation-search`, content: t(`LOCALISATION_SEARCH`), - show: pathVar.includes("localisation-") ? true : false, - isBack: pathVar.includes("localisation-search") ? true : false + show: from ? false : pathVar.includes("localisation-") ? true : false, + isBack: pathVar.includes("localisation-search") ? true : false, // query:`moduleName=${moduleName}&masterName=${masterName}` }, { - path: `/${window.contextPath}/employee/workbench/mdms-search-v2`, - query: `moduleName=${moduleName}&masterName=${masterName}`, + path: pathVar !== "mdms-search-v2" ? `/${window.contextPath}/employee/workbench/mdms-search-v2` : null, + query: from + ? `moduleName=${moduleName}&masterName=${masterName}&from=${from}&screen=${screen}&action=${action}` + : `moduleName=${moduleName}&masterName=${masterName}`, content: t(`${Digit.Utils.workbench.getMDMSLabel(pathVar, masterName, moduleName)}`), - show: (masterName && moduleName) ? true : false, - isBack: pathVar.includes("mdms-search-v2") ? true : false + show: masterName && moduleName ? true : false, + isBack: pathVar.includes("mdms-search-v2") ? true : false, }, { path: `/${window.contextPath}/employee/workbench/mdms-view`, content: t(`MDMS_VIEW`), show: pathVar.includes("mdms-edit") ? true : false, - query: `moduleName=${moduleName}&masterName=${masterName}&uniqueIdentifier=${uniqueIdentifier}` + query: from + ? `moduleName=${moduleName}&masterName=${masterName}&uniqueIdentifier=${uniqueIdentifier}&from=${from}&screen=${screen}&action=${action}` + : `moduleName=${moduleName}&masterName=${masterName}&uniqueIdentifier=${uniqueIdentifier}`, }, { path: `/${window.contextPath}/employee/masters/response`, content: t(`${Digit.Utils.workbench.getMDMSLabel(pathVar, "", "")}`), show: Digit.Utils.workbench.getMDMSLabel(pathVar, "", "", ["mdms-search-v2", "localisation-search"]) ? true : false, }, - ]; return ; }; @@ -88,13 +91,13 @@ const App = ({ path }) => { }; const currentUrl = window.location.href; if (!currentUrl.includes("mdms-add-v2") && !currentUrl.includes("mdms-add-v4") && !currentUrl.includes("mdms-view")) { - clearSessionStorageWithPrefix('MDMS_add'); + clearSessionStorageWithPrefix("MDMS_add"); } if (!currentUrl.includes("mdms-view")) { - clearSessionStorageWithPrefix('MDMS_view'); + clearSessionStorageWithPrefix("MDMS_view"); } if (!currentUrl.includes("mdms-edit")) { - clearSessionStorageWithPrefix('MDMS_edit'); + clearSessionStorageWithPrefix("MDMS_edit"); } }, [window.location.href]); @@ -109,12 +112,10 @@ const App = ({ path }) => { return ( -
    - - {!isBoundaryPath && ( - - )} -
    +
    + + {!isBoundaryPath && } +
    diff --git a/micro-ui/web/micro-ui-internals/packages/react-components/package.json b/micro-ui/web/micro-ui-internals/packages/react-components/package.json index 3faeaec3640..b5a8ab19948 100644 --- a/micro-ui/web/micro-ui-internals/packages/react-components/package.json +++ b/micro-ui/web/micro-ui-internals/packages/react-components/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-react-components", - "version": "1.8.2-beta.12", + "version": "1.8.2-beta.13", "license": "MIT", "main": "dist/index.js", "module": "dist/index.modern.js", diff --git a/micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/EmployeeModuleCard.js b/micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/EmployeeModuleCard.js index 21fb1ae0a51..4270312a9d4 100644 --- a/micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/EmployeeModuleCard.js +++ b/micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/EmployeeModuleCard.js @@ -22,17 +22,32 @@ const EmployeeModuleCard = ({ Icon, moduleName, kpis = [], links = [], isCitizen {count || "-"}
    - - {link ? history.push(`${link}`,{count})}>{label} : null} + {link ? ( + history.push(`${link}`, { count })}> + {label} + + ) : null}
    ))} )}
    - {links.map(({ count, label, link }, index) => ( + {links.map(({ count, label, link, isOutsideModule }, index) => ( - {link ? (link?.includes(`${window?.contextPath}/`)?{label}:{label}) : null} + {link ? ( + link?.includes(`${window?.contextPath}/`) ? ( + isOutsideModule ? ( + history.push(`${link}`)}> + {label} + + ) : ( + {label} + ) + ) : ( + {label} + ) + ) : null} {count ? ( <> history.push(`${link}`)}>{count || "-"} @@ -50,7 +65,7 @@ const EmployeeModuleCard = ({ Icon, moduleName, kpis = [], links = [], isCitizen ); }; -const ModuleCardFullWidth = ({ moduleName, links = [], isCitizen = false, className, styles, headerStyle, subHeader, subHeaderLink }) => { +const ModuleCardFullWidth = ({ moduleName, links = [], isCitizen = false, className, styles, headerStyle, subHeader, subHeaderLink }) => { return (
    @@ -58,7 +73,11 @@ const ModuleCardFullWidth = ({ moduleName, links = [], isCitizen = false, class {moduleName} - history.push(`${link}`)}> + history.push(`${link}`)} + > {subHeader || "-"} {" "} @@ -72,7 +91,7 @@ const ModuleCardFullWidth = ({ moduleName, links = [], isCitizen = false, class
    {links.map(({ count, label, link }, index) => ( - {link ? (link?.includes(`${window?.contextPath}/`)?{label}:{label}) : null} + {link ? link?.includes(`${window?.contextPath}/`) ? {label} : {label} : null} ))}
    diff --git a/micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/UploadFile.js b/micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/UploadFile.js index a251c89e3eb..cb09a145583 100644 --- a/micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/UploadFile.js +++ b/micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/UploadFile.js @@ -177,7 +177,7 @@ const UploadFile = (props) => { }; const handleEmpty = () => { - if(inpRef.current.files.length <= 0 && prevSate !== null) + if(inpRef?.current?.files?.length <= 0 && prevSate !== null) { inpRef.current.value = ""; props.onDelete(); } @@ -212,9 +212,9 @@ const UploadFile = (props) => { props?.removeTargetedFile(fileDetailsData, e)} />
    })} - {props?.uploadedFiles.length === 0 &&

    {props?.message}

    } + {props?.uploadedFiles?.length === 0 &&

    {props?.message}

    } {!hasFile || props.error ? ( -

    {props.message}

    +

    {props?.message}

    ) : (
    diff --git a/micro-ui/web/micro-ui-internals/packages/react-components/src/molecules/SearchOnRadioButtons.js b/micro-ui/web/micro-ui-internals/packages/react-components/src/molecules/SearchOnRadioButtons.js index 318dd4b6aea..65de59c423b 100644 --- a/micro-ui/web/micro-ui-internals/packages/react-components/src/molecules/SearchOnRadioButtons.js +++ b/micro-ui/web/micro-ui-internals/packages/react-components/src/molecules/SearchOnRadioButtons.js @@ -1,4 +1,4 @@ -import React, { useReducer } from "react" +import React, { useEffect, useReducer } from "react" import RadioButtons from "../atoms/RadioButtons" import TextInput from "../atoms/TextInput" import { SearchIconSvg } from "../atoms/svgindex" @@ -9,9 +9,18 @@ const SearchOnRadioButtons = ({options,optionsKey,additionalWrapperClass,onSelec switch (action.type){ case "filter": return action.options.filter(i => i[optionsKey].toUpperCase().includes(action.payload.toUpperCase())) + default: + return state; + } } + useEffect(()=>{ + if(options){ + optionsDispatch({type: "filter", payload: "", options}) + } + },[options]) + const [ filteredOptions, optionsDispatch ] = useReducer(optionsReducer, options) function defaultSearchQueryChange(e){ diff --git a/micro-ui/web/public/index.html b/micro-ui/web/public/index.html index c776075ff80..f464561a097 100644 --- a/micro-ui/web/public/index.html +++ b/micro-ui/web/public/index.html @@ -7,7 +7,7 @@ - +