fix: update btn_ready state management in Form component for improved submission handling
This commit is contained in:
parent
58936d894f
commit
dfabe899d6
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue