Digitale Eingänge Update mit Mock daten in der Entwicklungsumgebung

This commit is contained in:
ISA
2025-04-24 11:11:04 +02:00
parent eddf293ce2
commit 0b63579d56
7 changed files with 365 additions and 72 deletions

View File

@@ -1,4 +1,5 @@
"use client";
// /components/main/einausgaenge/DigitalInputs.tsx
import React from "react";
import { Icon } from "@iconify/react";
import { useSelector } from "react-redux";

View File

@@ -27,16 +27,36 @@ export default function InputModal({ selectedInput, closeInputModal, isOpen }) {
if (!isOpen || !selectedInput || !reduxInput) return null;
const handleInvertierungToggle = () => {
const handleInvertierungToggle = async () => {
const neueInvertierung = !invertiert;
setInvertiert(neueInvertierung);
dispatch(
updateInvertierung({ id: reduxInput.id, invertierung: neueInvertierung })
);
setInvertiert(neueInvertierung);
// Update Mock-API
await fetch("/api/cpl/updateDigitaleEingaenge", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
id: reduxInput.id,
invertierung: neueInvertierung ? 1 : 0,
}),
});
};
const handleNameSpeichern = () => {
const handleNameSpeichern = async () => {
dispatch(updateName({ id: reduxInput.id, name }));
// Update Mock-API
await fetch("/api/cpl/updateDigitaleEingaenge", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
id: reduxInput.id,
name: name,
}),
});
};
return (