40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
// components/main/kabelueberwachung/kue705FO/kue705FO-Funktionen/handleButtonClick.ts
|
|
import { Dispatch } from "react";
|
|
import { AppDispatch } from "@/redux/store";
|
|
import {
|
|
setActiveMode,
|
|
setSelectedSlot,
|
|
} from "@/redux/slices/kueChartModeSlice";
|
|
|
|
const handleButtonClick = (
|
|
button: "Schleife" | "TDR",
|
|
setActiveButton: Dispatch<React.SetStateAction<"Schleife" | "TDR">>,
|
|
setLoopTitleText: Dispatch<React.SetStateAction<string>>,
|
|
setLoopDisplayValue: Dispatch<React.SetStateAction<number | string>>,
|
|
schleifenwiderstand: number,
|
|
tdrLocation: number[] | undefined,
|
|
dispatch: AppDispatch,
|
|
slotIndex: number
|
|
) => {
|
|
// 🔥 Speichert den gewählten Slot im Redux-Store
|
|
dispatch(setSelectedSlot(slotIndex));
|
|
|
|
if (button === "Schleife") {
|
|
setActiveButton("Schleife");
|
|
setLoopTitleText("Schleifenwiderstand [kOhm]");
|
|
setLoopDisplayValue(schleifenwiderstand);
|
|
dispatch(setActiveMode("Schleife"));
|
|
} else if (button === "TDR") {
|
|
setActiveButton("TDR");
|
|
setLoopTitleText("Entfernung [Km]");
|
|
setLoopDisplayValue(
|
|
tdrLocation && tdrLocation[slotIndex] !== undefined
|
|
? tdrLocation[slotIndex]
|
|
: "0"
|
|
);
|
|
dispatch(setActiveMode("TDR"));
|
|
}
|
|
};
|
|
|
|
export default handleButtonClick;
|