import { Card, Text, Box, Flex } from "@mantine/core"; import type { TLine, TStation } from "../untils/types"; import classes from "./Component.module.css"; import TerminalCLI from "./TerminalXTerm"; import type { Socket } from "socket.io-client"; import { IconCircleCheckFilled } from "@tabler/icons-react"; import { memo, useMemo } from "react"; const CardLine = ({ line, selectedLines, setSelectedLines, socket, stationItem, openTerminal, loadTerminal, }: { line: TLine; selectedLines: TLine[]; setSelectedLines: (lines: React.SetStateAction) => void; socket: Socket | null; stationItem: TStation; openTerminal: (value: TLine) => void; loadTerminal: boolean; }) => { const user = useMemo(() => { return localStorage.getItem("user") && typeof localStorage.getItem("user") === "string" ? JSON.parse(localStorage.getItem("user") || "") : null; }, []); return ( val.id === line.id) ? { backgroundColor: "#8bf55940" } : {} } onDoubleClick={(e) => { e.preventDefault(); e.stopPropagation(); openTerminal(line); }} onClick={(e) => { e.preventDefault(); e.stopPropagation(); if (selectedLines.find((val) => val.id === line.id)) setSelectedLines(selectedLines.filter((val) => val.id !== line.id)); else setSelectedLines((pre) => [...pre, line]); }} > Line: {line.lineNumber || line.line_number} - {line.port}{" "} {line.status === "connected" && ( )}
{line?.userOpenCLI ? line?.userOpenCLI + " is using" : ""}
{/* PID: WS-C3560CG-8PC-S
SN: FGL2240307M
VID: V01
*/} { e.preventDefault(); e.stopPropagation(); }} style={{ height: "175px", width: "300px" }} > { openTerminal(line); }} />
); }; export default memo(CardLine);