From f9a5d300bb53bc9e95bd97221634636063ab39bd Mon Sep 17 00:00:00 2001 From: nabeelmd-eGov Date: Wed, 10 Apr 2024 19:03:30 +0530 Subject: [PATCH 1/3] Bug fixes --- .../example/public/index.html | 2 +- .../packages/css/package.json | 2 +- .../css/src/pages/employee/index.scss | 14 ++++++++++ .../src/components/CampaignSummary.js | 26 ++++++++++++++----- .../src/components/CycleDetaisPreview.js | 2 +- .../src/pages/employee/SetupCampaign.js | 24 ++++++++++------- .../deliveryRule/AddDeliverycontext.js | 9 ++++--- .../src/pages/employee/deliveryRule/index.js | 2 +- micro-ui/web/public/index.html | 2 +- 9 files changed, 59 insertions(+), 24 deletions(-) diff --git a/micro-ui/web/micro-ui-internals/example/public/index.html b/micro-ui/web/micro-ui-internals/example/public/index.html index 860176b6111..8976d1f3021 100644 --- a/micro-ui/web/micro-ui-internals/example/public/index.html +++ b/micro-ui/web/micro-ui-internals/example/public/index.html @@ -16,7 +16,7 @@ /> --> - + diff --git a/micro-ui/web/micro-ui-internals/packages/css/package.json b/micro-ui/web/micro-ui-internals/packages/css/package.json index b13f6088ccd..4df1b5dca60 100644 --- a/micro-ui/web/micro-ui-internals/packages/css/package.json +++ b/micro-ui/web/micro-ui-internals/packages/css/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-css", - "version": "1.0.9-campaign", + "version": "1.0.10-campaign", "license": "MIT", "main": "dist/index.css", "author": "Jagankumar ", diff --git a/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss b/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss index b672ae1883a..a09e9b231e5 100644 --- a/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss +++ b/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss @@ -133,3 +133,17 @@ input[type="date"]::-webkit-calendar-picker-indicator { top: 20%; transform: translateY(-50%); } +.campaign-preview-edit-container { + display: flex; + gap: 1rem; + span { + color: #f47738; + } +} +.campaign-attribute-table { + tbody { + tr:nth-child(odd) { + background-color: white; + } + } +} diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignSummary.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignSummary.js index 9db51ddc780..6c955efc97a 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignSummary.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignSummary.js @@ -25,7 +25,8 @@ const CampaignSummary = () => { type: "DATA", cardHeader: { value: t("CAMPAIGN_DETAILS"), inlineStyles: { marginTop: 0 } }, cardSecondaryAction: ( -
handleRedirect(1)}> +
handleRedirect(1)}> + Edit
), @@ -56,7 +57,8 @@ const CampaignSummary = () => { type: "DATA", cardHeader: { value: t("TARGET_DETAILS"), inlineStyles: { marginTop: 0 } }, cardSecondaryAction: ( -
handleRedirect(2)}> +
handleRedirect(4)}> + Edit
), @@ -74,7 +76,12 @@ const CampaignSummary = () => { { type: "COMPONENT", cardHeader: { value: t("DELIVERY_CYCLE_DETAILS"), inlineStyles: { marginTop: 0 } }, - cardSecondaryAction: , + cardSecondaryAction: ( +
handleRedirect(2)}> + Edit + +
+ ), component: "CycleDetaisPreview", props: { data: data?.[0], @@ -269,7 +276,8 @@ const CampaignSummary = () => { type: "DATA", cardHeader: { value: t("CAMPAIGN_DETAILS"), inlineStyles: { marginTop: 0 } }, cardSecondaryAction: ( -
handleRedirect(1)}> +
handleRedirect(1)}> + Edit
), @@ -300,7 +308,8 @@ const CampaignSummary = () => { type: "DATA", cardHeader: { value: t("TARGET_DETAILS"), inlineStyles: { marginTop: 0 } }, cardSecondaryAction: ( -
handleRedirect(2)}> +
handleRedirect(4)}> + Edit
), @@ -318,7 +327,12 @@ const CampaignSummary = () => { { type: "COMPONENT", cardHeader: { value: t("DELIVERY_CYCLE_DETAILS"), inlineStyles: { marginTop: 0 } }, - cardSecondaryAction: , + cardSecondaryAction: ( +
handleRedirect(2)}> + Edit + +
+ ), component: "CycleDetaisPreview", props: { DUMMY_DATA: DUMMY_DATA?.[0], diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CycleDetaisPreview.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CycleDetaisPreview.js index 9b64d1ab825..c15cb50031e 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CycleDetaisPreview.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CycleDetaisPreview.js @@ -99,7 +99,7 @@ const CycleDetaisPreview = ({ data, item, index }) => { columnsData={[ { Header: t("Product"), - accessor: "product", + accessor: "value", }, { Header: t("Count"), diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js index b7076c1e0a6..b395fcdca07 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js @@ -90,8 +90,8 @@ const SetupCampaign = () => { cycle.deliveries.forEach((delivery, index) => { delivery.deliveryRules.forEach((rule) => { const restructuredRule = { - startDate: Digit.Utils.date.convertDateToEpoch(dateData?.find((i) => i.key === cycle.cycleIndex)?.fromDate), // Hardcoded for now - endDate: Digit.Utils.date.convertDateToEpoch(dateData?.find((i) => i?.key === cycle?.cycleIndex)?.toDate), // Hardcoded for now + startDate: Digit.Utils.date.convertDateToEpoch(dateData?.find((i) => i.key == cycle.cycleIndex)?.fromDate), // Hardcoded for now + endDate: Digit.Utils.date.convertDateToEpoch(dateData?.find((i) => i?.key == cycle?.cycleIndex)?.toDate), // Hardcoded for now cycleNumber: parseInt(cycle.cycleIndex), deliveryNumber: parseInt(delivery.deliveryIndex), deliveryRuleNumber: parseInt(rule.ruleKey), // New key added @@ -107,6 +107,13 @@ const SetupCampaign = () => { }); }); + rule.products.forEach((prod) => { + restructuredRule.products.push({ + value: prod?.value, + count: prod?.count, + }); + }); + restructuredData.push(restructuredRule); }); }); @@ -295,13 +302,12 @@ const SetupCampaign = () => { const key = Object.keys(formData)?.[0]; switch (key) { case "campaignName": - if (typeof formData?.campaignName !== 'string' || !formData?.campaignName.trim() ) { - setShowToast({ key: "error", label: "CAMPAIGN_NAME_MISSING_TYPE_ERROR" }); - return false; - } - else { - return true; - } + if (typeof formData?.campaignName !== "string" || !formData?.campaignName.trim()) { + setShowToast({ key: "error", label: "CAMPAIGN_NAME_MISSING_TYPE_ERROR" }); + return false; + } else { + return true; + } case "campaignDates": const startDateObj = new Date(formData?.campaignDates?.startDate); const endDateObj = new Date(formData?.campaignDates?.endDate); diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/deliveryRule/AddDeliverycontext.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/deliveryRule/AddDeliverycontext.js index 62c8d456782..cf63303953d 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/deliveryRule/AddDeliverycontext.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/deliveryRule/AddDeliverycontext.js @@ -60,7 +60,7 @@ const AddAttributeField = ({ deliveryRuleIndex, delivery, deliveryRules, setDeli // setAttributes((pre) => pre.map((item) => (item.key === attribute.key ? { ...item, value: e.target.value } : item))); const updatedData = deliveryRules.map((item, index) => { if (item.ruleKey === deliveryRuleIndex) { - item.attributes.find((i) => i.key === attribute.key).value = value; + item.attributes.find((i) => i.key === attribute.key).value = value?.code; } return item; }); @@ -457,11 +457,12 @@ const AddDeliveryRule = ({ targetedData, deliveryRules, setDeliveryRules, index, }; const removeProduct = (item) => { + const temp = delivery; setDeliveryRules((prevState) => { const updatedDeliveryRules = prevState.map((delivery) => { - if (delivery.ruleKey === delivery.ruleKey) { + if (delivery.ruleKey === temp.ruleKey) { const updatedProducts = delivery.products - .filter((product) => product.key !== item.key) + .filter((product) => product.value !== item.value) .map((product, index) => ({ ...product, key: index + 1 })); return { ...delivery, products: updatedProducts }; } @@ -498,7 +499,7 @@ const AddDeliveryRule = ({ targetedData, deliveryRules, setDeliveryRules, index, {delivery?.products?.length > 0 && delivery?.products?.map((i) => { - i?.value && i.count ? removeProduct(i)} /> : null; + return i?.value && i?.count ? removeProduct(i)} /> : null; })}