111 lines
4.4 KiB
TypeScript
111 lines
4.4 KiB
TypeScript
"use client";
|
||
// /components/main/digitalOutputs/DigitalInputs.tsx
|
||
import React from "react";
|
||
import { useSelector } from "react-redux";
|
||
import { RootState } from "../../../redux/store";
|
||
import { Icon } from "@iconify/react";
|
||
import settingsIcon from "@iconify/icons-mdi/settings";
|
||
import inputIcon from "@iconify/icons-mdi/input";
|
||
import loginIcon from "@iconify/icons-mdi/login";
|
||
|
||
type Props = {
|
||
openInputModal: (input: {
|
||
id: number;
|
||
eingangOffline: boolean;
|
||
status: boolean;
|
||
label: string;
|
||
}) => void;
|
||
inputRange: { start: number; end: number };
|
||
};
|
||
|
||
export default function DigitalInputsWidget({
|
||
openInputModal,
|
||
inputRange,
|
||
}: Props) {
|
||
const digitalInputs = useSelector(
|
||
(state: RootState) => state.digitalInputsSlice.inputs
|
||
);
|
||
|
||
const inputs = digitalInputs.slice(inputRange.start, inputRange.end);
|
||
//console.log("DigitalInputs", inputs);
|
||
|
||
return (
|
||
<div className="bg-white text-gray-900 dark:bg-gray-900 dark:text-gray-100 shadow-md border border-gray-200 dark:border-gray-700 p-3 rounded-lg w-full laptop:p-1 xl:p-1">
|
||
<h2 className="laptop:text-sm md:text-base 2xl:text-lg font-bold mb-3 flex items-center">
|
||
<Icon
|
||
icon={inputIcon}
|
||
className="text-littwin-blue mr-2 text-xl laptop:text-lg xl:text-xl 2xl:text-2xl"
|
||
/>
|
||
Meldungseingänge {inputRange.start + 1} – {inputRange.end}
|
||
</h2>
|
||
<table className="w-full text-xs laptop:text-[10px] xl:text-xs 2xl:text-sm border-collapse bg-white dark:bg-gray-900">
|
||
<thead className="bg-white text-gray-900 dark:bg-gray-900 dark:text-gray-100 border-b">
|
||
<tr>
|
||
<th className="px-1 py-1 text-left bg-white text-gray-900 dark:bg-gray-900 dark:text-gray-100">
|
||
Eingang
|
||
</th>
|
||
<th className="px-1 py-1 text-left bg-white text-gray-900 dark:bg-gray-900 dark:text-gray-100">
|
||
Zustand
|
||
</th>
|
||
<th className="px-1 py-1 text-left bg-white text-gray-900 dark:bg-gray-900 dark:text-gray-100">
|
||
Bezeichnung
|
||
</th>
|
||
<th className="px-1 py-1 text-left bg-white text-gray-900 dark:bg-gray-900 dark:text-gray-100">
|
||
Aktion
|
||
</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{inputs.map((input) => (
|
||
<tr
|
||
key={input.id}
|
||
className="border-b hover:bg-gray-100 dark:hover:bg-gray-800"
|
||
>
|
||
<td className="px-1 py-0 bg-white text-gray-900 dark:bg-gray-900 dark:text-gray-100">
|
||
<div className="flex items-center gap-1 ">
|
||
<Icon
|
||
icon={loginIcon}
|
||
className="text-gray-600 text-base laptop:text-sm xl:text-sm 2xl:text-lg"
|
||
/>
|
||
{input.id}
|
||
</div>
|
||
</td>
|
||
<td className="px-1 py-1 bg-white text-gray-900 dark:bg-gray-900 dark:text-gray-100">
|
||
{input.eingangOffline ? (
|
||
<div className="relative group inline-block">
|
||
<span className="text-red-500 sm:text-sm md:text-base lg:text-lg xl:text-xl 2xl:text-2xl laptop:text-sm ">
|
||
✖
|
||
</span>
|
||
</div>
|
||
) : input.status ? (
|
||
<div className="relative group inline-block">
|
||
<span className="text-red-500 sm:text-sm md:text-base lg:text-lg xl:text-xl 2xl:text-2xl laptop:text-sm ">
|
||
●
|
||
</span>
|
||
</div>
|
||
) : (
|
||
<div className="relative group inline-block">
|
||
<span className="text-green-500 sm:text-sm md:text-base lg:text-lg xl:text-xl 2xl:text-2xl laptop:text-sm ">
|
||
●
|
||
</span>
|
||
</div>
|
||
)}
|
||
</td>
|
||
<td className="px-1 py-1 bg-white text-gray-900 dark:bg-gray-900 dark:text-gray-100">
|
||
{input.label}
|
||
</td>
|
||
<td className="px-1 py-1 bg-white text-gray-900 dark:bg-gray-900 dark:text-gray-100">
|
||
<Icon
|
||
icon={settingsIcon}
|
||
className="text-gray-400 text-base laptop:text-sm xl:text-sm 2xl:text-lg cursor-pointer dark:text-gray-300 dark:hover:text-white"
|
||
onClick={() => openInputModal(input)}
|
||
/>
|
||
</td>
|
||
</tr>
|
||
))}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
);
|
||
}
|