// components/main/kabelueberwachung/kue705FO/hooks/useTDRChart.ts
import { useState, useEffect } from "react";
import Chart from "chart.js/auto";

type ZoomPluginType = { id: string } | null;

const useChartPlugin = () => {
  const [zoomPlugin, setZoomPlugin] = useState<ZoomPluginType>(null);

  useEffect(() => {
    if (typeof window !== "undefined") {
      import("chartjs-plugin-zoom").then((mod) => {
        setZoomPlugin(mod.default);
        Chart.register(mod.default);
      });
    }
  }, []);

  return zoomPlugin;
};

export default useChartPlugin;
