// /components/main/kabelueberwachung/kue705FO/Charts/TDRChart/TDRChartActionBar.tsx import React, { useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import { RootState } from "../../../../../../redux/store"; import { fetchTDRChartDataById } from "../../../../../../services/fetchTDRChartDataById"; import { setTDRChartDataById, setSelectedTDRId, } from "../../../../../../redux/slices/tdrDataByIdSlice"; const TDRChartActionBar: React.FC = () => { const dispatch = useDispatch(); const tdmChartData = useSelector((state: RootState) => state.tdmChart.data); const selectedSlot = useSelector( (state: RootState) => state.kueChartMode.selectedSlot ); const idsForSlot = selectedSlot !== null ? tdmChartData[selectedSlot] ?? [] : []; const [selectedId, setSelectedId] = useState(null); const handleSelectChange = async ( e: React.ChangeEvent ) => { const id = parseInt(e.target.value); setSelectedId(id); const data = await fetchTDRChartDataById(id); if (!data) return; dispatch(setTDRChartDataById({ id, data })); dispatch(setSelectedTDRId(id)); // 👉 wichtig! }; return (
{idsForSlot.length > 0 && ( <> )}
); }; export default TDRChartActionBar;