refactor: Modal- und Widget-Komponenten umbenannt für bessere Lesbarkeit und Trennung von Seite und UI-Logik
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
win_da_state = [1, 0, 1, 0];
|
||||
win_da_state = [0, 0, 1, 0];
|
||||
win_da_bezeichnung = ["Ausgang1", "Ausgang2", "Ausgang3", "Ausgang4"];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use client";
|
||||
// /components/main/einausgaenge/DigitalOutputs.tsx
|
||||
// /components/main/einausgaenge/DigitalOutputsWidget.tsx
|
||||
import React from "react";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { RootState, AppDispatch } from "../../../redux/store";
|
||||
@@ -9,7 +9,7 @@ import outputIcon from "@iconify/icons-mdi/output";
|
||||
import switchIcon from "@iconify/icons-ion/switch";
|
||||
import { setDigitalOutputs } from "../../../redux/slices/digitalOutputsSlice";
|
||||
|
||||
export default function DigitalOutputs({ openOutputModal }) {
|
||||
export default function DigitalOutputsWidget({ openOutputModal }) {
|
||||
const dispatch = useDispatch<AppDispatch>();
|
||||
const digitalOutputs = useSelector(
|
||||
(state: RootState) => state.digitalOutputsSlice.outputs
|
||||
@@ -1,9 +1,9 @@
|
||||
"use client"; // /components/main/einausgaenge/modals/OutputModal.tsx
|
||||
"use client"; // /components/main/einausgaenge/modals/DigitalOutputsModal.tsx
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { useSelector } from "react-redux";
|
||||
import { RootState } from "../../../../redux/store";
|
||||
|
||||
export default function OutputModal({
|
||||
export default function DigitalOutputsModal({
|
||||
selectedOutput,
|
||||
closeOutputModal,
|
||||
isOpen,
|
||||
@@ -39,7 +39,9 @@ export default function OutputModal({
|
||||
setErrorMsg("");
|
||||
|
||||
const updatedOutputs = allOutputs.map((output) =>
|
||||
output.id === selectedOutput.id ? { ...output, label, status } : output
|
||||
output.id === selectedOutput.id
|
||||
? { ...output, label: label.trim(), status }
|
||||
: output
|
||||
);
|
||||
|
||||
try {
|
||||
@@ -53,7 +55,10 @@ export default function OutputModal({
|
||||
const err = await res.json();
|
||||
setErrorMsg(err?.error || "Fehler beim Speichern.");
|
||||
} else {
|
||||
console.log("✅ Änderungen gespeichert");
|
||||
console.log(
|
||||
"✅ Status & Label gespeichert für Ausgang",
|
||||
selectedOutput.id
|
||||
);
|
||||
closeOutputModal();
|
||||
}
|
||||
} catch (err) {
|
||||
@@ -93,20 +98,6 @@ export default function OutputModal({
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="mb-4">
|
||||
<label className="block font-semibold mb-1">
|
||||
Timer (Sekunden, optional)
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
value={timer}
|
||||
onChange={(e) => setTimer(parseInt(e.target.value))}
|
||||
className="w-full border border-gray-300 rounded px-3 py-2"
|
||||
placeholder="z. B. 5 für 5 Sekunden"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{errorMsg && <p className="text-red-600 text-sm mb-2">{errorMsg}</p>}
|
||||
|
||||
<div className="flex justify-end gap-2 mt-6">
|
||||
@@ -6,5 +6,5 @@
|
||||
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
|
||||
|
||||
*/
|
||||
const webVersion = "1.6.335";
|
||||
const webVersion = "1.6.336";
|
||||
export default webVersion;
|
||||
|
||||
@@ -3,12 +3,12 @@ import React, { useEffect, useState } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { AppDispatch, RootState } from "../redux/store";
|
||||
|
||||
import OutputModal from "../components/main/einausgaenge/modals/OutputModal";
|
||||
import DigitalOutputsModal from "../components/main/einausgaenge/modals/DigitalOutputsModal";
|
||||
|
||||
import { fetchDigitaleEingaengeThunk } from "../redux/thunks/fetchDigitaleEingaengeThunk";
|
||||
import { fetchDigitalOutputsThunk } from "../redux/thunks/fetchDigitalOutputsThunk";
|
||||
|
||||
import DigitalOutputs from "../components/main/einausgaenge/DigitalOutputs";
|
||||
import DigitalOutputs from "../components/main/einausgaenge/DigitalOutputsWidget";
|
||||
|
||||
const EinAusgaenge: React.FC = () => {
|
||||
const dispatch = useDispatch<AppDispatch>();
|
||||
@@ -50,7 +50,7 @@ const EinAusgaenge: React.FC = () => {
|
||||
</div>
|
||||
|
||||
{/* ✅ Modal aktiv einbinden */}
|
||||
<OutputModal
|
||||
<DigitalOutputsModal
|
||||
selectedOutput={selectedOutput}
|
||||
isOpen={isOutputModalOpen}
|
||||
closeOutputModal={closeOutputModal}
|
||||
|
||||
Reference in New Issue
Block a user