feat: Modularize KueModal component by extracting handler functions

- Moved `handleSave`, `handleChange`, `handleDisplayEinschalten`, `handleSetDateTime`, `handleClearDatabase`, and `handleReboot` to separate handler files for better modularity and code organization.
- Updated imports in `KueModal.jsx` and `SettingsModal.jsx` to use new handler files.
- Improved code readability and maintainability by organizing functions into dedicated handler modules.
This commit is contained in:
ISA
2024-11-09 19:29:33 +01:00
parent c4e89d690c
commit 589c8a0e9e
7 changed files with 59 additions and 44 deletions

View File

@@ -0,0 +1,10 @@
// Funktionen zur Änderung der Werte
const handleChange = (setter, e, slot) => {
const value = e.target.value;
setter((prev) => {
const updated = [...prev];
updated[slot] = value;
return updated;
});
};
export default handleChange;

View File

@@ -0,0 +1,16 @@
const handleDisplayEinschalten = (slot) => {
const url = `/CPL?/kabelueberwachung.html&KSD${slot}=1`;
fetch(url, { method: "GET" })
.then((response) => {
if (response.ok) {
alert(`Display für Slot ${slot + 1} erfolgreich eingeschaltet!`);
} else {
alert("Fehler beim Einschalten des Displays!");
}
})
.catch((error) => {
console.error("Fehler:", error);
alert("Fehler beim Einschalten des Displays!");
});
};
export default handleDisplayEinschalten;

View File

@@ -84,3 +84,5 @@ const handleSave = ({
onClose();
};
export default handleSave;