Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facility pop up fix #1872

Merged
merged 5 commits into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,21 @@ const FacilityPopUp = ({ details, onClose, updateDetails }) => {
},
};

const planFacilitySearchMutaionConfig = {
rachana-egov marked this conversation as resolved.
Show resolved Hide resolved
url: "/plan-service/plan/facility/_search",
body: {
PlanFacilitySearchCriteria: {
tenantId: tenantId,
planConfigurationId: url?.microplanId,
ids: [details?.id]
}
},
};

const mutationForPlanFacilityUpdate = Digit.Hooks.useCustomAPIMutationHook(planFacilityUpdateMutaionConfig);

const mutationForPlanFacilitySearch = Digit.Hooks.useCustomAPIMutationHook(planFacilitySearchMutaionConfig);
rachana-egov marked this conversation as resolved.
Show resolved Hide resolved

const handleAssignUnassign = async () => {
// Fetching the full data of selected rows
setLoader(true);
Expand Down Expand Up @@ -306,14 +319,26 @@ const FacilityPopUp = ({ details, onClose, updateDetails }) => {
{
onSuccess: async (result) => {
setSelectedRows([]);
updateDetails(newDetails);
if (facilityAssignedStatus) {
setShowToast({ key: "success", label: `${t("UNASSIGNED_SUCESS")} ${details?.additionalDetails?.facilityName}`, transitionTime: 5000 });


setShowToast({ key: "success", label: `${t("UNASSIGNED_SUCESS")} ${details?.additionalDetails?.facilityName}`, transitionTime: 5000 })
} else {
setShowToast({ key: "success", label: `${t("ASSIGNED_SUCESS")} ${details?.additionalDetails?.facilityName}`, transitionTime: 5000 });
rachana-egov marked this conversation as resolved.
Show resolved Hide resolved
}
// search call for same plan facility
// Add a delay of 1 second before making the second mutation call to make sure data is persisted
await new Promise((resolve) => setTimeout(resolve, 1000));
rachana-egov marked this conversation as resolved.
Show resolved Hide resolved
await mutationForPlanFacilitySearch.mutate(
{},
{
onSuccess: async (result) => {
updateDetails(result?.PlanFacility?.[0]);
},
onError: async (result) => {
setShowToast({ key: "error", label: t("ERROR_WHILE_SEARCHING_PLANFACILITY"), transitionTime: 5000 });
},
}
);
//updateDetails(newDetails);
},
onError: async (result) => {
// setDownloadError(true);
Expand Down Expand Up @@ -483,12 +508,14 @@ 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 });
censusSearch(boundaryData);
rachana-egov marked this conversation as resolved.
Show resolved Hide resolved
closeViewDetails();
}}
/>}
{viewDetails && securityData && <SecurityPopUp onClose={() => closeViewDetails()} census={securityData}
onSuccess={(data) => {
setShowToast({ key: "success", label: t("SECURITY_DETAILS_UPDATE_SUCCESS"), transitionTime: 5000 });
censusSearch(boundaryData);
rachana-egov marked this conversation as resolved.
Show resolved Hide resolved
closeViewDetails();
}}
/>}
Expand Down