Digitale Eingänge Update mit Mock daten in der Entwicklungsumgebung
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user