Skip to content

Commit

Permalink
Reverted action in assign to all, updated the column heading with pro… (
Browse files Browse the repository at this point in the history
#1790)

* reverted action in assign to all, updated the column heading with projecttype

* removed logs

---------

Co-authored-by: rachana-egov <[email protected]>
  • Loading branch information
rachana-egov and rachana-egov authored Nov 11, 2024
1 parent c501b6d commit c18e61a
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from "lodash";
import { useLocation, useHistory, Link, useParams } from "react-router-dom";
import React, { useState, Fragment } from "react";
import { DeleteIconv2, DownloadIcon, FileIcon, Button, Card, CardSubHeader, EditIcon, ArrowForward } from "@egovernments/digit-ui-react-components";
import { Button as ButtonNew , Dropdown} from "@egovernments/digit-ui-components";
import { Button as ButtonNew, Dropdown } from "@egovernments/digit-ui-components";

//create functions here based on module name set in mdms(eg->SearchProjectConfig)
//how to call these -> Digit?.Customizations?.[masterName]?.[moduleName]
Expand Down Expand Up @@ -303,9 +303,8 @@ export const UICustomizations = {
return (
<span className="link">
<Link
to={`/${
window.contextPath
}/employee/attendencemgmt/view-attendance?tenantId=${Digit.ULBService.getCurrentTenantId()}&musterRollNumber=${value}`}
to={`/${window.contextPath
}/employee/attendencemgmt/view-attendance?tenantId=${Digit.ULBService.getCurrentTenantId()}&musterRollNumber=${value}`}
>
{String(value ? (column.translate ? t(column.prefix ? `${column.prefix}${value}` : value) : value) : t("ES_COMMON_NA"))}
</Link>
Expand Down Expand Up @@ -1222,7 +1221,7 @@ export const UICustomizations = {

switch (key) {
case "MICROPLAN_FACILITY_ASSIGNED_VILLAGES":
const assignedVillages = row?.additionalDetails?.assignedVillages;
const assignedVillages = row?.serviceBoundaries;
return assignedVillages ? assignedVillages.length : null;
case "MICROPLAN_FACILITY_ACTION":
return (
Expand All @@ -1234,7 +1233,7 @@ export const UICustomizations = {
isSuffix
label={t("MICROPLAN_ASSIGN")}
// onClick={() => setShowPopup(true)}// removed this because due to popup crashing on dev
onClick={() => console.log("temp action")}
onClick={() => console.log("temp action")}
options={[]}
optionsKey=""
size="medium"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const PopInboxTable = ({ ...props }) => {
<DataTable
columns={columns}
data={props.censusData}
selectableRows={props.allowAction}
selectableRows
selectableRowsHighlight
noContextMenu
onSelectedRowsChange={handleRowSelect}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useMyContext } from "../utils/context";

const facilityMappingConfig = () => {
const facilityMappingConfig = (projectType) => {

const { state, dispatch } = useMyContext();
return {
label: "",
Expand Down Expand Up @@ -63,7 +64,7 @@ const facilityMappingConfig = () => {
optionsCustomStyle: {
top: "2.3rem",
},
options:state?.facilityType || []
options: state?.facilityType || []
},
},
{
Expand All @@ -77,7 +78,7 @@ const facilityMappingConfig = () => {
},
name: "status",
optionsKey: "name",
options:state?.facilityStatus || []
options: state?.facilityStatus || []
},
},
{
Expand Down Expand Up @@ -120,7 +121,7 @@ const facilityMappingConfig = () => {
jsonPath: "additionalDetails.facilityStatus",
},
{
label: "MICROPLAN_FACILITY_CAPACITY",
label: `MICROPLAN_FACILITY_${projectType}_CAPACITY`,
jsonPath: "additionalDetails.capacity",
},
{
Expand Down Expand Up @@ -160,7 +161,7 @@ const facilityMappingConfig = () => {
show: true,
},
},
customHookName:"microplanv1.useFcilityCatchmentMapping",
customHookName: "microplanv1.useFcilityCatchmentMapping",
additionalSections: {},
};
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Link, useLocation, useHistory, useParams } from "react-router-dom";
import _ from "lodash";
import React, { useState, Fragment } from "react";
import { Button as ButtonNew , Dropdown} from "@egovernments/digit-ui-components";
import { Button as ButtonNew, Dropdown } from "@egovernments/digit-ui-components";
import { DeleteIconv2, DownloadIcon, FileIcon, Button, Card, CardSubHeader, EditIcon, ArrowForward } from "@egovernments/digit-ui-react-components";

//create functions here based on module name set in mdms(eg->SearchProjectConfig)
Expand Down Expand Up @@ -504,7 +504,7 @@ export const UICustomizations = {
const FacilityPopUp = Digit.ComponentRegistryService.getComponent("FacilityPopup");
switch (key) {
case "MICROPLAN_FACILITY_ASSIGNED_VILLAGES":
const assignedVillages = row?.additionalDetails?.assignedVillages;
const assignedVillages = row?.serviceBoundaries;
return assignedVillages ? assignedVillages.length : null;
case "MICROPLAN_FACILITY_ACTION":
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ const FacilityCatchmentMapping = () => {
const [actionBarPopUp, setactionBarPopUp] = useState(false);
const { t } = useTranslation();
const history = useHistory();
const config = facilityMappingConfig();
const url = Digit.Hooks.useQueryParams();
const tenantId = Digit.ULBService.getCurrentTenantId();
const user = Digit.UserService.getUser();
const userRoles = user?.info?.roles?.map((roleData) => roleData?.code);
const [showPopup, setShowPopup] = useState(false);
const FacilityPopUp = Digit.ComponentRegistryService.getComponent("FacilityPopup");
const [currentRow, setCurrentRow] = useState(null);
const [projectType, setProjectType] = useState('');
const [censusQueryName, setCensusQueryName] = useState("censusData");
// Check if the user has the 'rootfacilitycatchmentmapper' role
const isRootApprover = userRoles?.includes("ROOT_FACILITY_CATCHMENT_MAPPER");
Expand All @@ -43,6 +43,23 @@ const FacilityCatchmentMapping = () => {
});


const {
isLoading: isLoadingCampaignObject,
data: campaignObject,
error: errorCampaign,
refetch: refetchCampaign,
} = Digit.Hooks.microplanv1.useSearchCampaign(
{
CampaignDetails: {
tenantId,
ids: [url?.campaignId],
},
},
{
enabled: url?.campaignId ? true : false,
}
);

// Custom hook to fetch census data based on microplanId
const reqCriteriaResource = {
url: `/census-service/_search`,
Expand Down Expand Up @@ -96,12 +113,21 @@ const FacilityCatchmentMapping = () => {
return updatedPlanConfig;
};

// Effect to update projectType based on campaign data
useEffect(() => {
if (campaignObject?.projectType) {
setProjectType(campaignObject?.projectType);
}
}, [campaignObject]);

const onClickRow = (row) => {
setShowPopup(true)
setCurrentRow(row.original)
}

if (isPlanEmpSearchLoading || isLoading || isLoadingPlanObject)
const config = facilityMappingConfig(projectType);

if (isPlanEmpSearchLoading || isLoading || isLoadingPlanObject || isLoadingCampaignObject)
return <Loader />

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const PlanInbox = () => {
const [rowsPerPage, setRowsPerPage] = useState(50);
const [totalRows, setTotalRows] = useState(0);
const [perPage, setPerPage] = useState(10);
const [allowAction, setAllowAction] = useState(true);
const [showToast, setShowToast] = useState(null);
const [availableActionsForUser, setAvailableActionsForUser] = useState([]);
const [limitAndOffset, setLimitAndOffset] = useState({ limit: rowsPerPage, offset: (currentPage - 1) * rowsPerPage });
Expand All @@ -62,8 +61,6 @@ const PlanInbox = () => {
}
);

console.log(censusJurisdiction, "JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJj");

useEffect(() => {
if (selectedFilter === "VALIDATED") {
setActiveLink({ code: "", name: "" });
Expand Down Expand Up @@ -320,15 +317,6 @@ const PlanInbox = () => {
}
}, [selectedFilter]);


useEffect(() => {
if (selectedFilter !== "VALIDATED" && activeLink.code === "ASSIGNED_TO_ALL") {
setAllowAction(false);
} else {
setAllowAction(true);
}
}, [selectedFilter, activeLink]);

const onFilter = (selectedStatus) => {
setSelectedFilter(selectedStatus?.code);
};
Expand Down Expand Up @@ -615,7 +603,7 @@ const PlanInbox = () => {
data={planWithCensus?.tableData}
pagination
paginationServer
selectableRows={allowAction}
selectableRows
selectableRowsHighlight
onChangeRowsPerPage={handlePerRowsChange}
onChangePage={handlePageChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const PopInbox = () => {
const [totalRows, setTotalRows] = useState(0);
const [showToast, setShowToast] = useState(null);
const [showComment, setShowComment] = useState(false);
const [allowAction, setAllowAction] = useState(true);
const [employeeNameMap, setEmployeeNameMap] = useState({});
const [availableActionsForUser, setAvailableActionsForUser] = useState([]);
const [assignedToMeCount, setAssignedToMeCount] = useState(0);
Expand Down Expand Up @@ -321,15 +320,6 @@ const PopInbox = () => {
}
}, [selectedFilter]);


useEffect(() => {
if (selectedFilter !== "VALIDATED" && activeLink.code === "ASSIGNED_TO_ALL") {
setAllowAction(false);
} else {
setAllowAction(true);
}
}, [selectedFilter, activeLink]);

const onFilter = (selectedStatus) => {
setSelectedFilter(selectedStatus?.code);
setActiveLink({
Expand Down Expand Up @@ -550,7 +540,7 @@ const PopInbox = () => {
setUpdatedCensus(data);
setShowComment(true);
}}
conditionalRowStyles={conditionalRowStyles} allowAction={allowAction} />}
conditionalRowStyles={conditionalRowStyles} />}
</Card>
{showComment && (
<WorkflowCommentPopUp
Expand Down

0 comments on commit c18e61a

Please sign in to comment.