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/modules/microplan/src/components/AssumptionsForm.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/AssumptionsForm.js index bd0f15a95a..9a53d0c238 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/AssumptionsForm.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/AssumptionsForm.js @@ -67,8 +67,12 @@ const AssumptionsForm = ({ onSelect, ...props }) => { }, [selectedDistributionProcess, selectedRegistrationDistributionMode, selectedRegistrationProcess, resourceDistributionStrategyCode]) - - + + useEffect(()=>{ + setSelectedRegistrationDistributionMode(props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm?.selectedRegistrationDistributionMode); + setSelectedDistributionProcess(props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm?.selectedDistributionProcess); + setSelectedRegistrationProcess(props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm?.selectedRegistrationProcess); + },[props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm]) const filteredOptions = resourceDistributionStrategyCode === "MIXED" ? optionsForProcesses.filter(option => option.resourceDistributionStrategyName !== "Fixed post & House-to-House") diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/UserUpload.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/UserUpload.js index f203ad1ec4..fe37365460 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/UserUpload.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/UserUpload.js @@ -410,7 +410,7 @@ const UserUpload = React.memo(() => { history.push(`/${window.contextPath}/employee/microplan/upload-user-success`, { fileName: fileName, message: "USER_DATA_UPLOAD_SUCCESSFUL", - description: "The user data uploaded will be available in your microplan user assignment", + description: "MP_USER_DATA_UPLOADED_WILL_BE_AVAILABLE", back: "GO_BACK_TO_USER_MANAGEMENT", backlink: `/${window.contextPath}/employee/microplan/user-management`, }); diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js index 45b1f7d43c..78c6e03883 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js @@ -107,10 +107,11 @@ export const UICustomizations = { }; 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_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=${ diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/createUpdatePlanProject.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/createUpdatePlanProject.js index a1cd80eee6..49a2fd57ff 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/createUpdatePlanProject.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/createUpdatePlanProject.js @@ -199,6 +199,7 @@ const UpdateResource = async (req, currentPlanObject, currentCampaignObject) => const updatedPlanObject = { ...currentPlanObject, name: totalFormData?.MICROPLAN_DETAILS?.microplanDetails?.microplanName, + additionalDetails:{...currentPlanObject.additionalDetails,key:req?.config?.key || "2"} }; const planRes = await Digit.CustomService.getResponse({ @@ -274,7 +275,8 @@ const createUpdatePlanProject = async (req) => { //later this object must have an invalidation config which can be used to invalidate data such as files uploaded,assumptions,formulas etc... const { totalFormData, state, setShowToast, setCurrentKey, setCurrentStep, config, invalidateConfig } = req; - const { microplanId, campaignId } = Digit.Hooks.useQueryParams(); + const { microplanId, campaignId,key} = Digit.Hooks.useQueryParams(); + // const key=config?.key; const tenantId = Digit.ULBService.getCurrentTenantId(); //now basically we need to decide from which screen this hook was triggered and take action accordingly let planObject = {}; @@ -399,6 +401,7 @@ const createUpdatePlanProject = async (req) => { //invalidate files const updatedPlanObjectForBoundaryInvalidate = { ...fetchedPlanForBoundaryInvalidate, + additionalDetails:{...fetchedPlanForBoundaryInvalidate.additionalDetails,key:key}, files: fetchedPlanForBoundaryInvalidate?.files?.length > 0 ? fetchedPlanForBoundaryInvalidate?.files?.map((file) => { @@ -409,6 +412,8 @@ const createUpdatePlanProject = async (req) => { }) : [], }; + + // update plan object const planUpdateForBoundaryInvalidation = await updatePlan(updatedPlanObjectForBoundaryInvalidate); @@ -478,6 +483,7 @@ const createUpdatePlanProject = async (req) => { totalFormData.CAMPAIGN_DETAILS.campaignDetails.distributionStrat.resourceDistributionStrategyCode === "MIXED" ? "SEPARATELY" : totalFormData.ASSUMPTIONS_FORM.assumptionsForm.selectedRegistrationDistributionMode?.code, + key:key }, }; const planResAssumptionsForm = await updatePlan(updatedPlanObjAssumptionsForm); @@ -514,6 +520,7 @@ const createUpdatePlanProject = async (req) => { const upatedPlanObjHypothesis = { ...fetchedPlanForHypothesis, assumptions: [...prevAssumptions, ...assumptionsToUpdate], + additionalDetails:{...fetchedPlanForHypothesis.additionalDetails,key:key} }; const planResHypothesis = await updatePlan(upatedPlanObjHypothesis); @@ -555,6 +562,7 @@ const createUpdatePlanProject = async (req) => { const upatedPlanObjSubHypothesis = { ...fetchedPlanForSubHypothesis, assumptions: [...prevAssumptionsForSubHypothesis, ...assumptionsToUpdateFromUI], + additionalDetails:{...fetchedPlanForSubHypothesis.additionalDetails,key:key} }; await updatePlan(upatedPlanObjSubHypothesis); @@ -600,6 +608,7 @@ const createUpdatePlanProject = async (req) => { //here we need to update the source of operations const updatedPlanObjFormula = { ...fetchedPlanForFormula, + additionalDetails:{...fetchedPlanForFormula.additionalDetails,key:key}, operations: [...prevFormulas, ...formulasToUpdateWithUpdatedSource], }; @@ -652,8 +661,8 @@ const createUpdatePlanProject = async (req) => { const upatedPlanObjSubFormula = { ...fetchedPlanForSubFormula, operations: [...prevFormulaValues, ...formulasToUpdateFromUIForSubFormula], + additionalDetails:{...fetchedPlanForSubFormula.additionalDetails,key:key} }; - await updatePlan(upatedPlanObjSubFormula); return; @@ -684,6 +693,7 @@ const createUpdatePlanProject = async (req) => { const updatedPlanObjForBoundary = { ...fetchedPlanForBoundary, files, + additionalDetails:{...fetchedPlanForBoundary.additionalDetails,key:key} }; const planResBoundary = await updatePlan(updatedPlanObjForBoundary); @@ -726,6 +736,7 @@ const createUpdatePlanProject = async (req) => { const updatedPlanObjForFacility = { ...fetchedPlanForFacility, files: filesForFacility, + additionalDetails:{ ...fetchedPlanForFacility.additionalDetails,key:key} }; const planResFacility = await updatePlan(updatedPlanObjForFacility); @@ -803,16 +814,33 @@ const createUpdatePlanProject = async (req) => { setShowToast({ key: "error", label: "ERR_FAILED_TO_COMPLETE_SETUP" }); } - case "ROLE_ACCESS_CONFIGURATION": - //run any api validations if any/ - setCurrentKey((prev) => prev + 1); - setCurrentStep((prev) => prev + 1); - window.dispatchEvent(new Event("isLastStep")); - Digit.Utils.microplanv1.updateUrlParams({ isLastVerticalStep: null }); - Digit.Utils.microplanv1.updateUrlParams({ internalKey: null }); - return { - triggeredFrom, - }; + case "ROLE_ACCESS_CONFIGURATION":{ + const fetchedPlan = await searchPlanConfig({ + PlanConfigurationSearchCriteria: { + tenantId, + id: microplanId, + }, + }); + const updatedPlanObject = { + ...fetchedPlan, + additionalDetails:{...fetchedPlanForBoundary.additionalDetails,key:key} + }; + const response= await updatePlan(updatedPlanObject); + // Return as expected + if(response){ + setCurrentKey((prev) => prev + 1); + setCurrentStep((prev) => prev + 1); + window.dispatchEvent(new Event("isLastStep")); + Digit.Utils.microplanv1.updateUrlParams({ isLastVerticalStep: null }); + Digit.Utils.microplanv1.updateUrlParams({ internalKey: null }); + return { + triggeredFrom, + }; + }else{ + setShowToast({ key: "error", label: "ERR_FAILED_TO_UPDATE_PLAN" }); + } + } + default: setShowToast({ key: "error", label: "ERROR_UNHANDLED_NEXT_OPERATION" }); return { diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/FacilityCatchmentMapping.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/FacilityCatchmentMapping.js index 62e3a7e9f7..15da661044 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/FacilityCatchmentMapping.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/FacilityCatchmentMapping.js @@ -45,7 +45,6 @@ const FacilityCatchmentMapping = () => { }, }); - const { isLoading: isLoadingCampaignObject, data: campaignObject, @@ -192,8 +191,8 @@ const FacilityCatchmentMapping = () => { {`${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?.[0]?.hierarchyLevel ? + ` (${t(planEmployee.planData[0].hierarchyLevel.toUpperCase())})` : ""}`}
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..aed5750444 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 @@ -836,7 +836,9 @@ 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())})` : ""}`} +
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())})` : ""}` + } +