Skip to content

Commit

Permalink
Facility Pagination Fix (#1908)
Browse files Browse the repository at this point in the history
Co-authored-by: rachana-egov <[email protected]>
  • Loading branch information
rachana-egov and rachana-egov authored Nov 27, 2024
1 parent 6fe9381 commit 98aa7ba
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const FacilityPopUp = ({ details, onClose, updateDetails }) => {

useEffect(async () => {
setLoader(true);
setTableLoader(true);
await censusSearch([]);
setLoader(false);
}, [currentPage, rowsPerPage])
Expand Down Expand Up @@ -143,6 +144,7 @@ const FacilityPopUp = ({ details, onClose, updateDetails }) => {
else {
jurisdictionArray = planEmployeeDetailsData?.PlanEmployeeAssignment?.[0]?.jurisdiction?.map((item) => { return { code: item } });
}
setTableLoader(true);
censusSearch(jurisdictionArray);
}, [microplanId, facilityAssignedStatus, details, planEmployeeDetailsData, currentPage, rowsPerPage]);

Expand Down Expand Up @@ -185,7 +187,7 @@ const FacilityPopUp = ({ details, onClose, updateDetails }) => {

const censusSearch = async (data) => {
setBoundaryData(data);
setTableLoader(true);

const codeArray = data?.length === 0
? planEmployeeDetailsData?.PlanEmployeeAssignment?.[0]?.jurisdiction?.map((item) => item) || []
: data?.map((item) => item?.code);
Expand Down Expand Up @@ -392,7 +394,7 @@ const FacilityPopUp = ({ details, onClose, updateDetails }) => {
}
);
await new Promise((resolve) => setTimeout(resolve, 1000));
// setCurrentPage(1);
setCurrentPage(1);
setLoader(false);
};

Expand Down Expand Up @@ -432,9 +434,9 @@ const FacilityPopUp = ({ details, onClose, updateDetails }) => {
if (selectedBoundaries.length === 0) {
setShowToast({ key: "warning", label: t("MICROPLAN_BOUNDARY_IS_EMPTY_WARNING"), transitionTime: 5000 });
} else {

setDefaultSelectedHierarchy(selectedHierarchy);
setDefaultBoundaries(selectedBoundaries);
setCurrentPage(1);
censusSearch(selectedBoundaries);
}

Expand All @@ -443,6 +445,8 @@ const FacilityPopUp = ({ details, onClose, updateDetails }) => {
const onClear = () => {
setDefaultBoundaries([]);
setDefaultSelectedHierarchy(null);
setCurrentPage(1);
setTableLoader(true);
censusSearch([]);
};

Expand All @@ -452,8 +456,8 @@ const FacilityPopUp = ({ details, onClose, updateDetails }) => {
{ key: "facilityName", value: details?.additionalDetails?.facilityName || t("NA") },
{ key: "facilityType", value: details?.additionalDetails?.facilityType || t("NA") },
{ key: "facilityStatus", value: details?.additionalDetails?.facilityStatus || t("NA") },
{ key: "capacity", value: details?.additionalDetails?.capacity || t("NA") },
{ key: "servingPopulation", value: latestKpiData?.PlanFacility[0]?.additionalDetails?.servingPopulation || t("NA")},
{ key: "capacity", value: details?.additionalDetails?.capacity || "0" },
{ key: "servingPopulation", value: latestKpiData?.PlanFacility[0]?.additionalDetails?.servingPopulation || "0"},
{ key: "fixedPost", value: details?.additionalDetails?.fixedPost || t("NA") },
{ key: "residingVillage", value: t(details?.residingBoundary) || t("NA") }
]);
Expand Down Expand Up @@ -569,6 +573,7 @@ const FacilityPopUp = ({ details, onClose, updateDetails }) => {
{viewDetails && accessibilityData && <AccessibilityPopUp onClose={() => closeViewDetails()} census={accessibilityData}
onSuccess={(data) => {
setShowToast({ key: "success", label: t("ACCESSIBILITY_DETAILS_UPDATE_SUCCESS"), transitionTime: 5000 });
setTableLoader(true);
censusSearch(boundaryData);
closeViewDetails();
}}
Expand All @@ -577,6 +582,7 @@ const FacilityPopUp = ({ details, onClose, updateDetails }) => {
{viewDetails && securityData && <SecurityPopUp onClose={() => closeViewDetails()} census={securityData}
onSuccess={(data) => {
setShowToast({ key: "success", label: t("SECURITY_DETAILS_UPDATE_SUCCESS"), transitionTime: 5000 });
setTableLoader(true);
censusSearch(boundaryData);
closeViewDetails();
}}
Expand Down

0 comments on commit 98aa7ba

Please sign in to comment.