[skip ci] fix payload retry transaction on history transaction
This commit is contained in:
@ -24,15 +24,14 @@ interface ResendTransactionProps {
|
|||||||
selectedTransactionForResend: any | null; // Adjust the type as per your requirements
|
selectedTransactionForResend: any | null; // Adjust the type as per your requirements
|
||||||
}
|
}
|
||||||
|
|
||||||
const ResendTransaction = ({ isOpen, onClose, selectedTransactionForResend }: ResendTransactionProps) => {
|
const ResendTransaction = ({
|
||||||
|
isOpen,
|
||||||
|
onClose,
|
||||||
|
selectedTransactionForResend
|
||||||
|
}: ResendTransactionProps) => {
|
||||||
// const { showResendDialog, handleResendDialog, selectedTransactionForResend } = useTransactionContext();
|
// const { showResendDialog, handleResendDialog, selectedTransactionForResend } = useTransactionContext();
|
||||||
const { GetData, PostData } = useCallApi();
|
const { GetData, PostData } = useCallApi();
|
||||||
const {
|
const { showDetailDialog, setShowDetailDialog, selectedTransactionId } = useTransactionContext();
|
||||||
showDetailDialog,
|
|
||||||
setShowDetailDialog,
|
|
||||||
selectedTransactionId
|
|
||||||
} = useTransactionContext();
|
|
||||||
const { reload } = useDataGrid();
|
const { reload } = useDataGrid();
|
||||||
const [transactionDetails, setTransactionDetails] = useState<any>(null);
|
const [transactionDetails, setTransactionDetails] = useState<any>(null);
|
||||||
const [alert, setAlert] = useState({
|
const [alert, setAlert] = useState({
|
||||||
@ -81,9 +80,8 @@ const ResendTransaction = ({ isOpen, onClose, selectedTransactionForResend }: Re
|
|||||||
|
|
||||||
// console.log(selectedTransactionForResend);
|
// console.log(selectedTransactionForResend);
|
||||||
|
|
||||||
|
const doResendTransaction = useCallback(
|
||||||
const doResendTransaction = useCallback(async (data: any | null, pintransactiion: string) => {
|
async (data: any | null, pintransactiion: string) => {
|
||||||
|
|
||||||
if (pintransactiion.trim() === '') {
|
if (pintransactiion.trim() === '') {
|
||||||
setAlert({ show: true, message: 'Please fill pin.' });
|
setAlert({ show: true, message: 'Please fill pin.' });
|
||||||
return;
|
return;
|
||||||
@ -118,7 +116,7 @@ const ResendTransaction = ({ isOpen, onClose, selectedTransactionForResend }: Re
|
|||||||
amount: String(data.transfer.amount),
|
amount: String(data.transfer.amount),
|
||||||
pin: pintransactiion,
|
pin: pintransactiion,
|
||||||
type: data.transfer.type
|
type: data.transfer.type
|
||||||
}
|
};
|
||||||
break;
|
break;
|
||||||
case 'U':
|
case 'U':
|
||||||
apiEndpoint = `${API_URL}/transaction/topup`;
|
apiEndpoint = `${API_URL}/transaction/topup`;
|
||||||
@ -128,7 +126,7 @@ const ResendTransaction = ({ isOpen, onClose, selectedTransactionForResend }: Re
|
|||||||
pin_p24: data.transfer.pin_p24,
|
pin_p24: data.transfer.pin_p24,
|
||||||
amount: String(data.transfer.amount),
|
amount: String(data.transfer.amount),
|
||||||
pin: pintransactiion
|
pin: pintransactiion
|
||||||
}
|
};
|
||||||
break;
|
break;
|
||||||
case 'W':
|
case 'W':
|
||||||
apiEndpoint = `${API_URL}/transaction/withdraw`;
|
apiEndpoint = `${API_URL}/transaction/withdraw`;
|
||||||
@ -138,25 +136,25 @@ const ResendTransaction = ({ isOpen, onClose, selectedTransactionForResend }: Re
|
|||||||
destination_iban: data.transfer.destination_iban,
|
destination_iban: data.transfer.destination_iban,
|
||||||
amount: String(data.transfer.amount),
|
amount: String(data.transfer.amount),
|
||||||
pin: pintransactiion
|
pin: pintransactiion
|
||||||
}
|
};
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
let walletParam = "";
|
let walletParam = '';
|
||||||
apiEndpoint = `${API_URL}/transaction/purchase`;
|
apiEndpoint = `${API_URL}/transaction/purchase`;
|
||||||
if (data.origin_wallet.name === 'Emoney Account') {
|
if (data.origin_wallet.name === 'Emoney Account') {
|
||||||
walletParam = "emoney";
|
walletParam = 'emoney';
|
||||||
} else if (data.origin_wallet.name === 'Point Account') {
|
} else if (data.origin_wallet.name === 'Point Account') {
|
||||||
walletParam = "point";
|
walletParam = 'point';
|
||||||
}
|
}
|
||||||
apiJsonData = {
|
apiJsonData = {
|
||||||
id_origin_customer: data.origin_customer.id,
|
id_origin_customer: data.origin_customer.id,
|
||||||
code_product: data.purchase.code,
|
code_product: data.purchase.product.code,
|
||||||
wallet: walletParam,
|
wallet: walletParam,
|
||||||
destination_number: data.purchase.destination_number,
|
destination_number: data.purchase.destination_number,
|
||||||
destination_amount: data.purchase.destination_amount,
|
destination_amount: data.purchase.destination_amount ?? 0,
|
||||||
pin: pintransactiion,
|
pin: pintransactiion,
|
||||||
purpose: data.purchase.purpose
|
purpose: data.purchase.purpose ?? 'Purchase'
|
||||||
}
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,10 +181,12 @@ const ResendTransaction = ({ isOpen, onClose, selectedTransactionForResend }: Re
|
|||||||
|
|
||||||
doSaveLogActivity(createActivity);
|
doSaveLogActivity(createActivity);
|
||||||
} else {
|
} else {
|
||||||
setAlert({ show: true, message: response?.message.message });
|
setAlert({ show: true, message: response?.message });
|
||||||
toast.error('Failed Retry Transaction');
|
toast.error('Failed Retry Transaction');
|
||||||
}
|
}
|
||||||
}, [selectedTransactionForResend, PostData]);
|
},
|
||||||
|
[selectedTransactionForResend, PostData]
|
||||||
|
);
|
||||||
|
|
||||||
if (!isOpen) return null;
|
if (!isOpen) return null;
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ const ResendTransaction = ({ isOpen, onClose, selectedTransactionForResend }: Re
|
|||||||
<p className="text-sm">You will retry this transaction!</p>
|
<p className="text-sm">You will retry this transaction!</p>
|
||||||
</Alert>
|
</Alert>
|
||||||
{alert.show && (
|
{alert.show && (
|
||||||
<Alert variant="danger">
|
<Alert variant="danger" className="my-2">
|
||||||
<h3>{alert.message}</h3>
|
<h3>{alert.message}</h3>
|
||||||
</Alert>
|
</Alert>
|
||||||
)}
|
)}
|
||||||
@ -222,7 +222,10 @@ const ResendTransaction = ({ isOpen, onClose, selectedTransactionForResend }: Re
|
|||||||
{/* <Button variant="outline" onClick={() => handleResendDialog(false, null)}>
|
{/* <Button variant="outline" onClick={() => handleResendDialog(false, null)}>
|
||||||
Cancel
|
Cancel
|
||||||
</Button> */}
|
</Button> */}
|
||||||
<button className="btn btn-primary" onClick={() => doResendTransaction(selectedTransactionForResend, formField.pin)}>
|
<button
|
||||||
|
className="btn btn-primary"
|
||||||
|
onClick={() => doResendTransaction(selectedTransactionForResend, formField.pin)}
|
||||||
|
>
|
||||||
Retry
|
Retry
|
||||||
</button>
|
</button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|||||||
Reference in New Issue
Block a user