- Tooltip-Text erscheint bei Mouseover über Symbol - Unterscheidung: Eingang inaktiv (✖), Eingang Aus (● rot), Eingang Ein (● grün) - Position des Tooltips mit translate-x-4 und translate-y-4 optimiert
85 lines
3.4 KiB
TypeScript
85 lines
3.4 KiB
TypeScript
"use client";
|
||
// /components/main/einausgaenge/DigitalInputs.tsx
|
||
import React from "react";
|
||
import { Icon } from "@iconify/react";
|
||
import { useSelector } from "react-redux";
|
||
import { RootState } from "../../../redux/store";
|
||
import CogIcon from "../../../components/icons/CogIcon";
|
||
|
||
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" />
|
||
Meldungseingä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.eingangOffline ? (
|
||
<div className="relative group inline-block">
|
||
<span className="text-red-500 text-2xl font-bold">✖</span>
|
||
<div className="absolute bottom-full translate-x-4 translate-y-4 w-max bg-gray-400 text-xs text-white rounded opacity-0 group-hover:opacity-100 transition p-1 z-10">
|
||
Eingang inaktiv
|
||
</div>
|
||
</div>
|
||
) : input.status ? (
|
||
<div className="relative group inline-block">
|
||
<span className="text-red-500 text-2xl">●</span>
|
||
<div className="absolute bottom-full translate-x-4 translate-y-4 w-max bg-gray-400 text-xs text-white rounded opacity-0 group-hover:opacity-100 transition p-1 z-10">
|
||
Eingang Aus
|
||
</div>
|
||
</div>
|
||
) : (
|
||
<div className="relative group inline-block">
|
||
<span className="text-green-500 text-2xl">●</span>
|
||
<div className="absolute bottom-full translate-x-4 translate-y-4 w-max bg-gray-400 text-xs text-white rounded opacity-0 group-hover:opacity-100 transition p-1 z-10">
|
||
Eingang Ein
|
||
</div>
|
||
</div>
|
||
)}
|
||
</td>
|
||
|
||
<td className="px-1 py-1">{input.label}</td>
|
||
<td className="px-1 py-1">
|
||
<CogIcon
|
||
className="2xl:w-8 2xl:h-8 xl:w-6 xl:h-6 laptop:w-4 laptop:h-4 cursor-pointer"
|
||
onClick={() => openInputModal(input)}
|
||
/>
|
||
</td>
|
||
</tr>
|
||
))}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
);
|
||
}
|