Fix React Strict Mode double-call issue in Google Calendar integration
- Add state-based lock (isTestRunning) to prevent duplicate API calls - Update error handling in edge function for body consumption - Add OAuth2 token generation helper tool (get-google-token-local.html) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -52,6 +52,7 @@ export function IntegrasiTab() {
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [testEmail, setTestEmail] = useState('');
|
||||
const [sendingTest, setSendingTest] = useState(false);
|
||||
const [isTestRunning, setIsTestRunning] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
fetchSettings();
|
||||
@@ -380,9 +381,11 @@ export function IntegrasiTab() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent multiple simultaneous clicks
|
||||
const btn = document.activeElement as HTMLButtonElement;
|
||||
if (btn) btn.disabled = true;
|
||||
if (isTestRunning) {
|
||||
return; // Prevent React Strict Mode double-call
|
||||
}
|
||||
|
||||
setIsTestRunning(true);
|
||||
|
||||
try {
|
||||
const { data, error } = await supabase.functions.invoke('create-google-meet-event', {
|
||||
@@ -406,9 +409,10 @@ export function IntegrasiTab() {
|
||||
} catch (err: any) {
|
||||
toast({ title: "Error", description: err.message, variant: "destructive" });
|
||||
} finally {
|
||||
if (btn) btn.disabled = false;
|
||||
setIsTestRunning(false);
|
||||
}
|
||||
}}
|
||||
disabled={isTestRunning}
|
||||
className="w-full border-2"
|
||||
>
|
||||
Test Google Calendar Connection
|
||||
|
||||
Reference in New Issue
Block a user