diff --git a/health/micro-ui/web/micro-ui-internals/example/public/index.html b/health/micro-ui/web/micro-ui-internals/example/public/index.html index 744f20ea3e..7b00f6e046 100644 --- a/health/micro-ui/web/micro-ui-internals/example/public/index.html +++ b/health/micro-ui/web/micro-ui-internals/example/public/index.html @@ -12,7 +12,7 @@ DIGIT - + diff --git a/health/micro-ui/web/micro-ui-internals/example/src/UICustomizations.js b/health/micro-ui/web/micro-ui-internals/example/src/UICustomizations.js index 0b4fefe01a..08953411b9 100644 --- a/health/micro-ui/web/micro-ui-internals/example/src/UICustomizations.js +++ b/health/micro-ui/web/micro-ui-internals/example/src/UICustomizations.js @@ -765,176 +765,177 @@ export const UICustomizations = { } }, }, - MicroplanSearchConfig: { - preProcess: (data, additionalDetails) => { - const { name, status } = data?.state?.searchForm || {}; - data.body.PlanConfigurationSearchCriteria = {}; - data.body.PlanConfigurationSearchCriteria.limit = data?.state?.tableForm?.limit; - // data.body.PlanConfigurationSearchCriteria.limit = 10 - data.body.PlanConfigurationSearchCriteria.offset = data?.state?.tableForm?.offset; - data.body.PlanConfigurationSearchCriteria.name = name; - data.body.PlanConfigurationSearchCriteria.tenantId = Digit.ULBService.getCurrentTenantId(); - data.body.PlanConfigurationSearchCriteria.userUuid = Digit.UserService.getUser().info.uuid; - // delete data.body.PlanConfigurationSearchCriteria.pagination - data.body.PlanConfigurationSearchCriteria.status = status?.status; - data.body.PlanConfigurationSearchCriteria.name = data?.state?.searchForm?.microplanName; - cleanObject(data.body.PlanConfigurationSearchCriteria); - - const dic = { - 0: null, - 1: ["DRAFT"], - 2: ["EXECUTION_TO_BE_DONE"], - 3: ["CENSUS_DATA_APPROVAL_IN_PROGRESS", "CENSUS_DATA_APPROVED", "RESOURCE_ESTIMATION_IN_PROGRESS"], - 4: ["RESOURCE_ESTIMATIONS_APPROVED"], - }; - const url = Digit.Hooks.useQueryParams(); - - const tabId = url.tabId || "0"; // Default to '0' if tabId is undefined - data.body.PlanConfigurationSearchCriteria.status = dic[String(tabId)]; - cleanObject(data.body.PlanConfigurationSearchCriteria); - return data; - }, - additionalCustomizations: (row, key, column, value, t, searchResult) => { - - switch (key) { - case "ACTIONS": - // TODO : Replace dummy file id with real file id when API is ready - const dummyFile = "c22a7676-d5d7-49b6-bcdb-83e9519f58df" - const microplanFileId = row?.campaignDetails?.additionalDetails?.microplanFileId || dummyFile; - let options = []; - - if (row?.status == "DRAFT") { - options = [{ code: "1", name: "MP_ACTIONS_EDIT_SETUP" }]; - } else { - options = [{ code: "1", name: "MP_ACTIONS_VIEW_SUMMARY" }]; - } - - const handleDownload = () => { - const files = row?.files; - const file = files.find((item) => item.templateIdentifier === "Population"); - const fileId = file?.filestoreId; - const campaignName = row?.name || ""; - if (!fileId) { - console.error("Population template file not found"); - return; - } - Digit.Utils.campaign.downloadExcelWithCustomName({ - fileStoreId: fileId, - customName: campaignName - }); - }; - - const onActionSelect = (e) => { - if (e.name == "MP_ACTIONS_EDIT_SETUP") { - window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${1}µplanId=${row.id}&campaignId=${ - row.campaignDetails.id - }`; - } - if (e.name == "MP_ACTIONS_VIEW_SUMMARY") { - window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${10}µplanId=${row.id}&campaignId=${ - row.campaignDetails.id - }&setup-completed=true`; + MicroplanSearchConfig: { + preProcess: (data, additionalDetails) => { + const { name, status } = data?.state?.searchForm || {}; + data.body.PlanConfigurationSearchCriteria = {}; + data.body.PlanConfigurationSearchCriteria.limit = data?.state?.tableForm?.limit; + // data.body.PlanConfigurationSearchCriteria.limit = 10 + data.body.PlanConfigurationSearchCriteria.offset = data?.state?.tableForm?.offset; + data.body.PlanConfigurationSearchCriteria.name = name; + data.body.PlanConfigurationSearchCriteria.tenantId = Digit.ULBService.getCurrentTenantId(); + data.body.PlanConfigurationSearchCriteria.userUuid = Digit.UserService.getUser().info.uuid; + // delete data.body.PlanConfigurationSearchCriteria.pagination + data.body.PlanConfigurationSearchCriteria.status = status?.status; + data.body.PlanConfigurationSearchCriteria.name = data?.state?.searchForm?.microplanName; + cleanObject(data.body.PlanConfigurationSearchCriteria); + + const dic = { + 0: null, + 1: ["DRAFT"], + 2: ["EXECUTION_TO_BE_DONE"], + 3: ["CENSUS_DATA_APPROVAL_IN_PROGRESS", "CENSUS_DATA_APPROVED", "RESOURCE_ESTIMATION_IN_PROGRESS"], + 4: ["RESOURCE_ESTIMATIONS_APPROVED"], + }; + const url = Digit.Hooks.useQueryParams(); + + const tabId = url.tabId || "0"; // Default to '0' if tabId is undefined + data.body.PlanConfigurationSearchCriteria.status = dic[String(tabId)]; + cleanObject(data.body.PlanConfigurationSearchCriteria); + return data; + }, + additionalCustomizations: (row, key, column, value, t, searchResult) => { + + switch (key) { + case "ACTIONS": + // TODO : Replace dummy file id with real file id when API is ready + const dummyFile = "c22a7676-d5d7-49b6-bcdb-83e9519f58df" + const microplanFileId = row?.campaignDetails?.additionalDetails?.microplanFileId || dummyFile; + let options = []; + + if (row?.status == "DRAFT") { + options = [{ code: "1", name: "MP_ACTIONS_EDIT_SETUP" }]; + } else { + options = [{ code: "1", name: "MP_ACTIONS_VIEW_SUMMARY" }]; } - }; - - return ( -
- {microplanFileId && row?.status == "RESOURCE_ESTIMATIONS_APPROVED" ? ( -
- -
- ) : ( -
-
- onActionSelect(item)} - /> -
-
- )} -
- ); - - case "NAME_OF_MICROPLAN": - if (value && value !== "NA") { - return ( -
-

{t(value)}

-
- ); - } else { - return ( -
-

{t("NA")}

-
- ); - } - - case "MICROPLAN_STATUS": - if (value && value != "NA") { - return

{t(Digit.Utils.locale.getTransformedLocale("MICROPLAN_STATUS_" + value))}

; - } else { - return ( -
-

{t("NA")}

-
- ); - } - - case "CAMPAIGN_DISEASE": - if (value && value != "NA") { - return

{t(Digit.Utils.locale.getTransformedLocale("MICROPLAN_DISEASE_" + value))}

; - } else { - return ( -
-

{t("NA")}

-
- ); - } - - case "CAMPAIGN_TYPE": - if (value && value != "NA") { - return

{t(Digit.Utils.locale.getTransformedLocale("MICROPLAN_TYPE_" + value))}

; - } else { - return ( -
-

{t("NA")}

-
- ); - } - - case "DISTIRBUTION_STRATEGY": - if (value && value != "NA") { - return

{t(Digit.Utils.locale.getTransformedLocale("MICROPLAN_DISTRIBUTION_" + value))}

; - } else { + + const handleDownload = () => { + const files = row?.files; + const file = files.find((item) => item.templateIdentifier === "Population"); + const fileId = file?.filestoreId; + if (!fileId) { + console.error("Population template file not found"); + return; + } + const campaignName = row?.name || ""; + Digit.Utils.campaign.downloadExcelWithCustomName({ + fileStoreId: fileId, + customName: campaignName + }); + }; + + const onActionSelect = (e) => { + if (e.name === "MP_ACTIONS_EDIT_SETUP") { + const key = parseInt(row?.additionalDetails?.key); + const resolvedKey = key === 8 ? 7 : key === 9 ? 10 : key || 2; + const url = `/${window.contextPath}/employee/microplan/setup-microplan?key=${resolvedKey}µplanId=${row.id}&campaignId=${row.campaignDetails.id}`; + window.location.href = url; + } + if (e.name == "MP_ACTIONS_VIEW_SUMMARY") { + window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${10}µplanId=${row.id}&campaignId=${ + row.campaignDetails.id + }&setup-completed=true`; + } + }; + return (
-

{t("NA")}

+ {microplanFileId && row?.status == "RESOURCE_ESTIMATIONS_APPROVED" ? ( +
+ +
+ ) : ( +
+
+ onActionSelect(item)} + /> +
+
+ )}
); - } - - default: - return null; // Handle any unexpected keys here if needed - } + + case "NAME_OF_MICROPLAN": + if (value && value !== "NA") { + return ( +
+

{t(value)}

+
+ ); + } else { + return ( +
+

{t("NA")}

+
+ ); + } + + case "MICROPLAN_STATUS": + if (value && value != "NA") { + return

{t(Digit.Utils.locale.getTransformedLocale("MICROPLAN_STATUS_" + value))}

; + } else { + return ( +
+

{t("NA")}

+
+ ); + } + + case "CAMPAIGN_DISEASE": + if (value && value != "NA") { + return

{t(Digit.Utils.locale.getTransformedLocale("MICROPLAN_DISEASE_" + value))}

; + } else { + return ( +
+

{t("NA")}

+
+ ); + } + + case "CAMPAIGN_TYPE": + if (value && value != "NA") { + return

{t(Digit.Utils.locale.getTransformedLocale("MICROPLAN_TYPE_" + value))}

; + } else { + return ( +
+

{t("NA")}

+
+ ); + } + + case "DISTIRBUTION_STRATEGY": + if (value && value != "NA") { + return

{t(Digit.Utils.locale.getTransformedLocale("MICROPLAN_DISTRIBUTION_" + value))}

; + } else { + return ( +
+

{t("NA")}

+
+ ); + } + + default: + return null; // Handle any unexpected keys here if needed + } + }, }, - }, MyMicroplanSearchConfig: { preProcess: (data, additionalDetails) => { const { name, status } = data?.state?.searchForm || {}; diff --git a/health/micro-ui/web/micro-ui-internals/packages/css/package.json b/health/micro-ui/web/micro-ui-internals/packages/css/package.json index 951a4bd11b..845e76cb11 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/css/package.json +++ b/health/micro-ui/web/micro-ui-internals/packages/css/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-health-css", - "version": "0.2.32", + "version": "0.2.33", "license": "MIT", "main": "dist/index.css", "author": "Jagankumar ", diff --git a/health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss b/health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss index e61a682368..8f234de9e8 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss +++ b/health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss @@ -531,4 +531,11 @@ tbody tr:last-child td:last-child .digit-dropdown-employee-select-wrap .digit-dr } } } +} + +.gap-between-dropdowns{ + display:flex; + flex-direction: column; + gap: 1rem; + } \ No newline at end of file diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadDataMapping.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadDataMapping.js index 2c6437898f..e9fa3db56f 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadDataMapping.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadDataMapping.js @@ -34,7 +34,7 @@ const reducer = (state, action) => { return { ...state, currentPage: action.payload, - currentData: getPageData(state.data, action.payload, state.rowsPerPage), // Update data for the new page + currentData: getPageData(state?.filter ? state?.currentData : state.data, action.payload, state.rowsPerPage), // Update data for the new page }; case "SET_ROWS_PER_PAGE": return { @@ -124,19 +124,20 @@ const reducer = (state, action) => { updated: true, }; case "FILTER_BY_ACTIVE": + const tempActive = action.payload?.filter + ? getPageData( + state.data?.filter((i) => + action?.currentCategories === "HCM_UPLOAD_USER_MAPPING" + ? i?.[action.t(action?.schemas?.find((i) => i.description === "User Usage")?.name)] === "Active" + : i?.[action.t(action?.schemas?.find((i) => i.description === "Facility usage")?.name)] === "Active" + ), + 1, + state.rowsPerPage, + ) + : getPageData(state.data, 1, state.rowsPerPage); return { ...state, - currentData: action.payload?.filter - ? getPageData( - state.data?.filter((i) => - action?.currentCategories === "HCM_UPLOAD_USER_MAPPING" - ? i?.[action.t(action?.schemas?.find((i) => i.description === "User Usage")?.name)] === "Active" - : i?.[action.t(action?.schemas?.find((i) => i.description === "Facility usage")?.name)] === "Active" - ), - state.currentPage, - state.rowsPerPage - ) - : getPageData(state.data, state.currentPage, state.rowsPerPage), // Update data for the new page + currentData: tempActive, // Update data for the new page totalRows: action.payload?.filter ? state.data?.filter((i) => action?.currentCategories === "HCM_UPLOAD_USER_MAPPING" @@ -218,6 +219,7 @@ function UploadDataMapping({ formData, onSelect, currentCategories }) { const schemaFilter = currentCategories === "HCM_UPLOAD_FACILITY_MAPPING" ? "facility" : "user"; const [state, dispatch] = useReducer(reducer, initialState); const boundaryHierarchy = paramsData?.hierarchy?.boundaryHierarchy; + const [rowsPerPage, setRowsPerPage] = useState(5); const { data: Schemas, isLoading: isThisLoading, refetch: refetchSchema } = Digit.Hooks.useCustomMDMS( tenantId, CONSOLE_MDMS_MODULENAME, @@ -346,6 +348,7 @@ function UploadDataMapping({ formData, onSelect, currentCategories }) { dispatch({ type: "SET_PAGE", payload: page, schemas: Schemas, t: t }); }; const handleRowsPerPageChange = (newPerPage) => { + setRowsPerPage(newPerPage); // Update the rows per page state dispatch({ type: "SET_ROWS_PER_PAGE", payload: newPerPage, schemas: Schemas, t: t }); }; @@ -413,20 +416,49 @@ function UploadDataMapping({ formData, onSelect, currentCategories }) { { name: t("BOUNDARY"), cell: (row) => { + const listOfBoundaries = row?.[t(Schemas?.find((i) => i.description === "Boundary Code (Mandatory)")?.name)]?.split(",") || []; return ( - <> - {row?.[t(Schemas?.find((i) => i.description === "Boundary Code (Mandatory)")?.name)] || t("NA")} +
+
+ {listOfBoundaries.slice(0, 2).map((item, index) => ( + + ))} + {listOfBoundaries?.length > 2 && ( +
); }, }, @@ -525,7 +557,7 @@ function UploadDataMapping({ formData, onSelect, currentCategories }) { size={"small"} isDisabled={row?.[t(Schemas?.find((i) => i.description === "Facility usage")?.name)] === "Inactive" ? true : false} variation={"teritiary"} - label={t("CHANGE_BOUNDARY")} + label={listOfBoundaries?.length > 0 ? t("CHANGE_BOUNDARY") : t("ADD _BOUNDARY")} onClick={() => { setShowPopUp(row); }} @@ -560,7 +592,11 @@ function UploadDataMapping({ formData, onSelect, currentCategories }) { /> {state?.currentData?.length === 0 ? ( - + ) : ( - {t("FACILITY_MAPPING_POP_HEADER")} + + {currentCategories === "HCM_UPLOAD_FACILITY_MAPPING" ? t("FACILITY_MAPPING_POP_HEADER_TITLE") : t("USER_MAPPING_POP_HEADER_TITLE")} + {t("CHOOSE_BOUNDARY_LEVEL")} - {t("CHOOSE_BOUNDARY_LEVEL")} + {t("CHOOSE_BOUNDARY")} { config: { enabled: true, select: (data) => { - + if (projectType === "CO-DEL") { + return data?.ProductVariant; + } const filteredData = data?.ProductVariant?.filter(item => item.additionalFields?.fields?.some(field => field.key === "projectType" && field.value === projectType) ); diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/deliveryRule/AddDeliverycontext.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/deliveryRule/AddDeliverycontext.js index 33c0ac6e1f..c18c0cc9df 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/deliveryRule/AddDeliverycontext.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/deliveryRule/AddDeliverycontext.js @@ -10,7 +10,7 @@ import { CloseSvg, } from "@egovernments/digit-ui-react-components"; import { SVG } from "@egovernments/digit-ui-react-components"; -import React, { Fragment, useContext, useEffect, useRef, useState } from "react"; +import React, { Fragment, useContext, useEffect, useRef, useState , useMemo} from "react"; import { useTranslation } from "react-i18next"; import AddProducts from "./AddProductscontext"; import { CycleContext } from "."; @@ -46,18 +46,48 @@ const AddAttributeField = ({ onDelete, attributeConfig, operatorConfig, - genderConfig, + tenantId }) => { const [val, setVal] = useState(""); const [showAttribute, setShowAttribute] = useState(null); const [showOperator, setShowOperator] = useState(null); const [addedOption, setAddedOption] = useState(null); + const [dropdownOption, setDropdownOption] = useState(null); const { t } = useTranslation(); useEffect(() => { setAddedOption(delivery?.attributes?.map((i) => i?.attribute?.code)?.filter((i) => i)); }, [delivery, deliveryRules]); + const schemaCode = useMemo(() => { + const code = showAttribute?.valuesSchema; + return code; + }, [showAttribute]); + + + const { data: structureConfig } = Digit.Hooks.useCustomMDMS( + tenantId, + schemaCode?.split(".")[0] || "", // Provide a fallback to avoid errors + schemaCode ? [{ name: schemaCode.split(".")[1] }] : [], // Run only if schemaCode is defined + schemaCode + ? { + select: (data) => { + const moduleName = schemaCode.split(".")[0]; + const schemaName = schemaCode.split(".")[1]; + return data?.[moduleName]?.[schemaName]; + }, + } + : null, // Pass null if schemaCode is undefined + schemaCode ? { schemaCode } : null // Include schemaCode only if it's defined +); + + useEffect(() => { + if (showAttribute) { + setDropdownOption(structureConfig); + } + }, [showAttribute, structureConfig, attributeConfig]); + + const selectValue = (e) => { let val = e.target.value; val = val.replace(/[^\d.]/g, ""); @@ -79,7 +109,7 @@ const AddAttributeField = ({ setDeliveryRules(updatedData); }; - const selectGender = (value) => { + const selectDropdownValue = (value) => { // setAttributes((pre) => pre.map((item) => (item.key === attribute.key ? { ...item, value: e.target.value } : item))); const updatedData = deliveryRules.map((item, index) => { if (item.ruleKey === deliveryRuleIndex) { @@ -122,16 +152,16 @@ const AddAttributeField = ({ }; const selectAttribute = (value) => { - // setAttributes((pre) => pre.map((item) => (item.key === attribute.key ? { ...item, value: e.target.value } : item))); const updatedData = deliveryRules.map((item, index) => { if (item.ruleKey === deliveryRuleIndex) { item.attributes.find((i) => i.key === attribute.key).attribute = value; item.attributes.find((i) => i.key === attribute.key).value = ""; item.attributes.find((i) => i.key === attribute.key).toValue = ""; item.attributes.find((i) => i.key === attribute.key).fromValue = ""; - if (value.code === "Gender") { + const defaultOperator = value.allowedOperators?.[0] || null; + if (defaultOperator) { item.attributes.find((i) => i.key === attribute.key).operator = { - code: "EQUAL_TO", + code: defaultOperator, }; } } @@ -179,7 +209,7 @@ const AddAttributeField = ({ selectOperator(value)} @@ -222,15 +252,29 @@ const AddAttributeField = ({ ) : ( {t(`CAMPAIGN_VALUE_LABEL`)} -
- {attribute?.attribute?.code === "Gender" ? ( +
+ {(typeof attribute?.value === "string" && /^[a-zA-Z]+$/.test(attribute?.value)) || + attribute?.attribute?.valuesSchema || + isNaN(attribute?.value) ? ( selectGender(value)} + option={dropdownOption} + select={(value) => selectDropdownValue(value)} optionKey="code" t={t} /> @@ -263,290 +307,24 @@ const AddAttributeField = ({ ); }; -const AddCustomAttributeField = ({ - config, - deliveryRuleIndex, - delivery, - deliveryRules, - setDeliveryRules, - attribute, - setAttributes, - index, - onDelete, - operatorConfig, - genderConfig, -}) => { - const [val, setVal] = useState(""); - const [showAttribute, setShowAttribute] = useState(null); - const [showOperator, setShowOperator] = useState(null); - const [addedOption, setAddedOption] = useState(null); - const { t } = useTranslation(); - const { attrConfig } = useContext(CycleContext); - - useEffect(() => { - setAddedOption(delivery?.attributes?.map((i) => i?.attribute?.code)?.filter((i) => i)); - }, [delivery]); - - const selectValue = (e) => { - let val = e.target.value; - val = val.replace(/[^\d.]/g, ""); - val = val.match(/^\d*\.?\d{0,2}/)[0] || ""; - // if (val.startsWith("-")) { - // val = val.slice(1); // Remove the negative sign - // } - if (isNaN(val) || [" ", "e", "E"].some((f) => val.includes(f))) { - val = val.slice(0, -1); - } - // setAttributes((pre) => pre.map((item) => (item.key === attribute.key ? { ...item, value: e.target.value } : item))); - const updatedData = deliveryRules.map((item, index) => { - if (item.ruleKey === deliveryRuleIndex) { - item.attributes.find((i) => i.key === attribute.key).value = val; - } - return item; - }); - setDeliveryRules(updatedData); - }; - - const selectOperator = (value) => { - // setAttributes((pre) => pre.map((item) => (item.key === attribute.key ? { ...item, value: e.target.value } : item))); - const updatedData = deliveryRules.map((item, index) => { - if (item.ruleKey === deliveryRuleIndex) { - item.attributes.find((i) => i.key === attribute.key).operator = value; - } - return item; - }); - setShowOperator(value); - setDeliveryRules(updatedData); - }; - - const selectToFromValue = (e, range) => { - let val = e.target.value; - val = val.replace(/[^\d.]/g, ""); - val = val.match(/^\d*\.?\d{0,2}/)[0] || ""; - // if (val.startsWith("-")) { - // val = val.slice(1); // Remove the negative sign - // } - if (isNaN(val) || [" ", "e", "E"].some((f) => val.includes(f))) { - val = val.slice(0, -1); - return; - } - if (range === "to") { - const updatedData = deliveryRules.map((item, index) => { - if (item.ruleKey === deliveryRuleIndex) { - item.attributes.find((i) => i.key === attribute.key).toValue = val; - } - return item; - }); - setDeliveryRules(updatedData); - } else { - const updatedData = deliveryRules.map((item, index) => { - if (item.ruleKey === deliveryRuleIndex) { - item.attributes.find((i) => i.key === attribute.key).fromValue = val; - } - return item; - }); - setDeliveryRules(updatedData); - } - }; - - return ( -
- - - {t(`CAMPAIGN_ATTRIBUTE_LABEL`)} - -
- -
- {/* !addedOption.includes(item.code)) : attributeConfig} - select={(value) => selectAttribute(value)} - optionKey="code" - t={t} - /> */} -
- - - {t(`CAMPAIGN_OPERATOR_LABEL`)} - - selectOperator(value)} - optionKey="code" - t={t} - /> - - {attribute?.operator?.code === "IN_BETWEEN" ? ( -
- - {t(`CAMPAIGN_FROM_LABEL`)} -
-
- selectToFromValue(e, "to")} - disable={false} - /> -
-
-
- - {t(`CAMPAIGN_TO_LABEL`)} -
-
- selectToFromValue(e, "from")} - disable={false} - /> -
-
-
-
- ) : ( - - {t(`CAMPAIGN_VALUE_LABEL`)} -
- {attribute?.attribute?.code === "Gender" ? ( - selectGender(value)} - optionKey="code" - t={t} - /> - ) : ( - - )} -
-
- )} -
- ); -}; - -const AddIRSCustomAttributeField = ({ - config, - deliveryRuleIndex, - delivery, - deliveryRules, - setDeliveryRules, - attribute, - setAttributes, - index, - onDelete, - operatorConfig, - structureConfig, -}) => { - const [val, setVal] = useState(""); - const [showAttribute, setShowAttribute] = useState(null); - const [showOperator, setShowOperator] = useState(null); - const [addedOption, setAddedOption] = useState(null); - const { t } = useTranslation(); - const { attrConfig } = useContext(CycleContext); - - useEffect(() => { - setAddedOption(delivery?.attributes?.map((i) => i?.attribute?.code)?.filter((i) => i)); - }, [delivery]); - - const selectStructureType = (value) => { - // setAttributes((pre) => pre.map((item) => (item.key === attribute.key ? { ...item, value: e.target.value } : item))); - const updatedData = deliveryRules.map((item, index) => { - if (item.ruleKey === deliveryRuleIndex) { - item.attributes.find((i) => i.key === attribute.key).attribute = { code: "TYPE_OF_STRUCTURE"}; - item.attributes.find((i) => i.key === attribute.key).operator = { code: "EQUAL_TO" }; - item.attributes.find((i) => i.key === attribute.key).value = value?.code; - } - return item; - }); - setDeliveryRules(updatedData); - }; - - const selectOperator = (value) => { - // setAttributes((pre) => pre.map((item) => (item.key === attribute.key ? { ...item, value: e.target.value } : item))); - const updatedData = deliveryRules.map((item, index) => { - if (item.ruleKey === deliveryRuleIndex) { - item.attributes.find((i) => i.key === attribute.key).operator = value; - } - return item; - }); - setShowOperator(value); - setDeliveryRules(updatedData); - }; - - return ( -
- - - {t(`CAMPAIGN_ATTRIBUTE_LABEL`)} - -
- -
-
- - - {t(`CAMPAIGN_OPERATOR_LABEL`)} - - - - - {t(`CAMPAIGN_VALUE_LABEL`)} -
- selectStructureType(value)} - optionKey="code" - t={t} - /> -
-
-
- ); -}; - const AddAttributeWrapper = ({ targetedData, deliveryRuleIndex, delivery, deliveryRules, setDeliveryRules, index, key }) => { const { campaignData, dispatchCampaignData, filteredDeliveryConfig } = useContext(CycleContext); const { t } = useTranslation(); const tenantId = Digit.ULBService.getCurrentTenantId(); - const { isLoading: attributeConfigLoading, data: attributeConfig } = Digit.Hooks.useCustomMDMS( + const { isLoading: commonAttributesLoading, data: attributeConfig } = Digit.Hooks.useCustomMDMS( tenantId, CONSOLE_MDMS_MODULENAME, - [{ name: "attributeConfig" }], + [{ name: "allAttributes" }], { select: (data) => { - return data?.[CONSOLE_MDMS_MODULENAME]?.attributeConfig; + const attributeConfig = data?.[CONSOLE_MDMS_MODULENAME]?.allAttributes; + const projectType = filteredDeliveryConfig?.projectType; + return attributeConfig.filter((attribute) => + attribute.projectTypes?.includes(projectType) + ); }, }, - { schemaCode: `${CONSOLE_MDMS_MODULENAME}.attributeConfig` } + { schemaCode: `${CONSOLE_MDMS_MODULENAME}.allAttributes` } ); const { isLoading: operatorConfigLoading, data: operatorConfig } = Digit.Hooks.useCustomMDMS( tenantId, @@ -561,24 +339,6 @@ const AddAttributeWrapper = ({ targetedData, deliveryRuleIndex, delivery, delive ); - const { isLoading: genderConfigLoading, data: genderConfig } = Digit.Hooks.useCustomMDMS(tenantId, "common-masters", [{ name: "GenderType" }], { - select: (data) => { - return data?.["common-masters"]?.GenderType?.filter((i) => i.active !== false); - }, - }, { schemaCode: `${"common-masters"}.GenderType` } -); - - const { data: structureConfig } = Digit.Hooks.useCustomMDMS( - tenantId, - "HCM", - [{ name: "HOUSE_STRUCTURE_TYPES" }], - { - select: (data) => { - return data?.["HCM"]?.["HOUSE_STRUCTURE_TYPES"]; - }, - }, - { schemaCode: `${"HCM"}.HOUSE_STRUCTURE_TYPES` } - ); const [attributes, setAttributes] = useState([{ key: 1, deliveryRuleIndex, attribute: "", operator: "", value: "" }]); const reviseIndexKeys = () => { @@ -622,68 +382,27 @@ const AddAttributeWrapper = ({ targetedData, deliveryRuleIndex, delivery, delive const selectedStructureCodes = campaignData?.flatMap((cycle) => cycle?.deliveries?.flatMap((delivery) => delivery?.deliveryRules?.flatMap((rule) => rule?.attributes?.map((attribute) => attribute?.value))) ); - - const filteredStructureConfig = structureConfig?.filter((structure) => !selectedStructureCodes.includes(structure?.code)); - return ( - {filteredDeliveryConfig?.customAttribute && filteredDeliveryConfig?.projectType === "LLIN-mz" - ? delivery.attributes.map((item, index) => ( - deleteAttribute(item, deliveryRuleIndex)} - operatorConfig={operatorConfig} - genderConfig={genderConfig} - /> - )) - : filteredDeliveryConfig?.customAttribute && filteredDeliveryConfig?.projectType === "IRS-mz" - ? delivery.attributes.map((item, index) => ( - deleteAttribute(item, deliveryRuleIndex)} - operatorConfig={operatorConfig} - structureConfig={filteredStructureConfig} - /> - )) - : delivery.attributes.map((item, index) => ( - deleteAttribute(item, deliveryRuleIndex)} - attributeConfig={attributeConfig} - operatorConfig={operatorConfig} - genderConfig={genderConfig} - /> - ))} + { + delivery.attributes.map((item, index) => ( + deleteAttribute(item, deliveryRuleIndex)} + attributeConfig={attributeConfig} + operatorConfig={operatorConfig} + tenantId = {tenantId} + /> + )) + } {!filteredDeliveryConfig?.attrAddDisable && delivery.attributes.length !== attributeConfig?.length && (
diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js index 8b65739235..9b958aa037 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js @@ -33,7 +33,7 @@ const PlanInbox = () => { const [hierarchyLevel, setHierarchyLevel] = useState(""); const [censusData, setCensusData] = useState([]); const [boundaries, setBoundaries] = useState([]); - const [selectedFilter, setSelectedFilter] = useState(null); + const [selectedFilter, setSelectedFilter] = useState({status:"PENDING_FOR_VALIDATION",onRoadCondition:null,terrain:null,securityQ1:null,securityQ2:null}); const [activeFilter, setActiveFilter] = useState({}); const [actionBarPopUp, setactionBarPopUp] = useState(false); const [selectedRows, setSelectedRows] = useState([]); @@ -120,7 +120,7 @@ const PlanInbox = () => { }; useEffect(() => { - if (selectedFilter === "VALIDATED") { + if (selectedFilter?.status === "VALIDATED") { setActiveLink({ code: "", name: "" }); setShowTab(false); } else { @@ -132,7 +132,7 @@ const PlanInbox = () => { setShowTab(true); } } - }, [selectedFilter]); + }, [selectedFilter?.status]); const selectProps = { hideLabel: true, @@ -171,7 +171,11 @@ const PlanInbox = () => { tenantId: tenantId, active: true, jurisdiction: censusJurisdiction, - status: selectedFilter !== null && selectedFilter !== undefined ? selectedFilter : "", + status: selectedFilter?.status !== null && selectedFilter?.status !== undefined ? selectedFilter?.status : null, + ...(selectedFilter?.onRoadCondition != null && { onRoadCondition: selectedFilter.onRoadCondition }), + ...(selectedFilter?.terrain != null && { terrain: selectedFilter.terrain }), + ...(selectedFilter?.securityQ1 != null && { securityQ1: selectedFilter.securityQ1 }), + ...(selectedFilter?.securityQ2 != null && { securityQ2: selectedFilter.securityQ2 }), assignee: user.info.uuid, planConfigurationId: microplanId, limit: limitAndOffset?.limit, @@ -206,8 +210,12 @@ const PlanInbox = () => { tenantId: tenantId, active: true, jurisdiction: censusJurisdiction, - status: selectedFilter !== null && selectedFilter !== undefined ? selectedFilter : "", - ...(activeLink.code == "ASSIGNED_TO_ALL" || selectedFilter == "VALIDATED" ? {} : { assignee: user.info.uuid }), + status: selectedFilter?.status !== null && selectedFilter?.status !== undefined ? selectedFilter?.status : "", + ...(activeLink.code == "ASSIGNED_TO_ALL" || selectedFilter?.status == "VALIDATED" ? {} : { assignee: user.info.uuid }), + ...(selectedFilter?.terrain != null && { terrain: selectedFilter.terrain }), + ...(selectedFilter?.onRoadCondition != null && { onRoadCondition: selectedFilter.onRoadCondition }), + ...(selectedFilter?.securityQ1 != null && { securityQ1: selectedFilter.securityQ1 }), + ...(selectedFilter?.securityQ2 != null && { securityQ2: selectedFilter.securityQ2 }), planConfigurationId: microplanId, //list of plan ids limit: limitAndOffset?.limit, offset: limitAndOffset?.offset, @@ -366,7 +374,7 @@ const PlanInbox = () => { businessServices: "PLAN_ESTIMATION", }, config: { - enabled: selectedFilter ? true : false, + enabled: selectedFilter?.status ? true : false, select: (data) => { return data.BusinessServices?.[0]; }, @@ -375,8 +383,8 @@ const PlanInbox = () => { useEffect(() => { if (workflowData) { - // Assume selectedFilter maps to applicationStatus or state - const selectedState = workflowData?.states?.find((state) => state.state === selectedFilter); + // Assume selectedFilter.filterValue maps to applicationStatus or state + const selectedState = workflowData?.states?.find((state) => state.state === selectedFilter?.status); // Filter actions based on the selected state const availableActions = selectedState?.actions?.filter((action) => action.roles.some((role) => userRoles.includes(role))); @@ -384,7 +392,7 @@ const PlanInbox = () => { // Update the available actions state setAvailableActionsForUser(availableActions || []); } - }, [workflowData, selectedFilter]); + }, [workflowData, selectedFilter?.status]); // if availableActionsForUser is defined and is an array const actionsMain = availableActionsForUser?.length > 0 ? availableActionsForUser : []; @@ -409,15 +417,18 @@ const PlanInbox = () => { ); setActiveFilter(reorderedStatusCount); const activeFilterKeys = Object.keys(reorderedStatusCount || {}); - if (selectedFilter === null || selectedFilter === undefined || selectedFilter === "" || !activeFilterKeys.includes(selectedFilter)) { - setSelectedFilter(activeFilterKeys[0]); + if (selectedFilter?.filterValue === null || selectedFilter?.status=== undefined || selectedFilter?.status === "") { + setSelectedFilter((prev) => ({ + ...prev, // Spread the previous state to retain other attributes + })); + } setVillagesSelected(0); setSelectedRows([]); if (activeLink.code === "ASSIGNED_TO_ME") { setAssignedToMeCount(planWithCensus?.TotalCount); - setAssignedToAllCount(planWithCensus?.StatusCount[selectedFilter] || 0); + setAssignedToAllCount(planWithCensus?.StatusCount[selectedFilter?.status] || 0); } else { setAssignedToAllCount(planWithCensus?.TotalCount); } @@ -425,13 +436,13 @@ const PlanInbox = () => { const uniqueAssignees = [...new Set(planWithCensus?.planData?.flatMap((item) => item.assignee || []))]; setAssigneeUuids(uniqueAssignees.join(",")); } - }, [planWithCensus, selectedFilter, activeLink]); + }, [planWithCensus, selectedFilter?.status, activeLink]); useEffect(() => { if (censusJurisdiction?.length > 0) { refetchPlanWithCensus(); // Trigger the API call again after activeFilter changes } - }, [selectedFilter, activeLink, censusJurisdiction, limitAndOffset]); + }, [selectedFilter?.status, activeLink, censusJurisdiction, limitAndOffset]); const reqCri = { url: `/${hrms_context_path}/employees/_search`, @@ -484,7 +495,7 @@ const PlanInbox = () => { }, [processData]); useEffect(() => { - if (selectedFilter === "VALIDATED") { + if (selectedFilter?.status === "VALIDATED") { setActiveLink({ code: "", name: "" }); setShowTab(false); } else { @@ -496,10 +507,15 @@ const PlanInbox = () => { setShowTab(true); } } - }, [selectedFilter]); + }, [selectedFilter?.status]); - const onFilter = (selectedStatus) => { - setSelectedFilter(selectedStatus?.code); + const onFilter = (filterValue) => { + setSelectedFilter((prev)=>( + { + ...prev, + ...filterValue + } + )); setCurrentPage(1); setLimitAndOffset((prev)=>{ return { @@ -513,10 +529,10 @@ const PlanInbox = () => { }); }; - const clearFilters = () => { - if (selectedFilter !== Object.entries(activeFilter)?.[0]?.[0]) { - setSelectedFilter(Object.entries(activeFilter)?.[0]?.[0]); - } + const clearFilters = () => { + setSelectedFilter((prev)=>({ + status:Object.entries(activeFilter)?.[0]?.[0] + })); setCurrentPage(1); setLimitAndOffset((prev)=>{ return { @@ -787,13 +803,13 @@ const PlanInbox = () => { }; const getButtonState = (action) => { - if (selectedFilter === "PENDING_FOR_VALIDATION" && action === "VALIDATE") { + if (selectedFilter?.status === "PENDING_FOR_VALIDATION" && action === "VALIDATE") { return true; } - if (selectedFilter === "PENDING_FOR_APPROVAL" && (action === "APPROVE" || action === "ROOT_APPROVE")) { + if (selectedFilter?.status === "PENDING_FOR_APPROVAL" && (action === "APPROVE" || action === "ROOT_APPROVE")) { return true; } - if (selectedFilter === "VALIDATED" && action === "SEND_BACK_FOR_CORRECTION") { + if (selectedFilter?.status === "VALIDATED" && action === "SEND_BACK_FOR_CORRECTION") { return true; } return false; @@ -836,10 +852,12 @@ const PlanInbox = () => {
{`${t("HCM_MICROPLAN_MICROPLAN_NAME_LABEL")}: ${campaignObject?.campaignName || t("NO_NAME_AVAILABLE")}`}
-
{`${t("LOGGED_IN_AS")} ${userName} - ${t(userRole)}`}
+
{`${t("LOGGED_IN_AS")} ${userName} - ${t(userRole)}${planEmployee?.planData?.[0]?.hierarchyLevel ? + ` (${t(planEmployee.planData[0].hierarchyLevel.toUpperCase())})` : ""}`} +
- + { options={activeFilter} onApplyFilters={onFilter} clearFilters={clearFilters} - defaultValue={{ [selectedFilter]: activeFilter[selectedFilter] }} + defaultValue={selectedFilter} >
@@ -993,7 +1011,7 @@ const PlanInbox = () => { ) : planWithCensus?.tableData?.length === 0 ? ( ) : ( diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js index 793350d96b..53b574fe3a 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js @@ -611,7 +611,10 @@ const PopInbox = () => { {`${t("HCM_MICROPLAN_MICROPLAN_NAME_LABEL")}: ${planObject?.name || t("NO_NAME_AVAILABLE")}`}
- {`${t("LOGGED_IN_AS")} ${userName} - ${t(userRole)}`} + {`${t("LOGGED_IN_AS")} ${userName} - ${t(userRole)}${planEmployee?.planData + ? ` (${t(planEmployee.planData[0].hierarchyLevel.toUpperCase())})` : ""}` + } +
diff --git a/health/micro-ui/web/public/index.html b/health/micro-ui/web/public/index.html index ffce7b9768..58a2485aef 100644 --- a/health/micro-ui/web/public/index.html +++ b/health/micro-ui/web/public/index.html @@ -10,7 +10,7 @@ - + DIGIT HCM