// components/main/kabelueberwachung/kue705FO/hooks/useKueVersion.ts
import { useEffect, useState } from "react";

const useKueVersion = (slotIndex: number, reduxKueVersion: any) => {
  const [kueVersion, setKueVersion] = useState("V4.19");

  useEffect(() => {
    if (reduxKueVersion?.[slotIndex]) {
      const versionNumber = Number(reduxKueVersion[slotIndex]);
      const major = Math.floor(versionNumber / 100);
      const minor = (versionNumber % 100).toString().padStart(2, "0");
      setKueVersion(`V${major}.${minor}`);
    }
  }, [slotIndex, reduxKueVersion]);

  return kueVersion;
};

export default useKueVersion;
