From 3c88770026b1bc74e79be24004da9bfb57abf0b3 Mon Sep 17 00:00:00 2001 From: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com> Date: Thu, 30 May 2024 19:54:47 +0530 Subject: [PATCH] Fixes of admin console v0.1 (#759) * Merge branch 'campaign' into campaign-merged * Merge branch 'campaign' into campaign-merged --- frontend/micro-ui/web/CHANGELOG.md | 7 ++ .../micro-ui-internals/example/package.json | 4 +- .../example/public/index.html | 6 +- .../web/micro-ui-internals/package.json | 4 +- .../packages/css/package.json | 2 +- .../css/src/pages/employee/campaign.scss | 5 +- .../css/src/pages/employee/campaignCycle.scss | 7 +- .../css/src/pages/employee/index.scss | 64 +++++++++-- .../packages/css/tailwind.config.js | 5 +- .../modules/campaign-manager/package.json | 4 +- .../src/components/CampaignDates.js | 5 +- .../src/components/CampaignType.js | 2 +- .../src/components/SelectingBoundaries.js | 28 +++-- .../src/components/UploadData.js | 6 ++ .../src/hooks/useParallelSearch.js | 20 ++++ .../src/pages/employee/CycleConfiguration.js | 18 ++-- .../src/pages/employee/MyCampaign.js | 38 ++++++- .../src/pages/employee/SetupCampaign.js | 18 ++++ .../deliveryRule/AddDeliverycontext.js | 11 +- .../employee/deliveryRule/MultiTabcontext.js | 4 +- .../src/pages/employee/deliveryRule/index.js | 2 +- frontend/micro-ui/web/package.json | 2 +- frontend/micro-ui/web/public/index.html | 4 +- frontend/micro-ui/web/workbench/package.json | 2 +- .../src/server/api/campaignApis.ts | 77 +++++++++----- .../src/server/api/genericApis.ts | 2 - .../src/server/config/createAndSearch.ts | 2 +- .../src/server/config/index.ts | 3 +- .../server/config/models/campaignDetails.ts | 2 +- .../src/server/kafka/Listener.ts | 1 + .../src/server/utils/campaignUtils.ts | 46 ++++---- .../src/server/utils/genericUtils.ts | 22 +++- .../utils/transforms/projectTypeUtils.ts | 13 ++- .../server/validators/campaignValidators.ts | 100 +++++++++++++----- 34 files changed, 397 insertions(+), 139 deletions(-) create mode 100644 frontend/micro-ui/web/CHANGELOG.md create mode 100644 frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useParallelSearch.js diff --git a/frontend/micro-ui/web/CHANGELOG.md b/frontend/micro-ui/web/CHANGELOG.md new file mode 100644 index 0000000000..826105084e --- /dev/null +++ b/frontend/micro-ui/web/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog +All notable changes to this module will be documented in this file. + +## 0.1.0 - 2024-05-28 +#### Base Admin console web + 1. Helps in creating the Campaign and configure delivery rules + 2. Create Data: Validates and creates resource details of type facility,user and boundary. diff --git a/frontend/micro-ui/web/micro-ui-internals/example/package.json b/frontend/micro-ui/web/micro-ui-internals/example/package.json index 495c3688d2..ccd8104bdb 100644 --- a/frontend/micro-ui/web/micro-ui-internals/example/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/example/package.json @@ -12,8 +12,8 @@ "@egovernments/digit-ui-libraries": "1.8.1-beta.4", "@egovernments/digit-ui-module-core": "1.8.1-beta.23", "@egovernments/digit-ui-module-utilities": "1.0.1-beta.2", - "@egovernments/digit-ui-components": "0.0.1-beta.28", - "@egovernments/digit-ui-react-components": "1.8.1-beta.23", + "@egovernments/digit-ui-components": "0.0.1-beta.31", + "@egovernments/digit-ui-react-components": "1.8.1-beta.24", "@egovernments/digit-ui-module-workbench": "1.0.1-beta.16", "@egovernments/digit-ui-module-hcmworkbench":"0.0.38", "@egovernments/digit-ui-module-campaign-manager": "0.0.1", diff --git a/frontend/micro-ui/web/micro-ui-internals/example/public/index.html b/frontend/micro-ui/web/micro-ui-internals/example/public/index.html index 64c6f223ce..63af0a10ba 100644 --- a/frontend/micro-ui/web/micro-ui-internals/example/public/index.html +++ b/frontend/micro-ui/web/micro-ui-internals/example/public/index.html @@ -15,8 +15,8 @@ href="https://unpkg.com/@egovernments/digit-ui-css@1.8.0-alpha.6/dist/index.css" /> --> - - + + @@ -32,4 +32,4 @@
- \ No newline at end of file + diff --git a/frontend/micro-ui/web/micro-ui-internals/package.json b/frontend/micro-ui/web/micro-ui-internals/package.json index 1545335ab3..072483e9f0 100644 --- a/frontend/micro-ui/web/micro-ui-internals/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/package.json @@ -45,8 +45,8 @@ "ajv": "^8.12.0", "lodash": "4.17.21", "microbundle-crl": "0.13.11", - "@egovernments/digit-ui-react-components": "1.8.1-beta.23", - "@egovernments/digit-ui-components": "0.0.1-beta.28", + "@egovernments/digit-ui-react-components": "1.8.1-beta.24", + "@egovernments/digit-ui-components": "0.0.1-beta.31", "react": "17.0.2", "react-dom": "17.0.2", "react-hook-form": "6.15.8", diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/css/package.json b/frontend/micro-ui/web/micro-ui-internals/packages/css/package.json index af328f65f0..e91bf430a2 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/css/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/packages/css/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-css", - "version": "1.0.47-campaign", + "version": "1.0.49-campaign", "license": "MIT", "main": "dist/index.css", "author": "Jagankumar ", diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaign.scss b/frontend/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaign.scss index 3a10013d8e..ff5cdb2409 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaign.scss +++ b/frontend/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaign.scss @@ -1,7 +1,7 @@ @import url("../../index.scss"); @import "../../typography.scss"; -.summary-header{ +.summary-header { @extend .typography.text-heading-l; font-size: 2.25rem; } @@ -58,6 +58,9 @@ } .selecting-boundary-div { padding-top: 0.5rem; + .label-field-pair { + margin-bottom: 1.5rem; + } } .campaign-table { border-collapse: collapse; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaignCycle.scss b/frontend/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaignCycle.scss index 69f4b0a9eb..2506d8ea13 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaignCycle.scss +++ b/frontend/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaignCycle.scss @@ -6,7 +6,7 @@ .sub-tab-container { margin-top: 5px; padding: 1.5rem; - .card-text{ + .card-text { margin-bottom: 0; } } @@ -69,6 +69,9 @@ } } } +.selector-button-primary { + background-color: theme(digitv2.lightTheme.primary); +} .campaign-breadcrumb { margin: 0; margin-bottom: 1.5rem; @@ -272,7 +275,7 @@ .options-card { max-height: 10rem !important; } - .card-label{ + .card-label { margin-bottom: 0.5rem; } } diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss b/frontend/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss index e8f42d0042..fb8aca4ee8 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss +++ b/frontend/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss @@ -9,6 +9,7 @@ margin-left: 92px; .employee-app-wrapper.digit-home-app-wrapper { margin-left: 0; + margin-right: 2rem; .ground-container.digit-home-ground { padding: 0; .employee-app-container.digit-home-employee-app { @@ -16,8 +17,12 @@ gap: 2.5rem; margin-top: 2rem; padding: 0; + display: grid !important; + grid-template-columns: repeat(auto-fill, minmax(263px, 1fr)); .employeeCard.customEmployeeCard.card-home.home-action-cards { margin: 0 !important; + min-width: 263px !important; + width: auto !important; } } } @@ -107,22 +112,40 @@ } .campaign-attribute-table { margin-bottom: 1rem; + border: 1px solid #d6d5d4; + overflow: hidden; + border-radius: 4px; table { background-color: #fafafa; border: 1px solid #d6d5d4; border-collapse: collapse; border-radius: 1rem; + tbody { + tr:nth-child(odd) { + background-color: white; + } + } th { - border: 1px solid #d6d5d4; + border-right: 1px solid #d6d5d4; + } + th:last-child { + border-right: none; } td { padding: 1rem; - border: 1px solid #d6d5d4; + border-right: 1px solid #d6d5d4; + } + td:last-child { + padding: 1rem; + border-right: none; } } } .campaign-product-table { margin-bottom: 1rem; + border: 1px solid #d6d5d4; + overflow: hidden; + border-radius: 4px; table { background-color: #fafafa; border: 1px solid #d6d5d4; @@ -130,13 +153,22 @@ border-radius: 1rem; tbody { background-color: #fff; + tr:nth-child(odd) { + background-color: white; + } } th { - border: 1px solid #d6d5d4; + border-right: 1px solid #d6d5d4; + } + th:last-child { + border-right: none; } td { padding: 1rem; - border: 1px solid #d6d5d4; + border-right: 1px solid #d6d5d4; + } + td:last-child { + border-right: none; } } } @@ -170,13 +202,20 @@ input[type="date"]::-webkit-calendar-picker-indicator { } } .campaign-attribute-table { + border: 1px solid #d6d5d4; + overflow: hidden; + border-radius: 4px; tbody { tr:nth-child(odd) { background-color: white; } } } - +tbody { + tr:nth-child(odd) { + background-color: white; + } +} .popup-wrap.campaign-data-preview { flex-direction: column; } @@ -212,6 +251,9 @@ input[type="date"]::-webkit-calendar-picker-indicator { .digit-dropdown-options-card { max-height: 10rem !important; } + .digit-field { + margin-bottom: 0 !important; + } } .campaign-summary-container { .setup-campaign-card { @@ -317,9 +359,9 @@ input[type="date"]::-webkit-calendar-picker-indicator { .popup-module-action-bar.campaign-pop-action { .selector-button-border { background-color: #ffffff; - border: 1px solid #f47738; + border: 1px solid #c84c0e; h2 { - color: #f47738 !important; + color: #c84c0e !important; } } } @@ -347,3 +389,11 @@ input[type="date"]::-webkit-calendar-picker-indicator { font-size: 14px; } } +.individualElement { + h2 { + color: theme(digitv2.lightTheme.text-primary); + } +} +.link { + color: #c84c0e !important; +} diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/css/tailwind.config.js b/frontend/micro-ui/web/micro-ui-internals/packages/css/tailwind.config.js index b6a497b173..e59e972d1a 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/css/tailwind.config.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/css/tailwind.config.js @@ -114,9 +114,10 @@ module.exports = { "header-sidenav": "#0B4B66", "input-border": "#505A5F", "primary-bg": "#FEEFE7", + "text-primary": "#363636", }, alert: { - error: "#b91900", + error: "#b91900", "error-bg": "#EFC7C1", success: "#00703C", "success-bg": "#BAD6C9", @@ -228,4 +229,4 @@ module.exports = { }, variants: {}, plugins: [], -}; \ No newline at end of file +}; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/package.json b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/package.json index 470bed80d1..ba8776efd9 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/package.json @@ -18,8 +18,8 @@ "react-router-dom": "5.3.0" }, "dependencies": { - "@egovernments/digit-ui-react-components": "1.8.1-beta.23", - "@egovernments/digit-ui-components": "0.0.1-beta.30", + "@egovernments/digit-ui-react-components": "1.8.1-beta.24", + "@egovernments/digit-ui-components": "0.0.1-beta.31", "@rjsf/core": "5.10.0", "@rjsf/utils": "5.10.0", "@rjsf/validator-ajv8": "5.10.0", diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignDates.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignDates.js index 9a15894f04..71bcfa4e44 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignDates.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignDates.js @@ -45,6 +45,9 @@ const CampaignDates = ({ onSelect, formData, ...props }) => { } else if (new Date(endDate).getTime() < new Date(startDate).getTime() && startValidation) { setError({ endDate: "CAMPAIGN_END_DATE_BEFORE_ERROR" }); onSelect("campaignDates", { startDate: startDate, endDate: endDate }); + } else if (startValidation && new Date(endDate).getTime() === new Date(startDate).getTime()) { + setError({ endDate: "CAMPAIGN_END_DATE_SAME_ERROR" }); + onSelect("campaignDates", { startDate: startDate, endDate: endDate }); } else if (startDate || endDate) { setError(null); onSelect("campaignDates", { startDate: startDate, endDate: endDate }); @@ -89,7 +92,7 @@ const CampaignDates = ({ onSelect, formData, ...props }) => { }} min={Digit.Utils.date.getDate(Date.now() + ONE_DAY_IN_MS)} onChange={(d) => { - setStartValidation(true); + // setStartValidation(true); setStart(d); }} /> diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignType.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignType.js index a4f247ac64..22d47594cd 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignType.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignType.js @@ -58,7 +58,7 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {
{ + setLoaderEnabled(false); + }, 1000); + // closeToast(); } }; @@ -256,7 +261,9 @@ function SelectingBoundaries({ onSelect, formData, ...props }) { updatedBoundaryData[type] = []; } }); - setSelectedData(updatedSelectedData); + if (!_.isEqual(selectedData, updatedSelectedData)) { + setSelectedData(updatedSelectedData); + } setBoundaryData(updatedBoundaryData); } return; @@ -317,8 +324,9 @@ function SelectingBoundaries({ onSelect, formData, ...props }) { } }) .flat(); - - setSelectedData(updatedSelectedData); + if (!_.isEqual(selectedData, updatedSelectedData)) { + setSelectedData(updatedSelectedData); + } } else { // Update only the data for the new boundaryType const mergedData = [...selectedData?.filter((item) => item?.type !== newBoundaryType), ...transformedRes]; @@ -337,8 +345,9 @@ function SelectingBoundaries({ onSelect, formData, ...props }) { children.forEach((child) => addChildren(child)); }; filteredData.filter((item) => item.isRoot).forEach((rootItem) => addChildren(rootItem)); - - setSelectedData(updatedSelectedData); + if (!_.isEqual(selectedData, updatedSelectedData)) { + setSelectedData(updatedSelectedData); + } } const parentBoundaryEntry = hierarchyTypeDataresult ? hierarchyTypeDataresult?.boundaryHierarchy?.find( @@ -354,6 +363,7 @@ function SelectingBoundaries({ onSelect, formData, ...props }) { return ( <> + {loaderEnabled && }
{t(`CAMPAIGN_SELECT_BOUNDARY`)}
diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js index 5f51c71886..c78d98166d 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js @@ -50,6 +50,8 @@ const UploadData = ({ formData, onSelect, ...props }) => { const [translatedSchema, setTranslatedSchema] = useState({}); const [readMeInfo, setReadMeInfo] = useState({}); const [enabled, setEnabled] = useState(false); + const currentKey = searchParams.get("key"); + useEffect(() => { if (type === "facilityWithBoundary") { @@ -795,6 +797,10 @@ const UploadData = ({ formData, onSelect, ...props }) => { } }, [showToast]); + useEffect(() => { + setShowToast(null); + }, [currentKey]); + return ( <> {isValidation && } diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useParallelSearch.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useParallelSearch.js new file mode 100644 index 0000000000..985afd73d9 --- /dev/null +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useParallelSearch.js @@ -0,0 +1,20 @@ +const useParallelSearch = ({ parentArray, tenantId, boundaryType, hierarchy, parentCode }) => { + for (const parentCode of parentArray) { + const reqCriteriaBoundaryTypeSearch = Digit.CustomService.getResponse({ + url: "/boundary-service/boundary-relationships/_search", + params: { + tenantId: tenantId, + hierarchyType:hierarchy, + boundaryType: boundaryType, + parent: parentCode, + }, + body: {}, + }); + // setShowToast({ key: "info", label: t("HCM_PLEASE_WAIT_LOADING_BOUNDARY") }); + setLoaderEnabled(true); + const boundaryTypeData = await reqCriteriaBoundaryTypeSearch; + newData.push({ parentCode, boundaryTypeData }); + } +}; + +export default useParallelSearch; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/CycleConfiguration.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/CycleConfiguration.js index 59882ee75e..01f7780f03 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/CycleConfiguration.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/CycleConfiguration.js @@ -2,17 +2,17 @@ import React, { useReducer, Fragment, useEffect, useState } from "react"; import { CardText, LabelFieldPair, Card, CardLabel, CardSubHeader, Paragraph, Header } from "@egovernments/digit-ui-react-components"; import { useTranslation } from "react-i18next"; import { TextInput } from "@egovernments/digit-ui-components"; -import { deliveryConfig } from "../../configs/deliveryConfig"; +// import { deliveryConfig } from "../../configs/deliveryConfig"; -const initialState = (saved, filteredDeliveryConfig) => { +const initialState = (saved, filteredDeliveryConfig, refetch) => { const data = { cycleConfgureDate: { - cycle: saved?.cycleConfgureDate?.cycle + cycle: saved?.cycleConfgureDate?.cycle && !refetch ? saved?.cycleConfgureDate?.cycle : filteredDeliveryConfig?.cycleConfig ? filteredDeliveryConfig?.cycleConfig?.cycle : 1, - deliveries: saved?.cycleConfgureDate?.deliveries + deliveries: saved?.cycleConfgureDate?.deliveries && !refetch ? saved?.cycleConfgureDate?.deliveries : filteredDeliveryConfig?.cycleConfig ? filteredDeliveryConfig?.cycleConfig?.deliveries @@ -27,7 +27,7 @@ const initialState = (saved, filteredDeliveryConfig) => { const reducer = (state, action) => { switch (action.type) { case "RELOAD": - return initialState(action.saved, action.filteredDeliveryConfig); + return initialState(action.saved, action.filteredDeliveryConfig, action.refetch); case "UPDATE_CYCLE": return { ...state, cycleConfgureDate: { ...state.cycleConfgureDate, cycle: action.payload } }; case "UPDATE_DELIVERY": @@ -71,14 +71,15 @@ function CycleConfiguration({ onSelect, formData, control, ...props }) { { select: (data) => { const temp = data?.["HCM-ADMIN-CONSOLE"]?.deliveryConfig; - // return temp?.find((i) => i?.projectType === selectedProjectType); - return deliveryConfig?.find((i) => i?.projectType === selectedProjectType); + return temp?.find((i) => i?.projectType === selectedProjectType); + // return deliveryConfig?.find((i) => i?.projectType === selectedProjectType); }, } ); 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; const tempSession = Digit.SessionStorage.get("HCM_CAMPAIGN_MANAGER_FORM_DATA"); - const [state, dispatch] = useReducer(reducer, initialState(saved, filteredDeliveryConfig)); + const [state, dispatch] = useReducer(reducer, initialState(saved, filteredDeliveryConfig, refetch)); const { cycleConfgureDate, cycleData } = state; const { t } = useTranslation(); const [dateRange, setDateRange] = useState({ @@ -93,6 +94,7 @@ function CycleConfiguration({ onSelect, formData, control, ...props }) { type: "RELOAD", saved: saved, filteredDeliveryConfig: filteredDeliveryConfig, + refetch: refetch, }); } }, [filteredDeliveryConfig, deliveryConfigLoading]); diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyCampaign.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyCampaign.js index 9e906e3ae2..4e72d9f98e 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyCampaign.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyCampaign.js @@ -1,7 +1,7 @@ import React, { useMemo, useState, useEffect } from "react"; import { useTranslation } from "react-i18next"; import { Button, Header, InboxSearchComposer, Loader } from "@egovernments/digit-ui-react-components"; -import { useLocation } from "react-router-dom"; +import { useHistory, useLocation } from "react-router-dom"; import { myCampaignConfig } from "../../configs/myCampaignConfig"; /** @@ -15,6 +15,7 @@ import { myCampaignConfig } from "../../configs/myCampaignConfig"; const MyCampaign = () => { const { t } = useTranslation(); const location = useLocation(); + const history = useHistory(); const moduleName = Digit?.Utils?.getConfigModuleName() || "commonCampaignUiConfig"; const tenant = Digit.ULBService.getStateId(); const tenantId = Digit.ULBService.getCurrentTenantId(); @@ -33,11 +34,44 @@ const MyCampaign = () => { window.Digit.SessionStorage.del("HCM_CAMPAIGN_MANAGER_UPLOAD_ID"); }, []); + const onClickRow = ({ original: row }) => { + const currentTab = tabData?.find((i) => i?.active === true)?.label; + switch (currentTab) { + case "CAMPAIGN_ONGOING": + history.push(`/${window.contextPath}/employee/campaign/setup-campaign?id=${row.id}&preview=${true}&action=${false}`); + break; + case "CAMPAIGN_COMPLETED": + history.push(`/${window.contextPath}/employee/campaign/setup-campaign?id=${row.id}&preview=${true}&action=${false}`); + break; + case "CAMPAIGN_UPCOMING": + history.push(`/${window.contextPath}/employee/campaign/setup-campaign?id=${row.id}&preview=${true}&action=${false}`); + break; + case "CAMPAIGN_DRAFTS": + history.push(`/${window.contextPath}/employee/campaign/setup-campaign?id=${row.id}&draft=${true}&fetchBoundary=${true}`); + break; + case "CAMPAIGN_FAILED": + history.push(`/${window.contextPath}/employee/campaign/setup-campaign?id=${row.id}&preview=${true}&action=${false}`); + break; + default: + break; + } + }; + return (
{t("CAMPAIGN_SEARCH_TITLE")}
- +
); diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js index 708318d9e6..a847562525 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js @@ -254,6 +254,7 @@ const SetupCampaign = ({ hierarchyType }) => { const [fetchBoundary, setFetchBoundary] = useState(() => Boolean(searchParams.get("fetchBoundary"))); const [fetchUpload, setFetchUpload] = useState(false); const [enabled, setEnabled] = useState(false); + // const [active, setActive] = useState(0); const { data: hierarchyConfig } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [{ name: "hierarchyConfig" }]); // const hierarchyType = hierarchyConfig?.["HCM-ADMIN-CONSOLE"]?.hierarchyConfig?.[0]?.hierarchy; @@ -354,6 +355,7 @@ const SetupCampaign = ({ hierarchyType }) => { : { cycle: delivery?.map((obj) => obj?.cycleNumber)?.length > 0 ? Math.max(...delivery?.map((obj) => obj?.cycleNumber)) : 1, deliveries: delivery?.map((obj) => obj?.deliveryNumber)?.length > 0 ? Math.max(...delivery?.map((obj) => obj?.deliveryNumber)) : 1, + refetch: true, }, cycleData: draftData?.additionalDetails?.cycleData?.cycleData ? draftData?.additionalDetails?.cycleData?.cycleData @@ -1134,6 +1136,7 @@ const SetupCampaign = ({ hierarchyType }) => { }; const onStepClick = (step) => { + console.log("step", step); if ((currentKey === 4 || currentKey === 5) && step > 1) { return; } @@ -1157,6 +1160,20 @@ const SetupCampaign = ({ hierarchyType }) => { } }; + // const findHighestStepCount = () => { + // const totalFormDataKeys = Object.keys(totalFormData); + + // const relatedSteps = campaignConfig?.[0]?.form.filter((step) => totalFormDataKeys.includes(step.name)); + + // const highestStep = relatedSteps.reduce((max, step) => Math.max(max, parseInt(step.stepCount)), 0); + + // setActive(highestStep); + // }; + + // useEffect(() => { + // findHighestStepCount(); + // }, [totalFormData, campaignConfig]); + const onSecondayActionClick = () => { if (currentKey > 1) { setShouldUpdate(false); @@ -1225,6 +1242,7 @@ const SetupCampaign = ({ hierarchyType }) => { ]} currentStep={currentStep + 1} onStepClick={onStepClick} + // activeSteps={active} /> )} deleteAttribute(item, deliveryRuleIndex)} @@ -658,7 +661,7 @@ const AddDeliveryRule = ({ targetedData, deliveryRules, setDeliveryRules, index, variation="secondary" className={"add-product-btn hover"} label={t(`CAMPAIGN_ADD_PRODUCTS_BUTTON_TEXT`)} - icon={} + icon={} onButtonClick={() => setShowModal(true)} /> @@ -696,12 +699,12 @@ const AddDeliveryRule = ({ targetedData, deliveryRules, setDeliveryRules, index, const AddDeliveryRuleWrapper = ({}) => { const { campaignData, dispatchCampaignData, filteredDeliveryConfig } = useContext(CycleContext); - const [targetedData, setTargetedData] = useState(campaignData.find((i) => i.active === true).deliveries.find((d) => d.active === true)); + const [targetedData, setTargetedData] = useState(campaignData?.find((i) => i?.active === true)?.deliveries?.find((d) => d?.active === true)); const [deliveryRules, setDeliveryRules] = useState(targetedData?.deliveryRules); const { t } = useTranslation(); useEffect(() => { - const dd = campaignData.find((i) => i.active === true).deliveries.find((d) => d.active === true); + const dd = campaignData?.find((i) => i?.active === true)?.deliveries?.find((d) => d?.active === true); setTargetedData(dd); }, [campaignData]); diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/deliveryRule/MultiTabcontext.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/deliveryRule/MultiTabcontext.js index 8fe47a6952..c02ce7d486 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/deliveryRule/MultiTabcontext.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/deliveryRule/MultiTabcontext.js @@ -168,8 +168,8 @@ const SubTabs = ({ onSubTabChange }) => { return (
{campaignData - .find((i) => i.active === true) - .deliveries.map((_, index) => ( + ?.find((i) => i?.active === true) + ?.deliveries.map((_, index) => (