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