Add button debouncing to prevent double API calls
- Disable button while request is in progress - Re-enable button after request completes (success or error) - Prevents React Strict Mode from firing duplicate simultaneous requests - Fixes 'Body already consumed' error from parallel edge function calls
This commit is contained in:
@@ -380,6 +380,10 @@ export function IntegrasiTab() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prevent multiple simultaneous clicks
|
||||||
|
const btn = document.activeElement as HTMLButtonElement;
|
||||||
|
if (btn) btn.disabled = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data, error } = await supabase.functions.invoke('create-google-meet-event', {
|
const { data, error } = await supabase.functions.invoke('create-google-meet-event', {
|
||||||
body: {
|
body: {
|
||||||
@@ -401,6 +405,8 @@ export function IntegrasiTab() {
|
|||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
toast({ title: "Error", description: err.message, variant: "destructive" });
|
toast({ title: "Error", description: err.message, variant: "destructive" });
|
||||||
|
} finally {
|
||||||
|
if (btn) btn.disabled = false;
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
className="w-full border-2"
|
className="w-full border-2"
|
||||||
|
|||||||
Reference in New Issue
Block a user