fix: update btn_ready state management in Form component for improved submission handling

This commit is contained in:
faisolavolut 2025-03-05 23:12:10 +07:00
parent 58936d894f
commit dfabe899d6
1 changed files with 6 additions and 1 deletions

View File

@ -34,6 +34,7 @@ export const Form: React.FC<any> = ({
const local = useLocal({ const local = useLocal({
ready: false, ready: false,
data: null as any | null, data: null as any | null,
btn_ready: true,
submit: async () => { submit: async () => {
toast.info( toast.info(
<> <>
@ -56,6 +57,8 @@ export const Form: React.FC<any> = ({
{toastMessage ? `${toastMessage}...` : "Saving..."} {toastMessage ? `${toastMessage}...` : "Saving..."}
</> </>
); );
local.btn_ready = false;
local.render();
try { try {
const fieldDate: any = local?.fields; const fieldDate: any = local?.fields;
let isError = false; let isError = false;
@ -201,6 +204,8 @@ export const Form: React.FC<any> = ({
} }
); );
} }
local.btn_ready = true;
local.render();
}, },
reload: async () => { reload: async () => {
local.ready = false; local.ready = false;
@ -296,7 +301,7 @@ export const Form: React.FC<any> = ({
local.ready = true; local.ready = true;
local.data = res; local.data = res;
local.render(); // Panggil render setelah data diperbarui local.render();
if (typeof afterLoad === "function") { if (typeof afterLoad === "function") {
await afterLoad(local); await afterLoad(local);
} }