Skip to content

Commit

Permalink
FEATURE/HCMPRE-2207 : removed the hard coded project types (#2157)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhavya-egov authored Jan 24, 2025
1 parent 3f117db commit 75fd4ad
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 29 deletions.
2 changes: 1 addition & 1 deletion health/micro-ui/web/console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"homepage": "/console",
"dependencies": {
"@egovernments/digit-ui-libraries": "1.8.8",
"@egovernments/digit-ui-module-core": "1.8.17",
"@egovernments/digit-ui-module-core": "1.8.20",
"@egovernments/digit-ui-components": "0.0.2-beta.64",
"@egovernments/digit-ui-react-components": "1.8.14",
"@egovernments/digit-ui-module-campaign-manager": "0.3.0",
Expand Down
2 changes: 1 addition & 1 deletion health/micro-ui/web/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"@egovernments/digit-ui-libraries": "1.8.8",
"@egovernments/digit-ui-module-workbench": "1.0.12",
"@egovernments/digit-ui-module-core": "1.8.15",
"@egovernments/digit-ui-module-core": "1.8.20",
"@egovernments/digit-ui-module-utilities": "1.0.10",
"@egovernments/digit-ui-components":"0.0.2-beta.56",
"@egovernments/digit-ui-react-components": "1.8.14",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@egovernments/digit-ui-libraries": "1.8.8",
"@egovernments/digit-ui-module-workbench": "1.0.12",
"@egovernments/digit-ui-components": "0.0.2-beta.58",
"@egovernments/digit-ui-module-core": "1.8.15",
"@egovernments/digit-ui-module-core": "1.8.20",
"@egovernments/digit-ui-module-utilities": "1.0.3",
"@egovernments/digit-ui-react-components": "1.8.14",
"@egovernments/digit-ui-module-hcmworkbench": "0.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import React, { useState, useEffect } from "react";
import { useTranslation } from "react-i18next";
import { useHistory, useLocation } from "react-router-dom";
import { dateChangeBoundaryConfig, dateChangeConfig } from "../../configs/dateChangeBoundaryConfig";
import { Button, InfoCard, PopUp, Toast , Tag} from "@egovernments/digit-ui-components";
import { Button, InfoCard, PopUp, Toast, Tag } from "@egovernments/digit-ui-components";
import getProjectServiceUrl from "../../utils/getProjectServiceUrl";
import { CONSOLE_MDMS_MODULENAME } from "../../Module";
import TagComponent from "../../components/TagComponent";


function UpdateDatesWithBoundaries() {
const { t } = useTranslation();
const history = useHistory();
Expand Down Expand Up @@ -39,30 +38,46 @@ function UpdateDatesWithBoundaries() {
}
}, [showToast]);

const isMultiCycle = (data) => {
const cycles = data?.additionalDetails?.projectType?.cycles;

// Check if cycles exist and the number of cycles is greater than 1
if (cycles?.length > 1) {
return true;
}

// Check if any cycle has more than one delivery
for (const cycle of cycles || []) {
if (cycle.deliveries?.length > 1) {
return true;
}
}

return false;
};

const checkValid = (data) => {
if (DateWithBoundary) {
const temp = data?.dateWithBoundary;
// const allCycleDateValid = temp
// .map((i) => i?.additionalDetails?.projectType?.cycles.every((j) => j?.startDate && j?.endDate))
// .every((k) => k === true);
const allCycleDateValid = temp?.projectType === "MR-DN"
? temp.map((i) => i?.additionalDetails?.projectType?.cycles.every((j) => j?.startDate && j?.endDate)).every((k) => k === true)
: true;
const isMultiCycles = isMultiCycle(temp?.[0]);
const allCycleDateValid =
isMultiCycles
? temp.map((i) => i?.additionalDetails?.projectType?.cycles.every((j) => j?.startDate && j?.endDate)).every((k) => k === true)
: true;
const allDateValid = temp.every((i) => i?.startDate && i?.endDate);

if (temp?.projectType === "MR-DN" && allCycleDateValid && allDateValid) {
if (isMultiCycles && allCycleDateValid && allDateValid) {
return true;
}
else if (temp?.projectType !== "MR-DN" && allDateValid) {
} else if (!isMultiCycles && allDateValid) {
return true;
}
return false;
} else if (!DateWithBoundary) {
const isMultiCycles = isMultiCycle(data?.dateAndCycle);
const cycleDateValid = data?.dateAndCycle?.additionalDetails?.projectType?.cycles?.every((item) => item?.startDate && item?.endDate);
if (data?.dateAndCycle?.projectType === "MR-DN" && data?.dateAndCycle?.startDate && data?.dateAndCycle?.endDate && cycleDateValid) {
if (isMultiCycles && data?.dateAndCycle?.startDate && data?.dateAndCycle?.endDate && cycleDateValid) {
return true;
}
else if (data?.dateAndCycle?.projectType !== "MR-DN" && data?.dateAndCycle?.startDate && data?.dateAndCycle?.endDate) {
} else if (!isMultiCycles && data?.dateAndCycle?.startDate && data?.dateAndCycle?.endDate) {
return true;
}
return false;
Expand Down Expand Up @@ -117,7 +132,7 @@ function UpdateDatesWithBoundaries() {
// text: t("ES_CAMPAIGN_CREATE_SUCCESS_RESPONSE_TEXTKK"),
// info: t("ES_CAMPAIGN_SUCCESS_INFO_TEXTKK"),
actionLabel: t("HCM_DATE_CHANGE_SUCCESS_RESPONSE_ACTION"),
actionLink: `/${window.contextPath}/employee/campaign/setup-campaign?id=${id}&preview=true&action=false&actionBar=true&key=16&summary=true`
actionLink: `/${window.contextPath}/employee/campaign/setup-campaign?id=${id}&preview=true&action=false&actionBar=true&key=16&summary=true`,
});
} else {
const url = getProjectServiceUrl();
Expand Down Expand Up @@ -179,8 +194,9 @@ function UpdateDatesWithBoundaries() {
}}
variant="default"
style={{ marginBottom: "1.5rem", marginTop: "1.5rem", marginLeft: "0rem", maxWidth: "100%" }}
additionalElements={[<span style={{ color: "#505A5F" }}>{t(`UPDATE_DATE_CHANGE_INFO_TEXT1`)}</span>,
<span style={{ color: "#505A5F" }}>{t(`UPDATE_DATE_CHANGE_INFO_TEXT2`)}</span>
additionalElements={[
<span style={{ color: "#505A5F" }}>{t(`UPDATE_DATE_CHANGE_INFO_TEXT1`)}</span>,
<span style={{ color: "#505A5F" }}>{t(`UPDATE_DATE_CHANGE_INFO_TEXT2`)}</span>,
]}
label={"Info"}
headerClassName={"headerClassName"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,7 @@ const AddDeliveryRule = ({ targetedData, deliveryRules, setDeliveryRules, index,
)}
</CardHeader>
{filteredDeliveryConfig?.customAttribute &&
filteredDeliveryConfig?.projectType !== "LLIN-mz" &&
filteredDeliveryConfig?.projectType !== "IRS-mz" && (
!filteredDeliveryConfig?.IsCycleDisable && (
<LabelFieldPair style={{ marginTop: "1.5rem", marginBottom: "1.5rem" }} className="delivery-type-radio">
<div className="deliveryType-labelfield">
<span className="bold">{`${t("HCM_DELIVERY_TYPE")}`}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function AddProducts({ stref, selectedDelivery, showToast, closeToast, selectedP
optionKey="displayName"
/>
</LabelFieldPair>
{filteredDeliveryConfig?.projectType === "MR-DN" && (
{!filteredDeliveryConfig?.productCountHide && (
<LabelFieldPair style={{ display: "flex", flexDirection: "column", alignItems: "flex-start" }}>
<Label>{t(`CAMPAIGN_COUNT_LABEL`)}</Label>
<TextInput type="numeric" defaultValue={i?.quantity} value={i?.quantity} onChange={(d) => incrementC(i, d)} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const generateConfig = (data) => {
dashboardUrls: data?.dashboardUrls,
taskProcedure: data?.taskProcedure,
resources: data?.resources,
IsCycleDisable: data?.IsCycleDisable,
cycleConfig: {
cycle: data?.cycles?.length || 1,
deliveries: data?.cycles?.[0]?.deliveries?.length || 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
cycle.deliveries.forEach((delivery) => {
delivery.deliveryRules.forEach((rule) => {
// Validate attributes and products length
if (projectType === "MR-DN" && !rule?.deliveryType) {
if (!rule?.deliveryType) {
isValid = false;
deliveryRulesError?.push({
name: `CYCLE_${cycle?.cycleIndex}`,
Expand Down
2 changes: 1 addition & 1 deletion health/micro-ui/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@egovernments/digit-ui-libraries": "1.8.2-beta.8",
"@egovernments/digit-ui-module-workbench": "1.0.2-beta.7",
"@egovernments/digit-ui-module-core": "1.8.15",
"@egovernments/digit-ui-module-core": "1.8.20",
"@egovernments/digit-ui-module-hrms": "1.8.0-beta.2",
"@egovernments/digit-ui-react-components": "1.8.14",
"@egovernments/digit-ui-components": "0.0.2-beta.58",
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@egovernments/digit-ui-libraries": "1.8.3",
"@egovernments/digit-ui-module-workbench": "1.0.6",
"@egovernments/digit-ui-module-core": "1.8.2",
"@egovernments/digit-ui-module-core": "1.8.20",
"@egovernments/digit-ui-module-pgr": "1.8.0",
"@egovernments/digit-ui-react-components": "1.8.4",
"@egovernments/digit-ui-module-utilities": "1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/micro-ui-internals/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@egovernments/digit-ui-libraries": "1.8.3",
"@egovernments/digit-ui-module-workbench": "1.0.6",
"@egovernments/digit-ui-module-dss": "1.8.0",
"@egovernments/digit-ui-module-core": "1.8.2",
"@egovernments/digit-ui-module-core": "1.8.20",
"@egovernments/digit-ui-module-common": "1.8.0",
"@egovernments/digit-ui-module-pgr": "1.8.0",
"@egovernments/digit-ui-module-hrms": "1.8.0",
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@egovernments/digit-ui-libraries": "1.8.3",
"@egovernments/digit-ui-module-workbench": "1.0.6",
"@egovernments/digit-ui-module-core": "1.8.2",
"@egovernments/digit-ui-module-core": "1.8.20",
"@egovernments/digit-ui-module-hrms": "1.8.0",
"@egovernments/digit-ui-react-components": "1.8.4",
"@egovernments/digit-ui-module-dss": "1.8.0",
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/workbench/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@egovernments/digit-ui-libraries": "1.8.3",
"@egovernments/digit-ui-module-workbench": "1.0.6",
"@egovernments/digit-ui-module-core": "1.8.2",
"@egovernments/digit-ui-module-core": "1.8.20",
"@egovernments/digit-ui-react-components": "1.8.4",
"@egovernments/digit-ui-module-utilities": "1.0.0",
"@egovernments/digit-ui-module-hrms":"1.8.0",
Expand Down

0 comments on commit 75fd4ad

Please sign in to comment.