diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DetailsTable.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DetailsTable.js
index fa48f6e7062..8c90b790625 100644
--- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DetailsTable.js
+++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DetailsTable.js
@@ -23,6 +23,9 @@ const DetailsTable = ({ className = "", columnsData, rowsData, summaryRows, card
else{
return{
...i,
+ value: typeof i?.value === "string"
+ ? t(i.value)
+ : i?.value,
operator: t(i?.operator?.code) || t(i?.operator),
attribute: i?.attribute?.code
? t(`CAMPAIGN_ATTRIBUTE_${i.attribute.code.toUpperCase()}`)
diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/CycleConfiguration.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/CycleConfiguration.js
index af3646d5ba0..b59dc6a2804 100644
--- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/CycleConfiguration.js
+++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/CycleConfiguration.js
@@ -1,5 +1,5 @@
import React, { useReducer, Fragment, useEffect, useState } from "react";
-import { CardText, LabelFieldPair, Card, CardLabel, CardSubHeader, Paragraph, Header } from "@egovernments/digit-ui-react-components";
+import { CardText, LabelFieldPair, Card, CardLabel, CardSubHeader, Paragraph, Header , Loader } from "@egovernments/digit-ui-react-components";
import { useTranslation } from "react-i18next";
import { TextInput, InfoCard , Stepper , TextBlock } from "@egovernments/digit-ui-components";
import { deliveryConfig } from "../../configs/deliveryConfig";
@@ -72,6 +72,7 @@ const updateCycleData = (cycleData, index, update) => {
function CycleConfiguration({ onSelect, formData, control, ...props }) {
const tenantId = Digit.ULBService.getCurrentTenantId();
+ const [isLoading , setIsLoading] = useState(false);
const selectedProjectType = window.Digit.SessionStorage.get("HCM_CAMPAIGN_MANAGER_FORM_DATA")?.HCM_CAMPAIGN_TYPE?.projectType?.code;
const { isLoading: deliveryConfigLoading, data: filteredDeliveryConfig } = Digit.Hooks.useCustomMDMS(
tenantId,
@@ -80,7 +81,7 @@ function CycleConfiguration({ onSelect, formData, control, ...props }) {
{
staleTime: 0,
cacheTime: 0,
- enabled: true,
+ enabled: selectedProjectType ? true : false,
select: (data) => {
const temp= getDeliveryConfig({data: data?.["HCM-PROJECT-TYPES"], projectType:selectedProjectType});
return temp;
@@ -88,6 +89,13 @@ function CycleConfiguration({ onSelect, formData, control, ...props }) {
},
{ schemaCode: `${"HCM-PROJECT-TYPES"}.projectTypes` }
);
+
+ useEffect(()=>{
+ if(!filteredDeliveryConfig || !filteredDeliveryConfig?.code){
+ setIsLoading(true);
+ }
+ else setIsLoading(false);
+ },[filteredDeliveryConfig])
const saved = Digit.SessionStorage.get("HCM_CAMPAIGN_MANAGER_FORM_DATA")?.HCM_CAMPAIGN_CYCLE_CONFIGURE?.cycleConfigure;
const refetch = Digit.SessionStorage.get("HCM_CAMPAIGN_MANAGER_FORM_DATA")?.HCM_CAMPAIGN_CYCLE_CONFIGURE?.cycleConfigure?.cycleConfgureDate
?.refetch;
@@ -177,6 +185,10 @@ function CycleConfiguration({ onSelect, formData, control, ...props }) {
else setKey(8);
};
+ if(isLoading){
+ return ;
+ }
+
return (
<>
diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js
index 6acae8c828f..71e0c27e783 100644
--- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js
+++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js
@@ -98,9 +98,33 @@ const SetupCampaign = ({ hierarchyType, hierarchyData }) => {
},
},
});
+
+ useEffect(() => {
+ if (isPreview === "true") {
+ setIsDraftCreated(true);
+ setCurrentKey(14);
+ }
+ else if (isDraft === "true") {
+ setIsDraftCreated(true);
+ if (isSkip === "false") {
+ if (currentKey === 1) setCurrentKey(1);
+ } else if (isDateRestricted === "true") {
+ setCurrentKey(3);
+ } else {
+ if(draftData?.additionalDetails?.key === 7 || draftData?.additionalDetails?.key === 8){
+ setCurrentKey(6);
+ }
+ else{
+ setCurrentKey(draftData?.additionalDetails?.key);
+ }
+ }
+ }
+}, [isPreview, isDraft, draftData]);
+
+
const getCurrentKey = () => {
const key = Number((/key=([^&]+)/.exec(location.search) || [])[1]);
- setCurrentKey(key);
+ setCurrentKey(key);
};
useEffect(() => {
@@ -122,29 +146,8 @@ const SetupCampaign = ({ hierarchyType, hierarchyData }) => {
}
}, [fetchUpload, fetchBoundary]);
- useEffect(() => {
- if (isPreview === "true") {
- setIsDraftCreated(true);
- setCurrentKey(14);
- return;
- }
- if (isDraft === "true") {
- setIsDraftCreated(true);
- if (isSkip === "false") {
- currentKey !== 1 ? null : setCurrentKey(1);
- } else {
- if (isDateRestricted === "true") {
- setCurrentKey(3);
- } else if (draftData?.additionalDetails?.key) {
- setCurrentKey(draftData?.additionalDetails?.key);
- } else {
- console.warn("No valid key found in draftData");
- setCurrentKey(1); // Fallback to initial key
- }
- }
- return;
- }
- }, [isPreview, isDraft, draftData]);
+
+
useEffect(() => {
setTotalFormData(params);
diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/utils/getDeliveryConfig.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/utils/getDeliveryConfig.js
index 0b7e67d01c5..b3d98f71b9c 100644
--- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/utils/getDeliveryConfig.js
+++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/utils/getDeliveryConfig.js
@@ -102,7 +102,7 @@ const getDeliveryConfig = ({ data, projectType }) => {
const generateMRDNConfig = (data) => {
return data?.deliveries?.map(delivery => {
- const conditionConfig = delivery.doseCriteria.map(dose => {
+ const conditionConfig = delivery.doseCriteria.map((dose, index) => {
const productConfig = dose.ProductVariants.map(variant => ({
key: 1,
name: variant.name,
@@ -132,7 +132,7 @@ const generateMRDNConfig = (data) => {
deliveryType: delivery.deliveryStrategy,
productConfig,
attributeConfig: attributeConfigs, // Use the array of attributeConfigs
- disableDeliveryType: true
+ disableDeliveryType: index === 0
};
});
diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/utils/setupCampaignHelpers.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/utils/setupCampaignHelpers.js
index b6cf0ddcba7..19a307c86e9 100644
--- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/utils/setupCampaignHelpers.js
+++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/utils/setupCampaignHelpers.js
@@ -2,6 +2,9 @@
* This file contains all the utils or helpers required for create campaign and drafts
*/
+// import { cloneDeep } from "lodash";
+import cloneDeep from 'lodash/cloneDeep';
+
export const cycleDataRemap=(data)=> {
if (!data) return null;
const uniqueCycleObjects = Object.values(
@@ -32,11 +35,7 @@ export const cycleDataRemap=(data)=> {
return operatorMapping[operator] || ""; // Default to empty if not found
}
export const restructureData=(data, cycleData, DeliveryConfig, projectType)=> {
- const deliveryConfig = DeliveryConfig?.find((e) => e.code === String(projectType));
- if (deliveryConfig) {
- delete deliveryConfig.cycles;
- delete deliveryConfig.resources;
- }
+ const deliveryConfig = cloneDeep(DeliveryConfig?.find(e => e.code === String(projectType)));
const resourcesMap = new Map();
const ageInfo = { maxAge: -Infinity, minAge: Infinity };
@@ -125,7 +124,7 @@ export const cycleDataRemap=(data)=> {
return [{
ruleKey: ruleKey + 1,
delivery: {},
- deliveryStrategy: deliveryStrategy,
+ deliveryType: deliveryStrategy || "DIRECT",
products,
attributes,
}];;
@@ -141,7 +140,7 @@ export const cycleDataRemap=(data)=> {
return deliveries?.map((delivery, deliveryIndex) => ({
active: deliveryIndex === 0,
deliveryIndex: String(deliveryIndex + 1),
- deliveryStrategy: delivery.deliveryStrategy || "DIRECT",
+ deliveryType: delivery.deliveryStrategy || "DIRECT",
deliveryRules: mapDoseCriteriaToDeliveryRules(delivery.doseCriteria , delivery.deliveryStrategy),
}));
};
@@ -162,7 +161,7 @@ export const cycleDataRemap=(data)=> {
return {
id: parseInt(delivery.deliveryIndex, 10),
- deliveryStrategy: delivery.deliveryStrategy || "DIRECT",
+ deliveryType: delivery.deliveryStrategy || "DIRECT",
mandatoryWaitSinceLastDeliveryInDays: null,
doseCriteria: delivery.deliveryRules.map(rule => {
const doseCriteriaResult = processDoseCriteria(rule, resourcesMap);