Files
CPLv4.0/components/main/einausgaenge/DigitalInputs.tsx
ISA 75759791cd Logik für Farbe abhängig von Status + Invertierung:
Anzeige ist rot wenn Status=1 ist. Die Farbe ist nicht abhängig von der Invertierung.
Status	Invertierung	Anzeige
1                1	            🔴 rot
1	             0	            🔴 rot
0	             1	            grün
0	             0              grün
2025-04-03 11:04:49 +02:00

67 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client";
import React from "react";
import { Icon } from "@iconify/react";
import { useSelector } from "react-redux";
import { RootState } from "../../../redux/store";
type Props = {
openInputModal: (input: any) => void;
inputRange: { start: number; end: number };
};
export default function DigitalInputs({ openInputModal, inputRange }: Props) {
const digitalInputs = useSelector(
(state: RootState) => state.digitalInputsSlice.inputs
);
const inputs = digitalInputs.slice(inputRange.start, inputRange.end);
return (
<div className="bg-white shadow-md border border-gray-200 p-3 rounded-lg w-full">
<h2 className="text-sm font-bold mb-3 flex items-center">
<Icon icon="mdi:input" className="text-littwin-blue mr-2 text-xl" />
Digitale Eingänge {inputRange.start + 1} {inputRange.end}
</h2>
<table className="w-full text-xs border-collapse">
<thead className="bg-gray-100 border-b">
<tr>
<th className="px-1 py-1 text-left">Eingang</th>
<th className="px-1 py-1 text-left">Zustand</th>
<th className="px-1 py-1 text-left">Bezeichnung</th>
<th className="px-1 py-1 text-left">Aktion</th>
</tr>
</thead>
<tbody>
{inputs.map((input) => (
<tr key={input.id} className="border-b">
<td className="flex items-center px-1 py-1">
<Icon
icon="mdi:login"
className="text-gray-600 mr-1 text-base"
/>
{input.id}
</td>
<td className="px-1 py-1">
{input.status ? (
<span className="text-red-500 text-xs"></span>
) : (
<span className="text-green-500 text-xs"></span>
)}
</td>
<td className="px-1 py-1">{input.label}</td>
<td className="px-1 py-1">
<Icon
icon="mdi:cog"
className="text-gray-400 text-base cursor-pointer"
onClick={() => openInputModal(input)}
/>
</td>
</tr>
))}
</tbody>
</table>
</div>
);
}