diff --git a/src/pages/GFMIS/index.js b/src/pages/GFMIS/index.js
index 3bca046..2dc8b02 100644
--- a/src/pages/GFMIS/index.js
+++ b/src/pages/GFMIS/index.js
@@ -4,6 +4,7 @@ import {
Typography,
Stack,
Button,
+ CircularProgress,
Dialog, DialogTitle, DialogContent, DialogActions,
} from '@mui/material';
import MainCard from "components/MainCard";
@@ -55,6 +56,8 @@ const Index = () => {
const [isPreviewLoading, setIsPreviewLoading] = React.useState(false);
const [isPopUp, setIsPopUp] = React.useState(false);
+ const [isXmlDialogSubmitting, setIsXmlDialogSubmitting] = React.useState(false);
+ const xmlDownloadInFlightRef = React.useRef(false);
const [downloadInput, setDownloadInput] = React.useState();
const [selectedIds, setSelectedIds] = React.useState([]);
@@ -66,6 +69,13 @@ const Index = () => {
setInputDateValue(inputDate);
}, [inputDate]);
+ React.useEffect(() => {
+ if (!isPopUp) {
+ xmlDownloadInFlightRef.current = false;
+ setIsXmlDialogSubmitting(false);
+ }
+ }, [isPopUp]);
+
React.useEffect(() => {
setOnReady(true);
}, [searchCriteria]);
@@ -94,66 +104,61 @@ const Index = () => {
function downloadXML() {
- console.log(selectedIds.join(','))
- setIsPopUp(false)
+ if (xmlDownloadInFlightRef.current) return;
+ xmlDownloadInFlightRef.current = true;
+ console.log(selectedIds.join(','));
+ setIsXmlDialogSubmitting(true);
let sentDateFrom = "";
-
+
if (inputDateValue != "dd / mm / yyyy") {
- sentDateFrom = DateUtils.dateValue(inputDateValue)
+ sentDateFrom = DateUtils.dateValue(inputDateValue);
}
HttpUtils.get({
url: GEN_GFMIS_XML + "/today",
- params:{
+ params: {
dateTo: downloadInput.dateTo,
dateFrom: downloadInput.dateFrom,
inputDate: sentDateFrom,
paymentId: selectedIds.join(',')
},
onSuccess: (responseData) => {
- // console.log(responseData)
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(responseData, 'application/xml');
- // Get the DCBHeader element
const dcbHeader = xmlDoc.querySelector("DCBHeader");
-
- // Get the Receipt and Allocation elements
+
const receiptElement = dcbHeader.querySelector("Receipt");
const allocationElement = dcbHeader.querySelector("Allocation");
const paymentMethodElements = Array.from(dcbHeader.querySelectorAll("PaymentMethod"));
- // Remove existing elements from DCBHeader
dcbHeader.innerHTML = "";
-
+
dcbHeader.appendChild(receiptElement);
dcbHeader.appendChild(allocationElement);
-
+
if (paymentMethodElements) {
paymentMethodElements.forEach((paymentMethodElement) => {
- dcbHeader.appendChild(paymentMethodElement);
- });
+ dcbHeader.appendChild(paymentMethodElement);
+ });
}
-
+
const updatedXmlString = new XMLSerializer().serializeToString(xmlDoc);
const filename = xmlDoc.querySelector('FileHeader').getAttribute('H_Filename');
- // console.log(updatedXmlString)
const blob = new Blob([updatedXmlString], { type: 'application/xml' });
- // Create a download link
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
- link.download = filename+'.xml';
-
- // Append the link to the document body
+ link.download = filename + '.xml';
+
document.body.appendChild(link);
-
- // Programmatically click the link to trigger the download
link.click();
-
- // Clean up the link
document.body.removeChild(link);
+ setIsPopUp(false);
+ },
+ onFinally: () => {
+ xmlDownloadInFlightRef.current = false;
+ setIsXmlDialogSubmitting(false);
}
- });
- // open(UrlUtils.GEN_GFMIS_XML + "/today?online=true")
- }
+ });
+ }
function applySearch(input) {
@@ -263,7 +268,11 @@ const Index = () => {
diff --git a/src/pages/Proof/Reply_GLD/ApplicationDetails.js b/src/pages/Proof/Reply_GLD/ApplicationDetails.js
index c241b75..04325b1 100644
--- a/src/pages/Proof/Reply_GLD/ApplicationDetails.js
+++ b/src/pages/Proof/Reply_GLD/ApplicationDetails.js
@@ -8,12 +8,13 @@ import {
Button,
Stack,
Dialog, DialogTitle, DialogContent, DialogActions,
+ CircularProgress,
} from '@mui/material';
import { useFormik } from 'formik';
import { useIntl } from 'react-intl';
import {isGranted} from "auth/utils";
-import {useState,useEffect,lazy} from "react";
+import {useState, useEffect, useRef, lazy} from "react";
import * as HttpUtils from "utils/HttpUtils"
import * as UrlUtils from "utils/ApiPathConst"
import * as DateUtils from "utils/DateUtils"
@@ -36,6 +37,8 @@ const ApplicationDetailCard = ({
const [data, setData] = useState({});
const [cancelPopUp, setCancelPopUp] = useState(false);
+ const [cancelLoading, setCancelLoading] = useState(false);
+ const cancellingRef = useRef(false);
const [onDownload, setOnDownload] = useState(false);
const [alertMsg, setAlertMsg] = useState('');
const [showAlert, setShowAlert] = useState(false);
@@ -98,17 +101,30 @@ const ApplicationDetailCard = ({
}
const confirmCancel = () => {
- setCancelPopUp(false);
+ if (cancellingRef.current) return;
+ cancellingRef.current = true;
+ setCancelLoading(true);
HttpUtils.get({
url: UrlUtils.CANCEL_PROOF + "/" + params.id,
onSuccess: function (responseData) {
+ cancellingRef.current = false;
+ setCancelLoading(false);
if (responseData && responseData.success === false) {
+ setCancelPopUp(false);
const msg = responseData.msg ? intl.formatMessage({ id: responseData.msg }) : intl.formatMessage({ id: 'proofAlreadyCancelled' });
setAlertMsg(msg);
setShowAlert(true);
} else {
window.location.reload(false);
}
+ },
+ onFail: () => {
+ cancellingRef.current = false;
+ setCancelLoading(false);
+ },
+ onError: () => {
+ cancellingRef.current = false;
+ setCancelLoading(false);
}
});
}
@@ -348,15 +364,24 @@ const ApplicationDetailCard = ({