// components/modulesStatus/KabelModulStatus.jsx
import React from "react";

const KabelModulStatus = ({ slot, kueCableBreak, isOnline, moduleVersion }) => {
  if (!isOnline) {
    return (
      <div className="border border-gray-400 w-10 h-20 flex items-center justify-center bg-gray-200">
        <div className="text-xs text-gray-500">Leer</div>
      </div>
    );
  }

  // Bestimme den Modultyp basierend auf der Version
  let moduleName = "";
  let moduleType = "";

  if (moduleVersion === 419) {
    moduleName = "KÜ705";
    moduleType = "FO";
  } else if (moduleVersion === 350) {
    moduleName = "KÜ605";
    moduleType = "µC";
  } else if (moduleVersion === 1100) {
    moduleName = "KÜSS";
    moduleType = "___";
  }

  const isCableBreak = kueCableBreak[slot - 1] === 1;

  return (
    <div className="border border-gray-400 w-10 h-20 flex flex-col">
      {/* Slot-Nummer anzeigen */}
      <div className="bg-littwin-blue flex-grow flex flex-col items-center justify-center text-white text-[10px]">
        <div className="flex w-full mb-1 items-start justify-start">{slot}</div>
        <div className="text-[10px]">{moduleName}</div>
        <div className="text-[10px]">{moduleType}</div>
      </div>
      {/* Status-Anzeige */}
      <div
        className={`w-full h-2/6 ${
          isCableBreak ? "bg-red-500" : "bg-green-500"
        }`}
      ></div>
      <div className="bg-littwin-blue w-full h-1/6"></div>
    </div>
  );
};

export default KabelModulStatus;
