From 8a956ab78be63c4ee51bf2b7fa0d9190979d7869 Mon Sep 17 00:00:00 2001 From: Abishek Date: Tue, 17 Dec 2024 14:41:23 +0530 Subject: [PATCH 01/10] Adding filters --- .../css/src/components/microplan.scss | 7 ++ .../src/components/InboxFilterWrapper.js | 72 +++++++++++++++++-- 2 files changed, 75 insertions(+), 4 deletions(-) diff --git a/health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss b/health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss index b330f694f65..43615ed9d46 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss +++ b/health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss @@ -526,4 +526,11 @@ tbody tr:last-child td:last-child .digit-dropdown-employee-select-wrap .digit-dr } } } +} + +.gap-between-dropdowns{ + display:flex; + flex-direction: column; + gap: 1rem; + } \ No newline at end of file diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js index 3a9135ec23b..913c27a2fd1 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js @@ -1,9 +1,18 @@ import React, { useState, useEffect } from "react"; import { useTranslation } from "react-i18next"; -import { FilterCard, LabelFieldPair, RadioButtons } from "@egovernments/digit-ui-components"; +import { FilterCard, Dropdown, LabelFieldPair, RadioButtons, TextBlock } from "@egovernments/digit-ui-components"; +import { useMyContext } from "../utils/context"; + const InboxFilterWrapper = (props) => { + const { state } = useMyContext(); const { t } = useTranslation(); + const [dropdown1Value, setDropdown1Value] = useState(null); + const [dropdown2Value, setDropdown2Value] = useState(null); + const [dropdownValues, setDropdownValues] = useState( + Array(state.securityQuestions.length).fill(null) + ); + // Default selected option const defaultSelectedOption = props.defaultValue @@ -57,9 +66,15 @@ const InboxFilterWrapper = (props) => { } }; + const handleDropdownChange = (index, value) => { + const newValues = [...dropdownValues]; + newValues[index] = value; + setDropdownValues(newValues); + }; + return ( { secondaryActionLabel={resultArray.length > 0 && t(props?.secondaryActionLabel)} title={t(props?.title)} > -
+
{/* Only render LabelFieldPair if resultArray has items */} {resultArray.length > 0 && ( - + { /> )} + + + + handleDropdownChange(value, 0)} + t={t} + disabled={false} + /> + + + + + handleDropdownChange(value, 1)} + t={t} + disabled={false} + /> + + + + {state.securityQuestions.map((item, index) => { + // Transform item.values into an array of objects + const options = item.values.map((value) => ({ + code: value, + name: value, + active: true, + })); + + return ( + + + handleDropdownChange(value, index + 2)} // Handle selection + t={(key) => key} // Translation function (you can replace as needed) + disabled={false} + /> + + ); + })} +
); From 3ffaa6d8c95196b55f27da4ecfd67930218987f7 Mon Sep 17 00:00:00 2001 From: Abishek Date: Mon, 23 Dec 2024 16:28:52 +0530 Subject: [PATCH 02/10] Working Filter Search --- .../src/components/InboxFilterWrapper.js | 39 +++++---- .../microplan/src/pages/employee/PlanInbox.js | 82 ++++++++++++------- 2 files changed, 76 insertions(+), 45 deletions(-) diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js index 913c27a2fd1..357741c991d 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js @@ -9,8 +9,8 @@ const InboxFilterWrapper = (props) => { const { t } = useTranslation(); const [dropdown1Value, setDropdown1Value] = useState(null); const [dropdown2Value, setDropdown2Value] = useState(null); - const [dropdownValues, setDropdownValues] = useState( - Array(state.securityQuestions.length).fill(null) + const [filterValues, setFilterValues] = useState( + {status:null,onRoadCondition:null, terrain:null, securityQ1:null,securityQ2:null} ); @@ -54,22 +54,27 @@ const InboxFilterWrapper = (props) => { // Apply filters when the user presses the primary action button const handleApplyFilters = () => { if (props.onApplyFilters) { - props.onApplyFilters(selectedValue); // Call the parent function with selected value + debugger; + console.log("filt",filterValues); + props.onApplyFilters(filterValues); // Call the parent function with selected value } }; // Clear filters when the user presses the secondary action button const clearFilters = () => { - setSelectedValue(selectedValue); // Clear the selection + // setSelectedValue(selectedValue); // Clear the selection + setFilterValues({status:null,onRoadCondition:null,terrain:null,securityQ1:null,securityQ2:null}); if (props.clearFilters) { props.clearFilters(); } }; - const handleDropdownChange = (index, value) => { - const newValues = [...dropdownValues]; - newValues[index] = value; - setDropdownValues(newValues); + const handleDropdownChange = (key, value) => { + console.log("filter",value) + setFilterValues((prev)=>({ + ...prev, + [key]:value?.code + })); }; return ( @@ -90,13 +95,13 @@ const InboxFilterWrapper = (props) => { handleDropdownChange("status",value)} // Function to handle selection /> )} @@ -106,8 +111,8 @@ const InboxFilterWrapper = (props) => { handleDropdownChange(value, 0)} + selected={filterValues["onRoadCondition"]} + select={(value) => handleDropdownChange("onRoadCondition",value)} t={t} disabled={false} /> @@ -118,8 +123,8 @@ const InboxFilterWrapper = (props) => { handleDropdownChange(value, 1)} + selected={filterValues["terrain"]} + select={(value) => handleDropdownChange("terrain",value)} t={t} disabled={false} /> @@ -136,12 +141,12 @@ const InboxFilterWrapper = (props) => { return ( - + handleDropdownChange(value, index + 2)} // Handle selection + selected={filterValues[`securityQ${index+1}`]} // Set selected value + select={(value) => handleDropdownChange( `securityQ${index+1}`,value)} // Handle selection t={(key) => key} // Translation function (you can replace as needed) disabled={false} /> diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js index 8b657392351..8f93a114e0d 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js @@ -33,7 +33,7 @@ const PlanInbox = () => { const [hierarchyLevel, setHierarchyLevel] = useState(""); const [censusData, setCensusData] = useState([]); const [boundaries, setBoundaries] = useState([]); - const [selectedFilter, setSelectedFilter] = useState(null); + const [selectedFilter, setSelectedFilter] = useState({status:null,onRoadCondition:null,terrain:null,securityQ1:null,securityQ2:null}); const [activeFilter, setActiveFilter] = useState({}); const [actionBarPopUp, setactionBarPopUp] = useState(false); const [selectedRows, setSelectedRows] = useState([]); @@ -120,7 +120,7 @@ const PlanInbox = () => { }; useEffect(() => { - if (selectedFilter === "VALIDATED") { + if (selectedFilter.status === "VALIDATED") { setActiveLink({ code: "", name: "" }); setShowTab(false); } else { @@ -132,7 +132,7 @@ const PlanInbox = () => { setShowTab(true); } } - }, [selectedFilter]); + }, [selectedFilter.status]); const selectProps = { hideLabel: true, @@ -171,7 +171,11 @@ const PlanInbox = () => { tenantId: tenantId, active: true, jurisdiction: censusJurisdiction, - status: selectedFilter !== null && selectedFilter !== undefined ? selectedFilter : "", + status: selectedFilter.status !== null && selectedFilter.status !== undefined ? selectedFilter.status : "", + onRoadCondition:selectedFilter.onRoadCondition, + terrain:selectedFilter?.terrain, + securityQ1:selectedFilter?.securityQ1, + securityQ2:selectedFilter?.securityQ2, assignee: user.info.uuid, planConfigurationId: microplanId, limit: limitAndOffset?.limit, @@ -206,8 +210,10 @@ const PlanInbox = () => { tenantId: tenantId, active: true, jurisdiction: censusJurisdiction, - status: selectedFilter !== null && selectedFilter !== undefined ? selectedFilter : "", - ...(activeLink.code == "ASSIGNED_TO_ALL" || selectedFilter == "VALIDATED" ? {} : { assignee: user.info.uuid }), + status: selectedFilter.status !== null && selectedFilter.status !== undefined ? selectedFilter.status : "", + ...(activeLink.code == "ASSIGNED_TO_ALL" || selectedFilter.status == "VALIDATED" ? {} : { assignee: user.info.uuid }), + terrain:selectedFilter?.terrain, + onRoadCondition:selectedFilter?.onRoadCondition, planConfigurationId: microplanId, //list of plan ids limit: limitAndOffset?.limit, offset: limitAndOffset?.offset, @@ -366,7 +372,7 @@ const PlanInbox = () => { businessServices: "PLAN_ESTIMATION", }, config: { - enabled: selectedFilter ? true : false, + enabled: selectedFilter.status ? true : false, select: (data) => { return data.BusinessServices?.[0]; }, @@ -375,8 +381,8 @@ const PlanInbox = () => { useEffect(() => { if (workflowData) { - // Assume selectedFilter maps to applicationStatus or state - const selectedState = workflowData?.states?.find((state) => state.state === selectedFilter); + // Assume selectedFilter.filterValue maps to applicationStatus or state + const selectedState = workflowData?.states?.find((state) => state.state === selectedFilter.status); // Filter actions based on the selected state const availableActions = selectedState?.actions?.filter((action) => action.roles.some((role) => userRoles.includes(role))); @@ -384,7 +390,7 @@ const PlanInbox = () => { // Update the available actions state setAvailableActionsForUser(availableActions || []); } - }, [workflowData, selectedFilter]); + }, [workflowData, selectedFilter.status]); // if availableActionsForUser is defined and is an array const actionsMain = availableActionsForUser?.length > 0 ? availableActionsForUser : []; @@ -409,15 +415,20 @@ const PlanInbox = () => { ); setActiveFilter(reorderedStatusCount); const activeFilterKeys = Object.keys(reorderedStatusCount || {}); - if (selectedFilter === null || selectedFilter === undefined || selectedFilter === "" || !activeFilterKeys.includes(selectedFilter)) { - setSelectedFilter(activeFilterKeys[0]); + console.log("filter activeFIlter",activeFilterKeys); + if (selectedFilter.filterValue === null || selectedFilter.status=== undefined || selectedFilter.status === "" || !activeFilterKeys.includes(selectedFilter.status)) { + setSelectedFilter((prev) => ({ + ...prev, // Spread the previous state to retain other attributes + status: activeFilterKeys[0], // Update only the `status` key + })); + } setVillagesSelected(0); setSelectedRows([]); if (activeLink.code === "ASSIGNED_TO_ME") { setAssignedToMeCount(planWithCensus?.TotalCount); - setAssignedToAllCount(planWithCensus?.StatusCount[selectedFilter] || 0); + setAssignedToAllCount(planWithCensus?.StatusCount[selectedFilter.status] || 0); } else { setAssignedToAllCount(planWithCensus?.TotalCount); } @@ -425,13 +436,13 @@ const PlanInbox = () => { const uniqueAssignees = [...new Set(planWithCensus?.planData?.flatMap((item) => item.assignee || []))]; setAssigneeUuids(uniqueAssignees.join(",")); } - }, [planWithCensus, selectedFilter, activeLink]); + }, [planWithCensus, selectedFilter.status, activeLink]); useEffect(() => { if (censusJurisdiction?.length > 0) { refetchPlanWithCensus(); // Trigger the API call again after activeFilter changes } - }, [selectedFilter, activeLink, censusJurisdiction, limitAndOffset]); + }, [selectedFilter.status, activeLink, censusJurisdiction, limitAndOffset]); const reqCri = { url: `/${hrms_context_path}/employees/_search`, @@ -484,7 +495,7 @@ const PlanInbox = () => { }, [processData]); useEffect(() => { - if (selectedFilter === "VALIDATED") { + if (selectedFilter.status === "VALIDATED") { setActiveLink({ code: "", name: "" }); setShowTab(false); } else { @@ -496,10 +507,21 @@ const PlanInbox = () => { setShowTab(true); } } - }, [selectedFilter]); + }, [selectedFilter.status]); - const onFilter = (selectedStatus) => { - setSelectedFilter(selectedStatus?.code); + useEffect(()=>{ + console.log("filter filteredValues",selectedFilter) + },[selectedFilter]); + + const onFilter = (filterValue) => { + debugger; + print("filter1",filterValue); + setSelectedFilter((prev)=>( + { + ...prev, + ...filterValue + } + )); setCurrentPage(1); setLimitAndOffset((prev)=>{ return { @@ -514,9 +536,13 @@ const PlanInbox = () => { }; const clearFilters = () => { - if (selectedFilter !== Object.entries(activeFilter)?.[0]?.[0]) { - setSelectedFilter(Object.entries(activeFilter)?.[0]?.[0]); - } + debugger; + + setSelectedFilter((prev)=>( + { + status:Object.entries(activeFilter)?.[0]?.[0] + } + )); setCurrentPage(1); setLimitAndOffset((prev)=>{ return { @@ -787,13 +813,13 @@ const PlanInbox = () => { }; const getButtonState = (action) => { - if (selectedFilter === "PENDING_FOR_VALIDATION" && action === "VALIDATE") { + if (selectedFilter.status === "PENDING_FOR_VALIDATION" && action === "VALIDATE") { return true; } - if (selectedFilter === "PENDING_FOR_APPROVAL" && (action === "APPROVE" || action === "ROOT_APPROVE")) { + if (selectedFilter.status === "PENDING_FOR_APPROVAL" && (action === "APPROVE" || action === "ROOT_APPROVE")) { return true; } - if (selectedFilter === "VALIDATED" && action === "SEND_BACK_FOR_CORRECTION") { + if (selectedFilter.status === "VALIDATED" && action === "SEND_BACK_FOR_CORRECTION") { return true; } return false; @@ -839,7 +865,7 @@ const PlanInbox = () => {
{`${t("LOGGED_IN_AS")} ${userName} - ${t(userRole)}`}
- + { options={activeFilter} onApplyFilters={onFilter} clearFilters={clearFilters} - defaultValue={{ [selectedFilter]: activeFilter[selectedFilter] }} + defaultValue={{ [selectedFilter.status]: activeFilter[selectedFilter.status] }} >
@@ -993,7 +1019,7 @@ const PlanInbox = () => { ) : planWithCensus?.tableData?.length === 0 ? ( ) : ( From 70d22e7eb2a990dd30c10427bab0d54fdb4f98c9 Mon Sep 17 00:00:00 2001 From: Abishek Date: Mon, 30 Dec 2024 10:13:45 +0530 Subject: [PATCH 03/10] InboxFilter Changes --- .../src/components/InboxFilterWrapper.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js index 357741c991d..3bf51541b86 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js @@ -12,6 +12,7 @@ const InboxFilterWrapper = (props) => { const [filterValues, setFilterValues] = useState( {status:null,onRoadCondition:null, terrain:null, securityQ1:null,securityQ2:null} ); + const [onRoadCondition,setonRoadCOndition]=useState(null); // Default selected option @@ -54,7 +55,7 @@ const InboxFilterWrapper = (props) => { // Apply filters when the user presses the primary action button const handleApplyFilters = () => { if (props.onApplyFilters) { - debugger; + // debugger; console.log("filt",filterValues); props.onApplyFilters(filterValues); // Call the parent function with selected value } @@ -71,11 +72,18 @@ const InboxFilterWrapper = (props) => { const handleDropdownChange = (key, value) => { console.log("filter",value) + debugger setFilterValues((prev)=>({ ...prev, - [key]:value?.code + [key]:value?.name })); + + // if(key==="onRoadCondition"){ + // setonRoadCOndition(value?.code); + // } }; + console.log("filtervalue",filterValues); + console.log("state",state.villageRoadCondition); return ( { handleDropdownChange("onRoadCondition",value)} t={t} @@ -122,7 +130,7 @@ const InboxFilterWrapper = (props) => { handleDropdownChange("terrain",value)} t={t} From 34f5cdccfc05e72434c4b231dd2cab7861647adc Mon Sep 17 00:00:00 2001 From: Abishek Date: Mon, 30 Dec 2024 14:40:34 +0530 Subject: [PATCH 04/10] removing console.log --- .../microplan/src/components/InboxFilterWrapper.js | 6 ------ .../modules/microplan/src/pages/employee/PlanInbox.js | 11 +---------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js index 3bf51541b86..4236df7b037 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js @@ -55,8 +55,6 @@ const InboxFilterWrapper = (props) => { // Apply filters when the user presses the primary action button const handleApplyFilters = () => { if (props.onApplyFilters) { - // debugger; - console.log("filt",filterValues); props.onApplyFilters(filterValues); // Call the parent function with selected value } }; @@ -71,8 +69,6 @@ const InboxFilterWrapper = (props) => { }; const handleDropdownChange = (key, value) => { - console.log("filter",value) - debugger setFilterValues((prev)=>({ ...prev, [key]:value?.name @@ -82,8 +78,6 @@ const InboxFilterWrapper = (props) => { // setonRoadCOndition(value?.code); // } }; - console.log("filtervalue",filterValues); - console.log("state",state.villageRoadCondition); return ( { ); setActiveFilter(reorderedStatusCount); const activeFilterKeys = Object.keys(reorderedStatusCount || {}); - console.log("filter activeFIlter",activeFilterKeys); if (selectedFilter.filterValue === null || selectedFilter.status=== undefined || selectedFilter.status === "" || !activeFilterKeys.includes(selectedFilter.status)) { setSelectedFilter((prev) => ({ ...prev, // Spread the previous state to retain other attributes @@ -509,13 +508,7 @@ const PlanInbox = () => { } }, [selectedFilter.status]); - useEffect(()=>{ - console.log("filter filteredValues",selectedFilter) - },[selectedFilter]); - const onFilter = (filterValue) => { - debugger; - print("filter1",filterValue); setSelectedFilter((prev)=>( { ...prev, @@ -535,9 +528,7 @@ const PlanInbox = () => { }); }; - const clearFilters = () => { - debugger; - + const clearFilters = () => { setSelectedFilter((prev)=>( { status:Object.entries(activeFilter)?.[0]?.[0] From a27755be604285db6100b114078c23b9f1649ddb Mon Sep 17 00:00:00 2001 From: Abishek Date: Mon, 30 Dec 2024 15:12:22 +0530 Subject: [PATCH 05/10] Css package update --- .../micro-ui/web/micro-ui-internals/example/public/index.html | 2 +- .../micro-ui/web/micro-ui-internals/packages/css/package.json | 2 +- .../modules/microplan/src/components/InboxFilterWrapper.js | 4 ---- health/micro-ui/web/public/index.html | 2 +- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/health/micro-ui/web/micro-ui-internals/example/public/index.html b/health/micro-ui/web/micro-ui-internals/example/public/index.html index 744f20ea3e3..7b00f6e0469 100644 --- a/health/micro-ui/web/micro-ui-internals/example/public/index.html +++ b/health/micro-ui/web/micro-ui-internals/example/public/index.html @@ -12,7 +12,7 @@ DIGIT - + diff --git a/health/micro-ui/web/micro-ui-internals/packages/css/package.json b/health/micro-ui/web/micro-ui-internals/packages/css/package.json index 951a4bd11b4..845e76cb110 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/css/package.json +++ b/health/micro-ui/web/micro-ui-internals/packages/css/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-health-css", - "version": "0.2.32", + "version": "0.2.33", "license": "MIT", "main": "dist/index.css", "author": "Jagankumar ", diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js index 4236df7b037..b6ba59d05e3 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js @@ -73,10 +73,6 @@ const InboxFilterWrapper = (props) => { ...prev, [key]:value?.name })); - - // if(key==="onRoadCondition"){ - // setonRoadCOndition(value?.code); - // } }; return ( diff --git a/health/micro-ui/web/public/index.html b/health/micro-ui/web/public/index.html index ffce7b97682..58a2485aef8 100644 --- a/health/micro-ui/web/public/index.html +++ b/health/micro-ui/web/public/index.html @@ -10,7 +10,7 @@ - + DIGIT HCM From afb8820ccfbde1f2c18138b89182836ec6057e0c Mon Sep 17 00:00:00 2001 From: Abishek Date: Tue, 31 Dec 2024 12:18:14 +0530 Subject: [PATCH 06/10] changes --- .../src/components/InboxFilterWrapper.js | 87 +++++++++++-------- 1 file changed, 50 insertions(+), 37 deletions(-) diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js index b6ba59d05e3..42006f6c36f 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js @@ -1,18 +1,19 @@ -import React, { useState, useEffect } from "react"; +import React, { useState, Fragment, useEffect } from "react"; import { useTranslation } from "react-i18next"; import { FilterCard, Dropdown, LabelFieldPair, RadioButtons, TextBlock } from "@egovernments/digit-ui-components"; import { useMyContext } from "../utils/context"; + const InboxFilterWrapper = (props) => { const { state } = useMyContext(); const { t } = useTranslation(); const [dropdown1Value, setDropdown1Value] = useState(null); const [dropdown2Value, setDropdown2Value] = useState(null); const [filterValues, setFilterValues] = useState( - {status:null,onRoadCondition:null, terrain:null, securityQ1:null,securityQ2:null} + { status: null, onRoadCondition: null, terrain: null, securityQ1: null, securityQ2: null } ); - const [onRoadCondition,setonRoadCOndition]=useState(null); + const [onRoadCondition, setonRoadCOndition] = useState(null); // Default selected option @@ -55,27 +56,39 @@ const InboxFilterWrapper = (props) => { // Apply filters when the user presses the primary action button const handleApplyFilters = () => { if (props.onApplyFilters) { - props.onApplyFilters(filterValues); // Call the parent function with selected value + const filtersToApply= {}; + + for (let key in filterValues) { + if (filterValues[key] && typeof filterValues[key] === 'object' && filterValues[key].hasOwnProperty('name')) { + filtersToApply[key] = filterValues[key].name; // Extract 'name' if it exists + } else { + filtersToApply[key] = filterValues[key]; // Keep the value as is (including null) + } + } + + props.onApplyFilters(filtersToApply); // Pass the new array to onApplyFilters } }; // Clear filters when the user presses the secondary action button const clearFilters = () => { // setSelectedValue(selectedValue); // Clear the selection - setFilterValues({status:null,onRoadCondition:null,terrain:null,securityQ1:null,securityQ2:null}); + setFilterValues({ status: null, onRoadCondition: null, terrain: null, securityQ1: null, securityQ2: null }); if (props.clearFilters) { props.clearFilters(); } }; const handleDropdownChange = (key, value) => { - setFilterValues((prev)=>({ + setFilterValues((prev) => ({ ...prev, - [key]:value?.name + [key]: value })); }; + return ( + { flexDirection: "column", gap: "1rem", // Adds space between options }} - onSelect={(value)=>handleDropdownChange("status",value)} // Function to handle selection + onSelect={(value) => handleDropdownChange("status", value)} // Function to handle selection /> )} @@ -108,9 +121,9 @@ const InboxFilterWrapper = (props) => { handleDropdownChange("onRoadCondition",value)} + select={(value) => handleDropdownChange("onRoadCondition", value)} t={t} disabled={false} /> @@ -120,38 +133,38 @@ const InboxFilterWrapper = (props) => { handleDropdownChange("terrain",value)} + select={(value) => handleDropdownChange("terrain", value)} t={t} disabled={false} /> - - {state.securityQuestions.map((item, index) => { - // Transform item.values into an array of objects - const options = item.values.map((value) => ({ - code: value, - name: value, - active: true, - })); - - return ( - - - handleDropdownChange( `securityQ${index+1}`,value)} // Handle selection - t={(key) => key} // Translation function (you can replace as needed) - disabled={false} - /> - - ); - })} - + + {state.securityQuestions.map((item, index) => { + // Transform item.values into an array of objects + const options = item.values.map((value) => ({ + code: value, + name: value, + active: true, + })); + + return ( + + + handleDropdownChange(`securityQ${index + 1}`, value)} // Handle selection + t={(key) => key} // Translation function (you can replace as needed) + disabled={false} + /> + + ); + })} +
); @@ -164,4 +177,4 @@ InboxFilterWrapper.defaultProps = { optionsKey: "name", }; -export default InboxFilterWrapper; +export default InboxFilterWrapper; \ No newline at end of file From 25e7cf90e101989ec6af5e68d3ef9cc2b38b5f2b Mon Sep 17 00:00:00 2001 From: Abishek Date: Tue, 31 Dec 2024 12:24:06 +0530 Subject: [PATCH 07/10] changes --- .../microplan/src/pages/employee/PlanInbox.js | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js index 13ad7dc8c24..71dd0de023d 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js @@ -120,7 +120,7 @@ const PlanInbox = () => { }; useEffect(() => { - if (selectedFilter.status === "VALIDATED") { + if (selectedFilter?.status === "VALIDATED") { setActiveLink({ code: "", name: "" }); setShowTab(false); } else { @@ -132,7 +132,7 @@ const PlanInbox = () => { setShowTab(true); } } - }, [selectedFilter.status]); + }, [selectedFilter?.status]); const selectProps = { hideLabel: true, @@ -171,7 +171,7 @@ const PlanInbox = () => { tenantId: tenantId, active: true, jurisdiction: censusJurisdiction, - status: selectedFilter.status !== null && selectedFilter.status !== undefined ? selectedFilter.status : "", + status: selectedFilter?.status !== null && selectedFilter?.status !== undefined ? selectedFilter?.status : "", onRoadCondition:selectedFilter.onRoadCondition, terrain:selectedFilter?.terrain, securityQ1:selectedFilter?.securityQ1, @@ -210,8 +210,8 @@ const PlanInbox = () => { tenantId: tenantId, active: true, jurisdiction: censusJurisdiction, - status: selectedFilter.status !== null && selectedFilter.status !== undefined ? selectedFilter.status : "", - ...(activeLink.code == "ASSIGNED_TO_ALL" || selectedFilter.status == "VALIDATED" ? {} : { assignee: user.info.uuid }), + status: selectedFilter?.status !== null && selectedFilter?.status !== undefined ? selectedFilter?.status : "", + ...(activeLink.code == "ASSIGNED_TO_ALL" || selectedFilter?.status == "VALIDATED" ? {} : { assignee: user.info.uuid }), terrain:selectedFilter?.terrain, onRoadCondition:selectedFilter?.onRoadCondition, planConfigurationId: microplanId, //list of plan ids @@ -372,7 +372,7 @@ const PlanInbox = () => { businessServices: "PLAN_ESTIMATION", }, config: { - enabled: selectedFilter.status ? true : false, + enabled: selectedFilter?.status ? true : false, select: (data) => { return data.BusinessServices?.[0]; }, @@ -382,7 +382,7 @@ const PlanInbox = () => { useEffect(() => { if (workflowData) { // Assume selectedFilter.filterValue maps to applicationStatus or state - const selectedState = workflowData?.states?.find((state) => state.state === selectedFilter.status); + const selectedState = workflowData?.states?.find((state) => state.state === selectedFilter?.status); // Filter actions based on the selected state const availableActions = selectedState?.actions?.filter((action) => action.roles.some((role) => userRoles.includes(role))); @@ -390,7 +390,7 @@ const PlanInbox = () => { // Update the available actions state setAvailableActionsForUser(availableActions || []); } - }, [workflowData, selectedFilter.status]); + }, [workflowData, selectedFilter?.status]); // if availableActionsForUser is defined and is an array const actionsMain = availableActionsForUser?.length > 0 ? availableActionsForUser : []; @@ -415,7 +415,7 @@ const PlanInbox = () => { ); setActiveFilter(reorderedStatusCount); const activeFilterKeys = Object.keys(reorderedStatusCount || {}); - if (selectedFilter.filterValue === null || selectedFilter.status=== undefined || selectedFilter.status === "" || !activeFilterKeys.includes(selectedFilter.status)) { + if (selectedFilter?.filterValue === null || selectedFilter?.status=== undefined || selectedFilter?.status === "" || !activeFilterKeys.includes(selectedFilter?.status)) { setSelectedFilter((prev) => ({ ...prev, // Spread the previous state to retain other attributes status: activeFilterKeys[0], // Update only the `status` key @@ -427,7 +427,7 @@ const PlanInbox = () => { setSelectedRows([]); if (activeLink.code === "ASSIGNED_TO_ME") { setAssignedToMeCount(planWithCensus?.TotalCount); - setAssignedToAllCount(planWithCensus?.StatusCount[selectedFilter.status] || 0); + setAssignedToAllCount(planWithCensus?.StatusCount[selectedFilter?.status] || 0); } else { setAssignedToAllCount(planWithCensus?.TotalCount); } @@ -435,13 +435,13 @@ const PlanInbox = () => { const uniqueAssignees = [...new Set(planWithCensus?.planData?.flatMap((item) => item.assignee || []))]; setAssigneeUuids(uniqueAssignees.join(",")); } - }, [planWithCensus, selectedFilter.status, activeLink]); + }, [planWithCensus, selectedFilter?.status, activeLink]); useEffect(() => { if (censusJurisdiction?.length > 0) { refetchPlanWithCensus(); // Trigger the API call again after activeFilter changes } - }, [selectedFilter.status, activeLink, censusJurisdiction, limitAndOffset]); + }, [selectedFilter?.status, activeLink, censusJurisdiction, limitAndOffset]); const reqCri = { url: `/${hrms_context_path}/employees/_search`, @@ -494,7 +494,7 @@ const PlanInbox = () => { }, [processData]); useEffect(() => { - if (selectedFilter.status === "VALIDATED") { + if (selectedFilter?.status === "VALIDATED") { setActiveLink({ code: "", name: "" }); setShowTab(false); } else { @@ -506,7 +506,7 @@ const PlanInbox = () => { setShowTab(true); } } - }, [selectedFilter.status]); + }, [selectedFilter?.status]); const onFilter = (filterValue) => { setSelectedFilter((prev)=>( @@ -804,13 +804,13 @@ const PlanInbox = () => { }; const getButtonState = (action) => { - if (selectedFilter.status === "PENDING_FOR_VALIDATION" && action === "VALIDATE") { + if (selectedFilter?.status === "PENDING_FOR_VALIDATION" && action === "VALIDATE") { return true; } - if (selectedFilter.status === "PENDING_FOR_APPROVAL" && (action === "APPROVE" || action === "ROOT_APPROVE")) { + if (selectedFilter?.status === "PENDING_FOR_APPROVAL" && (action === "APPROVE" || action === "ROOT_APPROVE")) { return true; } - if (selectedFilter.status === "VALIDATED" && action === "SEND_BACK_FOR_CORRECTION") { + if (selectedFilter?.status === "VALIDATED" && action === "SEND_BACK_FOR_CORRECTION") { return true; } return false; @@ -856,7 +856,7 @@ const PlanInbox = () => {
{`${t("LOGGED_IN_AS")} ${userName} - ${t(userRole)}`}
- + { options={activeFilter} onApplyFilters={onFilter} clearFilters={clearFilters} - defaultValue={{ [selectedFilter.status]: activeFilter[selectedFilter.status] }} + defaultValue={{ [selectedFilter?.status]: activeFilter[selectedFilter?.status] }} >
@@ -1010,7 +1010,7 @@ const PlanInbox = () => { ) : planWithCensus?.tableData?.length === 0 ? ( ) : ( From df7873baafa256109aa442981f76367bb8ef044d Mon Sep 17 00:00:00 2001 From: Abishek Date: Tue, 31 Dec 2024 12:25:48 +0530 Subject: [PATCH 08/10] changes --- .../modules/microplan/src/components/InboxFilterWrapper.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js index 42006f6c36f..8ee39aa9037 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js @@ -1,4 +1,4 @@ -import React, { useState, Fragment, useEffect } from "react"; +import React, { useState, useEffect } from "react"; import { useTranslation } from "react-i18next"; import { FilterCard, Dropdown, LabelFieldPair, RadioButtons, TextBlock } from "@egovernments/digit-ui-components"; import { useMyContext } from "../utils/context"; @@ -8,12 +8,9 @@ import { useMyContext } from "../utils/context"; const InboxFilterWrapper = (props) => { const { state } = useMyContext(); const { t } = useTranslation(); - const [dropdown1Value, setDropdown1Value] = useState(null); - const [dropdown2Value, setDropdown2Value] = useState(null); const [filterValues, setFilterValues] = useState( { status: null, onRoadCondition: null, terrain: null, securityQ1: null, securityQ2: null } ); - const [onRoadCondition, setonRoadCOndition] = useState(null); // Default selected option From ca2b8ccccb1d39377e1325ec4d55f068ddd7d2ef Mon Sep 17 00:00:00 2001 From: Abishek Date: Tue, 31 Dec 2024 13:23:43 +0530 Subject: [PATCH 09/10] changes --- .../packages/modules/microplan/src/pages/employee/PlanInbox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js index 71dd0de023d..67fa5fec1bb 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js @@ -415,7 +415,7 @@ const PlanInbox = () => { ); setActiveFilter(reorderedStatusCount); const activeFilterKeys = Object.keys(reorderedStatusCount || {}); - if (selectedFilter?.filterValue === null || selectedFilter?.status=== undefined || selectedFilter?.status === "" || !activeFilterKeys.includes(selectedFilter?.status)) { + if (selectedFilter?.filterValue === null || selectedFilter?.status=== undefined || selectedFilter?.status === "") { setSelectedFilter((prev) => ({ ...prev, // Spread the previous state to retain other attributes status: activeFilterKeys[0], // Update only the `status` key From f04ebfb503d0de072da09c50941d6a8b33f6c97a Mon Sep 17 00:00:00 2001 From: Abishek Date: Tue, 31 Dec 2024 13:29:27 +0530 Subject: [PATCH 10/10] changes --- .../modules/microplan/src/components/InboxFilterWrapper.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js index 8ee39aa9037..50dcdde1174 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js @@ -56,8 +56,8 @@ const InboxFilterWrapper = (props) => { const filtersToApply= {}; for (let key in filterValues) { - if (filterValues[key] && typeof filterValues[key] === 'object' && filterValues[key].hasOwnProperty('name')) { - filtersToApply[key] = filterValues[key].name; // Extract 'name' if it exists + if (filterValues[key] && typeof filterValues[key] === 'object' && filterValues[key].hasOwnProperty('code')) { + filtersToApply[key] = filterValues[key].code; // Extract 'name' if it exists } else { filtersToApply[key] = filterValues[key]; // Keep the value as is (including null) } @@ -102,7 +102,7 @@ const InboxFilterWrapper = (props) => {