Skip to content

Commit

Permalink
BUGFIX/HCMPRE-2243 : Showing only supported campaign types and minor …
Browse files Browse the repository at this point in the history
…fixes (#2187)

* BUGFIX/HCMPRE-2243 : Showing only supported campaign types for microplan ui (#2185)

* BUGFIX/HCMPRE-2243 : Showing only supported campaign types for microplan

* Added review changes

* Updated to hcm-microplanning module

* Fixed typo

* BUGFIX/HCMPRE-2250 : Added loader while data is loading  (#2193)

BUGFIX/HCMPRE-2250 : Added loader while data is loading for the Boundary KPI

* BUGFIX/HCMPRE-1818: Height of FilterCard Changed (#2191)

---------

Co-authored-by: Swathi-eGov <137176788+Swathi-eGov@users.noreply.github.com>
Co-authored-by: abishekTa-egov <abishek.t@egovernments.org>
  • Loading branch information
3 people authored Feb 6, 2025
1 parent bcb3a79 commit 71f636a
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<title>DIGIT</title>
<link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-css@1.8.12/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-components-css@0.0.2-beta.44/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-health-css@0.2.44/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-health-css@0.2.45/dist/index.css" />

<!-- added below css for hcm-workbench module inclusion-->
<!-- <link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-css@1.5.41/dist/index.css" /> -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egovernments/digit-ui-health-css",
"version": "0.2.44",
"version": "0.2.45",
"license": "MIT",
"main": "dist/index.css",
"author": "Jagankumar <jagan.kumar@egov.org.in>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,3 +548,15 @@ tbody tr:last-child td:last-child .digit-dropdown-employee-select-wrap .digit-dr
color: #363636;
font-size: 1.1rem;
}

.pop-inbox-wrapper-filter-table-wrapper.planInbox-filtercard-table-wrapper {
align-items: stretch;
}

.filter-card{
&.plan-inbox-filtercard{
.content-container{
flex:1;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import React from 'react';
import { Card } from '@egovernments/digit-ui-components';
import { Loader } from '@egovernments/digit-ui-components';
import { useMyContext } from '../utils/context';
import { useTranslation } from 'react-i18next';
import { Fragment } from 'react';
const BoundaryKpi = ({ data, heading }) => {
const { state: { boundaryHierarchy } } = useMyContext()
const { t } = useTranslation();

if (!data || Object.keys(data).length === 0) {
return <Card className="middle-child"> {<Loader />}</Card>;
}

return (

<Card className="middle-child">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ const BoundarySelection = ({ onSelect, props: customProps, ...props }) => {
const [statusMap, setStatusMap] = useState({});
const [executionCount, setExecutionCount] = useState(0);
const [updateBoundary, setUpdateBoundary] = useState(true);
const [isStatusMapLoading, setIsStatusMapLoading] = useState(false);
const [showPopup, setShowPopup] = useState(false);
const handleBoundaryChange = (value) => {
setBoundaryOptions(value?.boundaryOptions);
setSelectedData(value?.selectedData);
};

const [showPopup, setShowPopup] = useState(false)


const { campaignId, microplanId, key, ...queryParams } = Digit.Hooks.useQueryParams();
Expand Down Expand Up @@ -52,25 +51,18 @@ const BoundarySelection = ({ onSelect, props: customProps, ...props }) => {
//to show alert
useEffect(() => {
//if there are any assumptions filled show this popup by default
if (campaignObject?.boundaries?.length > 0) {
if (campaignObject?.boundaries?.length > 0 && !showPopup) {
setShowPopup(true)
}
}, [campaignObject, isLoadingCampaignObject])


useEffect(() => {
// Show loader before updating statusMap
setIsStatusMapLoading(true);
setStatusMap(null);
if (selectedData && selectedData.length >= 0) {
const newStatusMap = Digit.Utils.microplanv1.createStatusMap(selectedData, boundaryHierarchy);
setStatusMap(newStatusMap);
// Hide loader after updating statusMap
setIsStatusMapLoading(false);
}
return () => {
// Cleanup function to prevent state updates if component unmounts during loading
setIsStatusMapLoading(false);
};
}, [selectedData, boundaryHierarchy]);


Expand Down Expand Up @@ -104,7 +96,7 @@ const BoundarySelection = ({ onSelect, props: customProps, ...props }) => {

return (
<>
{isStatusMapLoading ? <Loader /> : <BoundaryKpi data={statusMap} />}
<BoundaryKpi data={statusMap} />
<CardNew className={"selecting-boundary-card"}>
<Header styles={{ margin: "0rem" }}>{t(`MICROPLAN_SELECT_BOUNDARY`)}</Header>
<p className="boundary-selection-description">{t(`MICROPLAN_SELECT_BOUNDARIES_DESCRIPTION`)}</p>
Expand All @@ -121,39 +113,41 @@ const BoundarySelection = ({ onSelect, props: customProps, ...props }) => {
}}
></BoundaryWrapper>
</CardNew>
{showPopup && <PopUp
className={"boundaries-pop-module"}
type={"alert"}
alertHeading={t("MP_WARNING_BOUNDARIES_FORM")}
alertMessage={t("MP_FILES_INVALIDATION_MESSAGE")}
// heading={t("MP_ASSUMTI")}
// children={[
// <div>
// <CardText style={{ margin: 0 }}>{t("ES_CAMPAIGN_UPDATE_TYPE_MODAL_TEXT") + " "}</CardText>
// </div>,
// ]}
onOverlayClick={() => {
setShowPopup(false);
}}
onClose={() => {
setShowPopup(false);
}}
footerChildren={[
<Button
className={"campaign-type-alert-button"}
type={"button"}
size={"large"}
variation={"secondary"}
label={t("MP_ACK")}
title={t("MP_ACK")}
onClick={() => {
setShowPopup(false);
// setCanUpdate(true);
}}
/>
]}
// sortFooterChildren={true}
></PopUp>}
{showPopup && (
<PopUp
className={"boundaries-pop-module"}
type={"alert"}
alertHeading={t("MP_WARNING_BOUNDARIES_FORM")}
alertMessage={t("MP_FILES_INVALIDATION_MESSAGE")}
// heading={t("MP_ASSUMTI")}
// children={[
// <div>
// <CardText style={{ margin: 0 }}>{t("ES_CAMPAIGN_UPDATE_TYPE_MODAL_TEXT") + " "}</CardText>
// </div>,
// ]}
onOverlayClick={() => {
setShowPopup(false);
}}
onClose={() => {
setShowPopup(false);
}}
footerChildren={[
<Button
className={"campaign-type-alert-button"}
type={"button"}
size={"large"}
variation={"secondary"}
label={t("MP_ACK")}
title={t("MP_ACK")}
onClick={() => {
setShowPopup(false);
// setCanUpdate(true);
}}
/>,
]}
// sortFooterChildren={true}
></PopUp>
)}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ const CampaignDetails = ({ onSelect, props: customProps, ...props }) => {
{ schemaCode: "ProjectType" }
);

const campaignTypeOptions = state?.MicroplanCampaignTypes?.map(item => item.code) || [];

useEffect(() => {
onSelect(customProps.name, {
distributionStrat,
Expand Down Expand Up @@ -112,7 +114,7 @@ const CampaignDetails = ({ onSelect, props: customProps, ...props }) => {
// variant={error ? "error" : ""}
t={t}
option={data?.campaignTypes?.filter(
(campaign) => campaign.code !== "IRS-mz"
(campaign) => campaignTypeOptions?.includes(campaign.code)
)}
optionKey={"i18nKey"}
selected={campaignType}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const InboxFilterWrapper = (props) => {
const [filterValues, setFilterValues] = useState(
{ status: null, onRoadCondition: null, terrain: null, securityQ1: null, securityQ2: null, facilityId:null }
);

// Default selected option
let defaultSelectedOptions = props.defaultValue
? Object.entries(props.defaultValue).reduce((acc, [key, value]) => {
Expand Down Expand Up @@ -161,8 +161,9 @@ const InboxFilterWrapper = (props) => {
primaryActionLabel={resultArray.length > 0 && t(props?.primaryActionLabel)}
secondaryActionLabel={resultArray.length > 0 && t(props?.secondaryActionLabel)}
title={t(props?.title)}
className={props?.isPlanInbox ? "plan-inbox-filtercard" : ""}
>
<div className="gap-between-dropdowns" style={{ height: "18rem" }}>
<div className="gap-between-dropdowns">
{/* Only render LabelFieldPair if resultArray has items */}
{resultArray.length > 0 && (
<LabelFieldPair vertical style={{ marginBottom: "1rem" }} >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const PlanInbox = () => {
const [defaultBoundaries, setDefaultBoundaries] = useState([]);
const userRoles = user?.info?.roles?.map((roleData) => roleData?.code);
const hrms_context_path = window?.globalConfigs?.getConfig("HRMS_CONTEXT_PATH") || 'health-hrms';

// Check if the user has the 'rootapprover' role
const isRootApprover = userRoles?.includes("ROOT_PLAN_ESTIMATION_APPROVER");

Expand Down Expand Up @@ -849,6 +849,7 @@ const PlanInbox = () => {
userRole = "PLAN_ESTIMATION_APPROVER";
}
});


return (
<div className="pop-inbox-wrapper">
Expand Down Expand Up @@ -879,7 +880,7 @@ const PlanInbox = () => {
/>

<div
className="pop-inbox-wrapper-filter-table-wrapper"
className="pop-inbox-wrapper-filter-table-wrapper planInbox-filtercard-table-wrapper"
style={{
marginBottom:
(isRootApprover && isStatusConditionMet(totalStatusCount) && planObject?.status === "RESOURCE_ESTIMATION_IN_PROGRESS") ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ const App = ({ path, stateCode, userType, tenants, BOUNDARY_HIERARCHY_TYPE, hier
{ name: "VehicleDetails" },
{ name: "ContextPathForUser" },
{ name: "DssKpiConfigs" },
{ name: "MicroplanCampaignTypes" },
],
{
cacheTime: Infinity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,13 @@ const destroySessionHelper = (currentPath, pathList, sessionName) => {
};

function createStatusMap(data, boundaryHierarchy) {
// Initialize an empty map to store counts of each type
const statusMap = {};
boundaryHierarchy.forEach((boundary) => {
statusMap[boundary.boundaryType] = 0;
});

if (data.length === 0) return statusMap;
// Iterate over each object in the array
data?.forEach((item) => {
// If the type already exists in the map, increment the count
if (statusMap[item.type]) {
statusMap[item.type]++;
} else {
// Otherwise, initialize the count for this type
statusMap[item.type] = 1;
}
});

return statusMap;
return data.reduce((statusMap, { type }) => {
statusMap[type] = (statusMap[type] || 0) + 1;
return statusMap;
}, boundaryHierarchy.reduce((initialMap, { boundaryType }) => {
initialMap[boundaryType] = 0;
return initialMap;
}, {}));
}

const formValidator = (formData, key, state, t) => {
Expand Down
2 changes: 1 addition & 1 deletion health/micro-ui/web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-css@1.8.12/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-components-css@0.0.2-beta.44/dist/index.css" />
<!-- added below css for hcm-workbench module inclusion-->
<link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-health-css@0.2.44/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-health-css@0.2.45/dist/index.css" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#00bcd1" />
<title>DIGIT HCM</title>
Expand Down

0 comments on commit 71f636a

Please sign in to comment.