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({
ready: false,
data: null as any | null,
btn_ready: true,
submit: async () => {
toast.info(
<>
@ -56,6 +57,8 @@ export const Form: React.FC<any> = ({
{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<any> = ({
}
);
}
local.btn_ready = true;
local.render();
},
reload: async () => {
local.ready = false;
@ -296,7 +301,7 @@ export const Form: React.FC<any> = ({
local.ready = true;
local.data = res;
local.render(); // Panggil render setelah data diperbarui
local.render();
if (typeof afterLoad === "function") {
await afterLoad(local);
}