// compoenents/main/kabelueberwachung/kue705FO/hooks/useIsoDisplay.ts
import { useEffect, useState } from "react";
import { getAlarmDisplayText } from "../../../../../utils/alarmUtils";

const useIsoDisplay = (
  slotIndex: number,
  kuePSTmMinus96V: any,
  kueCableBreak: any,
  kueGroundFault: any,
  kueAlarm1: any,
  kueAlarm2: any,
  kueOverflow: any,
  isolationswert: any,
  isoDisplayText: string,
  groundFaultDisplayText: string,
  isoFaultDisplayText: string,
  loopFaultDisplayText: string,
  isoGreaterThan200: string
) => {
  const [isoDisplayValue, setIsoDisplayValue] = useState<
    string | JSX.Element
  >();

  useEffect(() => {
    setIsoDisplayValue(
      getAlarmDisplayText(
        slotIndex,
        kuePSTmMinus96V,
        kueCableBreak,
        kueGroundFault,
        kueAlarm1,
        kueAlarm2,
        kueOverflow ?? undefined,
        isolationswert,
        isoDisplayText,
        groundFaultDisplayText,
        isoFaultDisplayText,
        loopFaultDisplayText,
        isoGreaterThan200
      )
    );
  }, [
    slotIndex,
    isolationswert,
    isoDisplayText,
    groundFaultDisplayText,
    isoFaultDisplayText,
    loopFaultDisplayText,
    isoGreaterThan200,
    kuePSTmMinus96V,
    kueCableBreak,
    kueGroundFault,
    kueAlarm1,
    kueAlarm2,
    kueOverflow,
  ]);

  return isoDisplayValue;
};

export default useIsoDisplay;
