From dfabe899d6d4c9c99d367f180309420467a5a83e Mon Sep 17 00:00:00 2001 From: faisolavolut Date: Wed, 5 Mar 2025 23:12:10 +0700 Subject: [PATCH] fix: update btn_ready state management in Form component for improved submission handling --- components/form/Form.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/form/Form.tsx b/components/form/Form.tsx index 1bd2264..e3d00ea 100644 --- a/components/form/Form.tsx +++ b/components/form/Form.tsx @@ -34,6 +34,7 @@ export const Form: React.FC = ({ const local = useLocal({ ready: false, data: null as any | null, + btn_ready: true, submit: async () => { toast.info( <> @@ -56,6 +57,8 @@ export const Form: React.FC = ({ {toastMessage ? `${toastMessage}...` : "Saving..."} ); + local.btn_ready = false; + local.render(); try { const fieldDate: any = local?.fields; let isError = false; @@ -201,6 +204,8 @@ export const Form: React.FC = ({ } ); } + local.btn_ready = true; + local.render(); }, reload: async () => { local.ready = false; @@ -296,7 +301,7 @@ export const Form: React.FC = ({ local.ready = true; local.data = res; - local.render(); // Panggil render setelah data diperbarui + local.render(); if (typeof afterLoad === "function") { await afterLoad(local); }