At the time of Update in Purchase Automatically hit the sumit without click.
This commit is contained in:
parent
194b032870
commit
35b3384dac
@ -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,50 +182,53 @@ 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)}
|
||||
>
|
||||
{stepsConfig[activeTab].component}
|
||||
{activeTab !== 2 && (
|
||||
<div>
|
||||
{stepsConfig[activeTab].component}
|
||||
|
||||
{/* Buttons */}
|
||||
<div className="d-flex justify-content-between mt-4">
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-outline-secondary"
|
||||
onClick={handlePrev}
|
||||
disabled={activeTab === 0}
|
||||
>
|
||||
Previous
|
||||
</button>
|
||||
<div className="d-flex justify-content-between mt-4">
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-outline-secondary"
|
||||
onClick={handlePrev}
|
||||
disabled={activeTab === 0}
|
||||
>
|
||||
Previous
|
||||
</button>
|
||||
|
||||
<div>
|
||||
{activeTab < stepsConfig.length - 1 ? (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-primary"
|
||||
onClick={handleNext}
|
||||
disabled={isPending || isUpdating}
|
||||
>
|
||||
Next
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
type={activeTab == 2 ? "submit" : "button"}
|
||||
className="btn btn-sm btn-primary"
|
||||
disabled={isPending || isUpdating}
|
||||
>
|
||||
{isPending || isUpdating ? "Please Wait" : "Submit"}
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-primary"
|
||||
onClick={handleNext}
|
||||
>
|
||||
Next
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
)}
|
||||
{activeTab === 2 && (
|
||||
<form onSubmit={purchaseOrder.handleSubmit(onSubmit)}>
|
||||
{stepsConfig[2].component}
|
||||
|
||||
<div className="d-flex justify-content-between mt-4">
|
||||
<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>
|
||||
</form>
|
||||
)}
|
||||
</AppFormProvider>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user