At the time of Update in Purchase Automatically hit the sumit without click.

This commit is contained in:
Kartik Sharma 2025-12-01 11:39:34 +05:30
parent 194b032870
commit 35b3384dac

View File

@ -127,8 +127,6 @@ const ManagePurchase = ({ onClose, purchaseId }) => {
const onSubmit = useCallback(
(formData) => {
if (activeTab !== 2) return;
if (purchaseId) {
const payload = generatePatchOps(formData);
updatePurchase({ purchaseId, payload });
@ -136,7 +134,7 @@ const ManagePurchase = ({ onClose, purchaseId }) => {
CreateInvoice(formData);
}
},
[activeTab, purchaseId, generatePatchOps, updatePurchase, CreateInvoice]
[purchaseId, generatePatchOps, updatePurchase, CreateInvoice]
);
return (
<div className="bs-stepper horizontically mt-2 b-secondry shadow-none border-0">
@ -184,18 +182,10 @@ const ManagePurchase = ({ onClose, purchaseId }) => {
{/* --- Form Content --- */}
<div className="bs-stepper-content py-2 px-3">
<AppFormProvider {...purchaseOrder}>
<form
onSubmitCapture={(e) => {
if (activeTab !== 2) {
e.preventDefault();
e.stopPropagation();
}
}}
onSubmit={purchaseOrder.handleSubmit(onSubmit)}
>
{activeTab !== 2 && (
<div>
{stepsConfig[activeTab].component}
{/* Buttons */}
<div className="d-flex justify-content-between mt-4">
<button
type="button"
@ -206,28 +196,39 @@ const ManagePurchase = ({ onClose, purchaseId }) => {
Previous
</button>
<div>
{activeTab < stepsConfig.length - 1 ? (
<button
type="button"
className="btn btn-sm btn-primary"
onClick={handleNext}
disabled={isPending || isUpdating}
>
Next
</button>
) : (
</div>
</div>
)}
{activeTab === 2 && (
<form onSubmit={purchaseOrder.handleSubmit(onSubmit)}>
{stepsConfig[2].component}
<div className="d-flex justify-content-between mt-4">
<button
type={activeTab == 2 ? "submit" : "button"}
type="button"
className="btn btn-sm btn-outline-secondary"
onClick={handlePrev}
>
Previous
</button>
<button
type="submit"
className="btn btn-sm btn-primary"
disabled={isPending || isUpdating}
>
{isPending || isUpdating ? "Please Wait" : "Submit"}
</button>
)}
</div>
</div>
</form>
)}
</AppFormProvider>
</div>
</div>