From 3f88737654a4b9f2ae53840fdd75bbb064279cee Mon Sep 17 00:00:00 2001 From: Bhavya-egov Date: Wed, 13 Nov 2024 18:47:45 +0530 Subject: [PATCH 1/4] fixed app delivery condition --- .../src/components/BoundarySummary.js | 2 +- .../SelectingBoundariesDuplicate.js | 2 +- .../src/pages/employee/SetupCampaign.js | 9 +++++--- .../src/utils/setupCampaignHelpers.js | 21 ++++++++++++------- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/BoundarySummary.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/BoundarySummary.js index 51d7b1e5dd3..d6017c87650 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/BoundarySummary.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/BoundarySummary.js @@ -146,7 +146,7 @@ const BoundarySummary = (props) => { - + diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundariesDuplicate.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundariesDuplicate.js index d38cd8c0022..b260c6db5fe 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundariesDuplicate.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundariesDuplicate.js @@ -106,7 +106,7 @@ const SelectingBoundariesDuplicate = ({ onSelect, formData, ...props }) => { - + 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 0191526f160..0478649267a 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 @@ -312,7 +312,8 @@ const SetupCampaign = ({ hierarchyType, hierarchyData }) => { totalFormData?.HCM_CAMPAIGN_DELIVERY_DATA?.deliveryRule, totalFormData?.HCM_CAMPAIGN_CYCLE_CONFIGURE?.cycleConfigure, DeliveryConfig, - totalFormData?.HCM_CAMPAIGN_TYPE?.projectType?.code + totalFormData?.HCM_CAMPAIGN_TYPE?.projectType?.code, + "create" ); payloadData.deliveryRules = [temp?.[0]]; // payloadData.deliveryRules = totalFormData?.HCM_CAMPAIGN_DELIVERY_DATA?.deliveryRule; @@ -399,7 +400,8 @@ const SetupCampaign = ({ hierarchyType, hierarchyData }) => { totalFormData?.HCM_CAMPAIGN_DELIVERY_DATA?.deliveryRule, totalFormData?.HCM_CAMPAIGN_CYCLE_CONFIGURE?.cycleConfigure, DeliveryConfig, - totalFormData?.HCM_CAMPAIGN_TYPE?.projectType?.code + totalFormData?.HCM_CAMPAIGN_TYPE?.projectType?.code, + "draft" ); payloadData.deliveryRules = temp?.[0]; // payloadData.deliveryRules = totalFormData?.HCM_CAMPAIGN_DELIVERY_DATA?.deliveryRule; @@ -473,7 +475,8 @@ const SetupCampaign = ({ hierarchyType, hierarchyData }) => { totalFormData?.HCM_CAMPAIGN_DELIVERY_DATA?.deliveryRule, totalFormData?.HCM_CAMPAIGN_CYCLE_CONFIGURE?.cycleConfigure, DeliveryConfig, - totalFormData?.HCM_CAMPAIGN_TYPE?.projectType?.code + totalFormData?.HCM_CAMPAIGN_TYPE?.projectType?.code, + "draft" ); payloadData.deliveryRules = [temp?.[0]]; // payloadData.deliveryRules = totalFormData?.HCM_CAMPAIGN_DELIVERY_DATA?.deliveryRule; 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 6987d12a94b..5112fb68348 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 @@ -34,7 +34,7 @@ export const cycleDataRemap=(data)=> { }; return operatorMapping[operator] || ""; // Default to empty if not found } - export const restructureData=(data, cycleData, DeliveryConfig, projectType)=> { + export const restructureData=(data, cycleData, DeliveryConfig, projectType , type)=> { const deliveryConfig = cloneDeep(DeliveryConfig?.find(e => e.code === String(projectType))); const resourcesMap = new Map(); @@ -49,7 +49,7 @@ export const cycleDataRemap=(data)=> { startDate: cycleStartDate, endDate: cycleEndDate, id: parseInt(cycle.cycleIndex, 10), - deliveries: cycle?.deliveries?.map(delivery => processDelivery(delivery, resourcesMap, ageInfo)) + deliveries: cycle?.deliveries?.map(delivery => processDelivery(delivery, resourcesMap, ageInfo , type)) }; }); @@ -157,14 +157,14 @@ export const cycleDataRemap=(data)=> { } - export const processDelivery=(delivery, resourcesMap, ageInfo)=> { + export const processDelivery=(delivery, resourcesMap, ageInfo , type)=> { return { id: parseInt(delivery.deliveryIndex, 10), deliveryStrategy: delivery.deliveryStrategy || "DIRECT", mandatoryWaitSinceLastDeliveryInDays: null, doseCriteria: delivery.deliveryRules.map(rule => { - const doseCriteriaResult = processDoseCriteria(rule, resourcesMap); + const doseCriteriaResult = processDoseCriteria(rule, resourcesMap ,type); const ages = extractAgesFromConditions(doseCriteriaResult.condition); if (ages.length > 0) { ageInfo.maxAge = Math.max(ageInfo.maxAge, ...ages); @@ -174,7 +174,7 @@ export const cycleDataRemap=(data)=> { }) }; } - export const processDoseCriteria =(rule, resourcesMap) =>{ + export const processDoseCriteria =(rule, resourcesMap ,type) =>{ rule.products.forEach(product => { if (resourcesMap.has(product.value)) { resourcesMap.get(product.value).count += product.count; @@ -190,9 +190,16 @@ export const cycleDataRemap=(data)=> { const conditions = rule.attributes.map(attr => { if (attr?.operator?.code === "IN_BETWEEN") { - return `${attr.toValue} <= ${attr.attribute.code} < ${attr.fromValue}`; + if (type === "create") { + return `${attr.toValue}<=${attr.attribute.code.toLowerCase()}and${attr.attribute.code.toLowerCase()}<${attr.fromValue}`; + } + else return `${attr.toValue} <= ${attr.attribute.code} < ${attr.fromValue}`; } else { - return `${attr?.attribute?.code}${getOperatorSymbol(attr?.operator?.code)}${attr?.value}`; + if (type === "create") { + return `${attr?.attribute?.code.toLowerCase()}${getOperatorSymbol(attr?.operator?.code)}${attr?.value}`; + } + else return `${attr?.attribute?.code}${getOperatorSymbol(attr?.operator?.code)}${attr?.value}`; + } }); From c075921ad6aa30b336e17c47a602fda9818e9841 Mon Sep 17 00:00:00 2001 From: Bhavya-egov Date: Thu, 14 Nov 2024 19:02:22 +0530 Subject: [PATCH 2/4] added my microplan screen --- .../src/components/CampaignCard.js | 6 + .../src/components/CampaignType.js | 5 +- .../src/configs/UICustomizations.js | 64 ++++++++++- .../src/configs/myCampaignConfig.js | 18 ++- .../src/configs/myMicroplanConfig.js | 104 ++++++++++++++++++ .../src/pages/employee/MyMicroplans.js | 52 +++++++++ .../src/pages/employee/SetupCampaign.js | 10 +- .../src/pages/employee/index.js | 2 + 8 files changed, 249 insertions(+), 12 deletions(-) create mode 100644 health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/myMicroplanConfig.js create mode 100644 health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyMicroplans.js diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignCard.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignCard.js index 41329a8d089..a17de5031ae 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignCard.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignCard.js @@ -74,6 +74,12 @@ const CampaignCard = () => { roles: ROLES.CAMPAIGN_MANAGER, // count: isLoading?"-":data }, + { + label: t("MICROPLAN_CAMPAIGN"), + link: `/${window?.contextPath}/employee/campaign/my-microplan`, + roles: ROLES.CAMPAIGN_MANAGER, + // count: isLoading?"-":data + }, ]; links = links.filter((link) => (link?.roles && link?.roles?.length > 0 ? Digit.Utils.didEmployeeHasAtleastOneRole(link?.roles) : true)); diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignType.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignType.js index 42adf726de5..a60630e7b2d 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignType.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignType.js @@ -19,6 +19,7 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => { const searchParams = new URLSearchParams(location.search); const [currentStep , setCurrentStep] = useState(1); const currentKey = searchParams.get("key"); + const productType = searchParams.get("type"); const [key, setKey] = useState(() => { const keyParam = searchParams.get("key"); return keyParam ? parseInt(keyParam) : 1; @@ -118,7 +119,7 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {
{ - if (props?.props?.sessionData?.HCM_CAMPAIGN_TYPE?.projectType && !canUpdate) { + if (props?.props?.sessionData?.HCM_CAMPAIGN_TYPE?.projectType && !canUpdate && productType!=="microplan") { setShowPopUp(true); return; } @@ -143,6 +144,8 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => { setStartValidation(true); handleChange(value); }} + disabled = {productType === "microplan"} + /> {error?.message && }
diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js index 7c530ca3f3a..c566f3a38a3 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js @@ -299,11 +299,66 @@ export const UICustomizations = { }} /> - ) + ); } - }, + }, + MicroplanCampaignSearchConfig: { + 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; + data.body.PlanConfigurationSearchCriteria.campaignType = data?.state?.searchForm?.campaignType?.[0]?.code; + return data; + }, + additionalCustomizations: (row, key, column, value, t, searchResult) => { + switch (key) { + case "NAME_OF_MICROPLAN": + if (value && value !== "NA") { + return ( +
+

{t(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 "LAST_MODIFIED_TIME": + return Digit.DateUtils.ConvertEpochToDate(value); + default: + return null; // Handle any unexpected keys here if needed + } + }, }, MyCampaignConfigOngoing: { preProcess: (data, additionalDetails) => { @@ -886,7 +941,7 @@ export const UICustomizations = { return value ? t("CM_UPDATE_REQUEST") : t("CM_CREATE_REQUEST"); case "CAMPAIGN_START_DATE": return Digit.DateUtils.ConvertEpochToDate(value); - case "CAMPAIGN_END_DATE": + case "LAST_MODIFIED_TIME": return Digit.DateUtils.ConvertEpochToDate(value); default: return "case_not_found"; @@ -993,7 +1048,8 @@ export const UICustomizations = { ); - + case "CM_DRAFT_TYPE": + return value ? t("CM_UPDATE_REQUEST") : t("CM_CREATE_REQUEST"); case "CAMPAIGN_START_DATE": return Digit.DateUtils.ConvertEpochToDate(value); case "CAMPAIGN_END_DATE": diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/myCampaignConfig.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/myCampaignConfig.js index 5c05471a267..0537d052036 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/myCampaignConfig.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/myCampaignConfig.js @@ -524,11 +524,16 @@ export const myCampaignConfig = { additionalCustomization: true, // disableSortBy: true, }, + // { + // label: "CAMPAIGN_END_DATE", + // jsonPath: "endDate", + // additionalCustomization: true, + // // disableSortBy: true, + // }, { - label: "CAMPAIGN_END_DATE", - jsonPath: "endDate", - additionalCustomization: true, - // disableSortBy: true, + label:"LAST_MODIFIED_TIME", + jsonPath:"auditDetails.lastModifiedTime", + additionalCustomization:true }, ], enableGlobalSearch: false, @@ -637,6 +642,11 @@ export const myCampaignConfig = { jsonPath: "campaignName", // additionalCustomization: true, }, + { + label: "CM_DRAFT_TYPE", + jsonPath: "parentId", + additionalCustomization: true, + }, { label: "CAMPAIGN_TYPE", jsonPath: "projectType", diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/myMicroplanConfig.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/myMicroplanConfig.js new file mode 100644 index 00000000000..7163cb8e6a3 --- /dev/null +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/myMicroplanConfig.js @@ -0,0 +1,104 @@ + + + const tenantId = Digit.ULBService.getCurrentTenantId(); + const mdms_context_path = window?.globalConfigs?.getConfig("MDMS_V2_CONTEXT_PATH") || "mdms-v2"; + export const MicroplanCampaignSearchConfig = [ + { + label: "MICROPLAN_SEARCH", + type: "search", + apiDetails: { + serviceName: "/plan-service/config/_search", + requestParam: { + }, + requestBody: { + "PlanConfigurationSearchCriteria": { + "limit": 10, + "offset": 0, + "tenantId": "mz", + "userUuid": "ff4ca65b-de7a-48de-ab9d-23c7728dc1aa" + }, + }, + masterName: "commonUiConfig", + moduleName: "MicroplanCampaignSearchConfig", + minParametersForSearchForm: 0, + tableFormJsonPath: "requestBody.PlanConfigurationSearchCriteria.pagination", + // filterFormJsonPath: "requestBody.MdmsCriteria.customs", + searchFormJsonPath: "requestBody.PlanConfigurationSearchCriteria", + }, + sections: { + search: { + uiConfig: { + formClassName: "custom-both-clear-search", + primaryLabel: "ES_COMMON_SEARCH", + secondaryLabel: "ES_COMMON_CLEAR_SEARCH", + minReqFields: 0, + defaultValues:{ + microplanName: "", + campaignType: "", + }, + fields: [ + { + label: "Name of the microplan", + isMandatory: false, + key: "microplanName", + type: "text", + populators: { + name: "microplanName" + }, + }, + { + label: "CAMPAIGN_SEARCH_TYPE", + type: "apidropdown", + isMandatory: false, + disable: false, + populators: { + optionsCustomStyle: { + top: "2.3rem", + }, + name: "campaignType", + optionsKey: "code", + allowMultiSelect: false, + masterName: "commonUiConfig", + moduleName: "MyCampaignConfigDrafts", + customfn: "populateCampaignTypeReqCriteria", + }, + }, + ], + }, + + show: true, + }, + searchResult: { + uiConfig: { + columns: [ + { + label: "NAME_OF_MICROPLAN", + jsonPath: "name", + additionalCustomization:true + }, + { + label:"CAMPAIGN_TYPE", + jsonPath:"campaignDetails.projectType", + additionalCustomization:true + }, + { + label:"LAST_MODIFIED_TIME", + jsonPath:"auditDetails.lastModifiedTime", + additionalCustomization:true + }, + ], + resultsJsonPath: "PlanConfiguration", + + enableColumnSort: true, + // resultsJsonPath: "mdms", + }, + show: true, + }, + // customHookName: "microplanv1.useSavedMicroplans", + + }, + customHookName:"microplanv1.useSavedMicroplans" + }, + ]; + + diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyMicroplans.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyMicroplans.js new file mode 100644 index 00000000000..926a321096f --- /dev/null +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyMicroplans.js @@ -0,0 +1,52 @@ +import { Header, InboxSearchComposer } from "@egovernments/digit-ui-react-components"; +import React, { useState, useEffect } from "react"; +import { useTranslation } from "react-i18next"; +import { useHistory } from "react-router-dom"; +import { MicroplanCampaignSearchConfig } from "../../configs/myMicroplanConfig"; + + + +const defaultSearchValues = { + +}; + +const MyMicroplans = () => { + const { t } = useTranslation(); + const [defaultValues, setDefaultValues] = useState(defaultSearchValues); // State to hold default values for search fields + const history = useHistory(); + useEffect(() => { + // Set default values when component mounts + setDefaultValues(defaultSearchValues); + }, []); + + const onTabChange = (n) => { + + setTabData((prev) => prev.map((i, c) => ({ ...i, active: c === n ? true : false }))); //setting tab enable which is being clicked + // setConfig(TabSearchconfig?.TabSearchconfig?.[n]);// as per tab number filtering the config + const url = new URL(window.location.href); + url.searchParams.set("tabId", `${n}`); + window.history.replaceState({}, "", url); + + }; + const onClickRow = ({ original: row }) => { + history.push(`/${window.contextPath}/employee/campaign/setup-campaign?id=${row.campaignId}&draft=true&fetchBoundary=true&draftBoundary=true&type=microplan`); + }; + return ( + + +
{t("MY_MICROPLANS_HEADING")}
+
+ {/* Pass defaultValues as props to InboxSearchComposer */} + +
+
+ ); +}; +export default MyMicroplans; \ No newline at end of file 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 0478649267a..e7d3325d9d5 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 @@ -49,6 +49,7 @@ const SetupCampaign = ({ hierarchyType, hierarchyData }) => { const isDateRestricted = searchParams.get("date"); const isChangeDates = searchParams.get("changeDates"); const actionBar = searchParams.get("actionBar"); + const type = searchParams.get("type"); const [isDraftCreated, setIsDraftCreated] = useState(false); const [currentKey, setCurrentKey] = useState(() => { const keyParam = searchParams.get("key"); @@ -112,9 +113,12 @@ const SetupCampaign = ({ hierarchyType, hierarchyData }) => { setIsDraftCreated(true); if (isSkip === "false") { if (currentKey === 1) setCurrentKey(1); - } else if (isDateRestricted === "true") { - setCurrentKey(3); - } else { + } else if (type === "microplan") { + setCurrentKey(2); + }else if (isDateRestricted === "true") { + setCurrentKey(3); + } + else { if(draftData?.additionalDetails?.key === 7 || draftData?.additionalDetails?.key === 8){ setCurrentKey(6); } diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/index.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/index.js index 3659ba79432..b2aeeb02143 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/index.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/index.js @@ -14,6 +14,7 @@ import ViewHierarchy from "./ViewHierarchy"; import ViewChecklist from "./ViewChecklist"; import UpdateChecklist from "./UpdateChecklist"; import BoundaryHome from "./BoundaryHome"; +import MyMicroplans from "./MyMicroplans"; /** * The CampaignBreadCrumb function generates breadcrumb navigation for a campaign setup page in a React * application. @@ -148,6 +149,7 @@ const App = ({ path, BOUNDARY_HIERARCHY_TYPE, hierarchyData }) => { } /> } /> } /> + } /> From f076ed082093ce2294981f3dac6de914d121bd26 Mon Sep 17 00:00:00 2001 From: Bhavya-egov Date: Fri, 15 Nov 2024 13:17:42 +0530 Subject: [PATCH 3/4] changes in the url --- .../src/components/CampaignCard.js | 14 ++---- .../src/components/CampaignName.js | 16 +++++-- .../src/components/CampaignType.js | 4 +- .../src/configs/UICustomizations.js | 46 +++++++++---------- .../src/configs/myMicroplanConfig.js | 46 +++++++++---------- .../src/pages/employee/MyMicroplans.js | 26 ++--------- .../src/pages/employee/SetupCampaign.js | 7 ++- .../src/pages/employee/index.js | 4 +- .../src/utils/setupCampaignValidators.js | 4 +- 9 files changed, 76 insertions(+), 91 deletions(-) diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignCard.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignCard.js index 51c924d2984..8b28d4eb125 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignCard.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignCard.js @@ -22,6 +22,8 @@ const CampaignCard = () => { } const { t } = useTranslation(); + const userId = Digit.UserService.getUser().info.uuid; + const microplanStatus = "RESOURCE_ESTIMATIONS_APPROVED" let links = [ @@ -36,9 +38,9 @@ const CampaignCard = () => { roles: ROLES.CAMPAIGN_MANAGER, // count: isLoading?"-":data }, - { //@Bhavya put the new url and remove the comment + { label: t("ACTION_TEST_SETUP_CAMPAIGN_FROM_MICROPLAN"), - link: `/${window?.contextPath}/employee/campaign/setup-campaign`, + link: `/${window?.contextPath}/employee/campaign/setup-microplan&userId=${userId}&status=${microplanStatus}`, roles: ROLES.CAMPAIGN_MANAGER }, { @@ -58,13 +60,7 @@ const CampaignCard = () => { link: `/${window?.contextPath}/employee/campaign/boundary/home`, roles: ROLES.BOUNDARY_MANAGER, // count: isLoading?"-":data - }, - { - label: t("MICROPLAN_CAMPAIGN"), - link: `/${window?.contextPath}/employee/campaign/my-microplan`, - roles: ROLES.CAMPAIGN_MANAGER, - // count: isLoading?"-":data - }, + } ]; links = links.filter((link) => (link?.roles && link?.roles?.length > 0 ? Digit.Utils.didEmployeeHasAtleastOneRole(link?.roles) : true)); diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignName.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignName.js index 04b4f7c02aa..bae52d9f60b 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignName.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignName.js @@ -6,14 +6,24 @@ import { ErrorMessage, FieldV1 , Stepper , TextBlock ,Card } from "@egovernments const CampaignName = ({ onSelect, formData, control, formState, ...props }) => { const { t } = useTranslation(); - const [name, setName] = useState(props?.props?.sessionData?.HCM_CAMPAIGN_NAME?.campaignName || ""); + const [executionCount, setExecutionCount] = useState(0); const [startValidation, setStartValidation] = useState(null); const [error, setError] = useState(null); + const searchParams = new URLSearchParams(location.search); + const microplanName = searchParams.get("microName"); + const source = searchParams.get("source"); + const [name, setName] = useState(props?.props?.sessionData?.HCM_CAMPAIGN_NAME?.campaignName || ""); useEffect(() => { - setName(props?.props?.sessionData?.HCM_CAMPAIGN_NAME?.campaignName); + if(source === "microplan"){ + const sessionName = props?.props?.sessionData?.HCM_CAMPAIGN_NAME?.campaignName.replace(/&/g, "and"); + if(sessionName === microplanName){ + setName(""); + } + } + else setName(props?.props?.sessionData?.HCM_CAMPAIGN_NAME?.campaignName); }, [props?.props?.sessionData?.HCM_CAMPAIGN_NAME]); - const searchParams = new URLSearchParams(location.search); + const [currentStep , setCurrentStep] = useState(1); const currentKey = searchParams.get("key"); const [key, setKey] = useState(() => { diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignType.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignType.js index a60630e7b2d..2bc5e33d3e9 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignType.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignType.js @@ -19,7 +19,7 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => { const searchParams = new URLSearchParams(location.search); const [currentStep , setCurrentStep] = useState(1); const currentKey = searchParams.get("key"); - const productType = searchParams.get("type"); + const source = searchParams.get("source"); const [key, setKey] = useState(() => { const keyParam = searchParams.get("key"); return keyParam ? parseInt(keyParam) : 1; @@ -144,7 +144,7 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => { setStartValidation(true); handleChange(value); }} - disabled = {productType === "microplan"} + disabled = {source === "microplan"} /> {error?.message && } diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js index c566f3a38a3..8e2118d7808 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js @@ -149,8 +149,8 @@ export const UICustomizations = { history.push(`/${window.contextPath}/employee/campaign/checklist/create?campaignName=${campaignName}&role=${role_code}&checklistType=${cl_code}&projectType=${projectType}&campaignId=${campaignId}`) }} /> - ) - } + ); + } default: return value; } @@ -305,18 +305,15 @@ export const UICustomizations = { }, MicroplanCampaignSearchConfig: { 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; + const url = window.location.pathname; + const queryString = url.includes("?") ? url.split("?")[1] : url.split("&").slice(1).join("&"); + const searchParams = new URLSearchParams(queryString); + const userId = searchParams.get("userId"); + const status = searchParams.get("status"); + data.body.PlanConfigurationSearchCriteria.userUuid = userId; + data.body.PlanConfigurationSearchCriteria.status = [status]; data.body.PlanConfigurationSearchCriteria.name = data?.state?.searchForm?.microplanName; - data.body.PlanConfigurationSearchCriteria.campaignType = data?.state?.searchForm?.campaignType?.[0]?.code; + // data.body.PlanConfigurationSearchCriteria.campaignType = data?.state?.searchForm?.campaignType?.[0]?.code; return data; }, additionalCustomizations: (row, key, column, value, t, searchResult) => { @@ -326,10 +323,10 @@ export const UICustomizations = { return (

{t(value)}

@@ -345,7 +342,7 @@ export const UICustomizations = { case "CAMPAIGN_TYPE": if (value && value != "NA") { - return

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

; + return

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

; } else { return (
@@ -452,7 +449,6 @@ export const UICustomizations = { setTimeline(true); break; case "ACTION_LABEL_CONFIGURE_APP": - window.history.pushState( { name: row?.campaignName, @@ -770,7 +766,6 @@ export const UICustomizations = { setTimeline(true); break; - case "ACTION_LABEL_UPDATE_BOUNDARY_DETAILS": window.history.pushState( { @@ -790,7 +785,7 @@ export const UICustomizations = { name: row?.campaignName, data: row, projectId: row?.projectId, - campaignType: row?.projectType + campaignType: row?.projectType, }, "", `/${window.contextPath}/employee/campaign/checklist/search?name=${row?.campaignName}&campaignId=${row?.id}&projectType=${row?.projectType}` @@ -1032,8 +1027,8 @@ export const UICustomizations = { setTimeline(true); break; case "ACTION_LABEL_RETRY": - retryCampaign(row,searchResult); - break; + retryCampaign(row, searchResult); + break; default: console.log(value); break; @@ -1062,7 +1057,10 @@ export const UICustomizations = { type="actionButton" variation="secondary" label={"Action"} - options={[{ key: 1, code: "ACTION_LABEL_VIEW_TIMELINE", i18nKey: t("ACTION_LABEL_VIEW_TIMELINE") },{ key: 2, code: "ACTION_LABEL_RETRY", i18nKey: t("ACTION_LABEL_RETRY") }].filter(obj=>Digit.Utils.didEmployeeHasAtleastOneRole(["SYSTEM_ADMINISTRATOR"]||obj?.key!=2))} //added retry for system adminstrator for failed campaign + options={[ + { key: 1, code: "ACTION_LABEL_VIEW_TIMELINE", i18nKey: t("ACTION_LABEL_VIEW_TIMELINE") }, + { key: 2, code: "ACTION_LABEL_RETRY", i18nKey: t("ACTION_LABEL_RETRY") }, + ].filter((obj) => Digit.Utils.didEmployeeHasAtleastOneRole(["SYSTEM_ADMINISTRATOR"] || obj?.key != 2))} //added retry for system adminstrator for failed campaign optionsKey="i18nKey" showBottom={true} isSearchable={false} diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/myMicroplanConfig.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/myMicroplanConfig.js index 7163cb8e6a3..19da3a0d45d 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/myMicroplanConfig.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/myMicroplanConfig.js @@ -11,11 +11,10 @@ requestParam: { }, requestBody: { - "PlanConfigurationSearchCriteria": { + "PlanConfigurationSearchCriteria": { "limit": 10, "offset": 0, - "tenantId": "mz", - "userUuid": "ff4ca65b-de7a-48de-ab9d-23c7728dc1aa" + "tenantId": tenantId, }, }, masterName: "commonUiConfig", @@ -38,7 +37,7 @@ }, fields: [ { - label: "Name of the microplan", + label: "NAME_OF_MICROPLAN", isMandatory: false, key: "microplanName", type: "text", @@ -46,23 +45,23 @@ name: "microplanName" }, }, - { - label: "CAMPAIGN_SEARCH_TYPE", - type: "apidropdown", - isMandatory: false, - disable: false, - populators: { - optionsCustomStyle: { - top: "2.3rem", - }, - name: "campaignType", - optionsKey: "code", - allowMultiSelect: false, - masterName: "commonUiConfig", - moduleName: "MyCampaignConfigDrafts", - customfn: "populateCampaignTypeReqCriteria", - }, - }, + // { + // label: "CAMPAIGN_SEARCH_TYPE", + // type: "apidropdown", + // isMandatory: false, + // disable: false, + // populators: { + // optionsCustomStyle: { + // top: "2.3rem", + // }, + // name: "campaignType", + // optionsKey: "code", + // allowMultiSelect: false, + // masterName: "commonUiConfig", + // moduleName: "MyCampaignConfigDrafts", + // customfn: "populateCampaignTypeReqCriteria", + // }, + // }, ], }, @@ -78,7 +77,7 @@ }, { label:"CAMPAIGN_TYPE", - jsonPath:"campaignDetails.projectType", + jsonPath:"additionalDetails.campaignType", additionalCustomization:true }, { @@ -90,14 +89,11 @@ resultsJsonPath: "PlanConfiguration", enableColumnSort: true, - // resultsJsonPath: "mdms", }, show: true, }, - // customHookName: "microplanv1.useSavedMicroplans", }, - customHookName:"microplanv1.useSavedMicroplans" }, ]; diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyMicroplans.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyMicroplans.js index 926a321096f..89208ca7e09 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyMicroplans.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyMicroplans.js @@ -4,39 +4,19 @@ import { useTranslation } from "react-i18next"; import { useHistory } from "react-router-dom"; import { MicroplanCampaignSearchConfig } from "../../configs/myMicroplanConfig"; - - -const defaultSearchValues = { - -}; - const MyMicroplans = () => { const { t } = useTranslation(); - const [defaultValues, setDefaultValues] = useState(defaultSearchValues); // State to hold default values for search fields const history = useHistory(); - useEffect(() => { - // Set default values when component mounts - setDefaultValues(defaultSearchValues); - }, []); - - const onTabChange = (n) => { - - setTabData((prev) => prev.map((i, c) => ({ ...i, active: c === n ? true : false }))); //setting tab enable which is being clicked - // setConfig(TabSearchconfig?.TabSearchconfig?.[n]);// as per tab number filtering the config - const url = new URL(window.location.href); - url.searchParams.set("tabId", `${n}`); - window.history.replaceState({}, "", url); - - }; const onClickRow = ({ original: row }) => { - history.push(`/${window.contextPath}/employee/campaign/setup-campaign?id=${row.campaignId}&draft=true&fetchBoundary=true&draftBoundary=true&type=microplan`); + console.log("row" , row); + const updatedName = row.name.replace(/&/g, "and"); + history.push(`/${window.contextPath}/employee/campaign/setup-campaign?id=${row.campaignId}&draft=true&fetchBoundary=true&draftBoundary=true&source=microplanµName=${updatedName}`); }; return (
{t("MY_MICROPLANS_HEADING")}
- {/* Pass defaultValues as props to InboxSearchComposer */} { const isDateRestricted = searchParams.get("date"); const isChangeDates = searchParams.get("changeDates"); const actionBar = searchParams.get("actionBar"); - const type = searchParams.get("type"); + const source = searchParams.get("source"); + const microplanName = searchParams.get("microName"); const [isDraftCreated, setIsDraftCreated] = useState(false); const [currentKey, setCurrentKey] = useState(() => { const keyParam = searchParams.get("key"); @@ -113,8 +114,10 @@ const SetupCampaign = ({ hierarchyType, hierarchyData }) => { setIsDraftCreated(true); if (isSkip === "false") { if (currentKey === 1) setCurrentKey(1); - } else if (type === "microplan") { + //if user comes from set up microplan + } else if (source === "microplan") { setCurrentKey(2); + //if the campaign is in draft and the start date is passed }else if (isDateRestricted === "true") { setCurrentKey(3); } diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/index.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/index.js index b2aeeb02143..4a175150cb5 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/index.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/index.js @@ -93,6 +93,8 @@ const CampaignBreadCrumb = ({ location, defaultPath }) => { */ const App = ({ path, BOUNDARY_HIERARCHY_TYPE, hierarchyData }) => { const location = useLocation(); + const userId = Digit.UserService.getUser().info.uuid; + const microplanStatus = "RESOURCE_ESTIMATIONS_APPROVED" const UploadBoundaryData = Digit?.ComponentRegistryService?.getComponent("UploadBoundaryData"); const CycleConfiguration = Digit?.ComponentRegistryService?.getComponent("CycleConfiguration"); const DeliveryRule = Digit?.ComponentRegistryService?.getComponent("DeliveryRule"); @@ -149,7 +151,7 @@ const App = ({ path, BOUNDARY_HIERARCHY_TYPE, hierarchyData }) => { } /> } /> } /> - } /> + } /> diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/utils/setupCampaignValidators.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/utils/setupCampaignValidators.js index a641082c84b..b1e60a3e1ef 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/utils/setupCampaignValidators.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/utils/setupCampaignValidators.js @@ -191,8 +191,8 @@ export const handleValidate = ({formData,t,setShowToast,hierarchyDefinition,low if (typeof formData?.campaignName !== "string" || !formData?.campaignName.trim()) { setShowToast({ key: "error", label: "CAMPAIGN_NAME_MISSING_TYPE_ERROR" }); return false; - } else if (formData.campaignName.length > 250) { - setShowToast({ key: "error", label: "CAMPAIGN_NAME_TOO_LONG_ERROR" }); + } else if (formData.campaignName.length > 30) { + setShowToast({ key: "error", label: "CAMPAIGN_NAME_LONG_ERROR" }); return false; } else { setShowToast(null); From 978884badf23f6b6e06b5032d29ed86d5508c957 Mon Sep 17 00:00:00 2001 From: Bhavya-egov Date: Fri, 15 Nov 2024 14:21:36 +0530 Subject: [PATCH 4/4] changes --- .../src/components/CampaignCard.js | 2 +- .../src/components/CampaignType.js | 2 +- .../src/pages/employee/MyMicroplans.js | 15 ++++++++++++++- .../campaign-manager/src/pages/employee/index.js | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignCard.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignCard.js index 8b28d4eb125..1a662a87e2c 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignCard.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignCard.js @@ -40,7 +40,7 @@ const CampaignCard = () => { }, { label: t("ACTION_TEST_SETUP_CAMPAIGN_FROM_MICROPLAN"), - link: `/${window?.contextPath}/employee/campaign/setup-microplan&userId=${userId}&status=${microplanStatus}`, + link: `/${window?.contextPath}/employee/campaign/setup-from-microplan&userId=${userId}&status=${microplanStatus}`, roles: ROLES.CAMPAIGN_MANAGER }, { diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignType.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignType.js index 2bc5e33d3e9..ca8c7bf4184 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignType.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignType.js @@ -119,7 +119,7 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {
{ - if (props?.props?.sessionData?.HCM_CAMPAIGN_TYPE?.projectType && !canUpdate && productType!=="microplan") { + if (props?.props?.sessionData?.HCM_CAMPAIGN_TYPE?.projectType && !canUpdate && source!=="microplan") { setShowPopUp(true); return; } diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyMicroplans.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyMicroplans.js index 89208ca7e09..40740c1d2ce 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyMicroplans.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyMicroplans.js @@ -4,11 +4,24 @@ import { useTranslation } from "react-i18next"; import { useHistory } from "react-router-dom"; import { MicroplanCampaignSearchConfig } from "../../configs/myMicroplanConfig"; +// export const updateUrlParams=(params) =>{ +// const url = new URL(window.location.href); +// Object.entries(params).forEach(([key, value]) => { +// url.searchParams.set(key, value); +// }); +// window.history.replaceState({}, "", url); +// } + const MyMicroplans = () => { const { t } = useTranslation(); const history = useHistory(); + // const userId = Digit.UserService.getUser().info.uuid; + // const microplanStatus = "RESOURCE_ESTIMATIONS_APPROVED" + + // useEffect(() =>{ + // updateUrlParams({ userId: userId, status: microplanStatus }); + // },[]) const onClickRow = ({ original: row }) => { - console.log("row" , row); const updatedName = row.name.replace(/&/g, "and"); history.push(`/${window.contextPath}/employee/campaign/setup-campaign?id=${row.campaignId}&draft=true&fetchBoundary=true&draftBoundary=true&source=microplanµName=${updatedName}`); }; diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/index.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/index.js index 4a175150cb5..a3051b82ed0 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/index.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/index.js @@ -151,7 +151,7 @@ const App = ({ path, BOUNDARY_HIERARCHY_TYPE, hierarchyData }) => { } /> } /> } /> - } /> + } />