export const goLoop = ( slotIndex: number, setLoading: (loading: boolean) => void ) => { if (slotIndex >= 32) { return; } const slotFormat = slotIndex < 10 ? `${slotIndex}` : `${slotIndex}`; setLoading(true); alert(`Schleifenmessung wird für Slot ${slotIndex + 1} gestartet...`); fetch(`/CPL?kabelueberwachung.html&KS_${slotFormat}=1&slot=${slotIndex}`, { method: "GET", }) .then((response) => { if (response.ok) { alert( `Schleifenmessung erfolgreich gestartet für Slot ${slotIndex + 1}` ); console.log( "Schleifenmessung erfolgreich gestartet für Slot", slotIndex ); } else { alert("Fehler beim Starten der Schleifenmessung."); console.error("Fehler beim Senden der Schleifen-Anfrage"); } }) .catch((error) => { alert("Ein Fehler ist aufgetreten."); console.error("Fehler:", error); }) .finally(() => setLoading(false)); };