[ update approve modal ]

This commit is contained in:
YasinShaikh123
2025-01-17 17:51:58 +05:30
parent 79c822bb4d
commit 9f93993938
2 changed files with 90 additions and 8 deletions

View File

@@ -17,6 +17,7 @@ import { TABLE_PAGINATION } from "../../Constants/Paginations";
import GlobalStateContext from "../../Contexts/GlobalStateContext";
import { OPACITY_ON_LOAD } from "../../Layout/animations";
import {
useApproveAccountDeletionRequestMutation,
useGetAccountDeletionMasterQuery,
useRejectAccountDeletionRequestMutation,
} from "../../Services/reversal.account.deletion.service";
@@ -24,6 +25,7 @@ import ConfirmModal from "./ConfirmModal";
import RejectModal from "./RejectModal";
import RejectReversalPopups from "../../Components/Popups/RejectReversalPopups";
import ToastBox from "../../Components/ToastBox";
import ConfirmReversalPopups from "../../Components/Popups/ConfirmReversalPopups";
// import { formatDate } from "../../Components/Functions/UTCConvertor";
const ReversalAccountDeletion = () => {
@@ -53,8 +55,9 @@ const ReversalAccountDeletion = () => {
onClose: onRejectClose,
} = useDisclosure();
const [rejectAccountDeletionRequest] =
useRejectAccountDeletionRequestMutation();
const [rejectAccountDeletionRequest] = useRejectAccountDeletionRequestMutation();
const [approveAccountDeletionRequest] = useApproveAccountDeletionRequestMutation();
// Debounce the search term to avoid making a request on every keystroke
useEffect(() => {
@@ -293,6 +296,46 @@ const ReversalAccountDeletion = () => {
}
};
const handleConfirm = async (data) => {
setIsReversalLoading.on(); // Start loading
try {
const { error, data: responseData } = await approveAccountDeletionRequest({
id: actionId,
data,
});
if (error) {
throw error; // Explicitly handle the error
}
// Success: Perform necessary actions
refetch();
toast({
render: () => (
<ToastBox message={responseData?.message || "Action successful!"} />
),
});
onRejectClose();
} catch (error) {
// Handle errors
toast({
render: () => (
<ToastBox
message={
error?.data?.message || "Something went wrong. Please try again."
}
status="error"
/>
),
});
console.error("Error:", error);
} finally {
setIsReversalLoading.off(); // Ensure loading is toggled off
}
};
return (
<Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"} pb={38}>
<Box bg="white.500">
@@ -342,12 +385,11 @@ const ReversalAccountDeletion = () => {
alertHandler={handleDelete}
isLoading={isLoading}
/>
<ConfirmModal
// data={data?.data?.rows}
<ConfirmReversalPopups
isOpen={isConfirmOpen}
onClose={onConfirmClose}
id={actionId}
// firstField={firstField}
handleConfirm={handleConfirm}
isLoading={isReversalLoading}
/>
<RejectReversalPopups
isOpen={isRejectOpen}

View File

@@ -301,6 +301,46 @@ const ReversalFawateerDeposit = () => {
}
};
const handleConfirm = async (data) => {
setIsReversalLoading.on(); // Start loading
try {
const { error, data: responseData } = await approveFawateerRequest({
id: actionId,
data,
});
if (error) {
throw error; // Explicitly handle the error
}
// Success: Perform necessary actions
refetch();
toast({
render: () => (
<ToastBox message={responseData?.message || "Action successful!"} />
),
});
onRejectClose();
} catch (error) {
// Handle errors
toast({
render: () => (
<ToastBox
message={
error?.data?.message || "Something went wrong. Please try again."
}
status="error"
/>
),
});
console.error("Error:", error);
} finally {
setIsReversalLoading.off(); // Ensure loading is toggled off
}
};
return (
<Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"} pb={38}>
<Box bg="white.500">
@@ -358,9 +398,9 @@ const ReversalFawateerDeposit = () => {
<ConfirmReversalPopups
isOpen={isConfirmOpen}
onClose={onConfirmClose}
handelApproved={handleApproved}
handleConfirm={handleConfirm}
isLoading={isReversalLoading}
/>
/>
<RejectReversalPopups
isOpen={isRejectOpen}
onClose={onRejectClose}