- `console.log`-Ausgaben für `vonDatum`, `bisDatum` und `formatierteDaten` hinzugefügt - Fehleranalyse für `startIndex` und `endIndex` in `LoopMeasurementChart.tsx` - Falls `startIndex` oder `endIndex` nicht gefunden wird, wird die gesamte Datenreihe geloggt - Vorbereitung für Fallback-Lösung, falls Datum nicht exakt gefunden wird
62 lines
2.0 KiB
TypeScript
62 lines
2.0 KiB
TypeScript
import React from "react";
|
|
import DatePicker from "react-datepicker";
|
|
import { useSelector, useDispatch } from "react-redux";
|
|
import { RootState } from "../../../../../redux/store";
|
|
import {
|
|
setVonDatum,
|
|
setBisDatum,
|
|
} from "../../../../../redux/slices/kabelueberwachungChartSlice";
|
|
import "react-datepicker/dist/react-datepicker.css";
|
|
|
|
const DateRangePicker: React.FC = () => {
|
|
const dispatch = useDispatch();
|
|
|
|
const reduxVonDatum = useSelector(
|
|
(state: RootState) => state.kabelueberwachungChart.vonDatum
|
|
);
|
|
const reduxBisDatum = useSelector(
|
|
(state: RootState) => state.kabelueberwachungChart.bisDatum
|
|
);
|
|
|
|
return (
|
|
<div className="flex space-x-4">
|
|
<div>
|
|
<label className="block text-sm font-semibold">Von</label>
|
|
<DatePicker
|
|
selected={reduxVonDatum ? new Date(reduxVonDatum) : new Date()}
|
|
onChange={(date) => {
|
|
if (date) {
|
|
dispatch(setVonDatum(date.toISOString().split("T")[0]));
|
|
}
|
|
}}
|
|
selectsStart
|
|
startDate={reduxVonDatum ? new Date(reduxVonDatum) : new Date()}
|
|
endDate={reduxBisDatum ? new Date(reduxBisDatum) : new Date()}
|
|
dateFormat="dd.MM.yyyy"
|
|
className="border px-2 py-1 rounded"
|
|
/>
|
|
</div>
|
|
|
|
<div>
|
|
<label className="block text-sm font-semibold">Bis</label>
|
|
<DatePicker
|
|
selected={reduxBisDatum ? new Date(reduxBisDatum) : new Date()}
|
|
onChange={(date) => {
|
|
if (date) {
|
|
dispatch(setBisDatum(date.toISOString().split("T")[0]));
|
|
}
|
|
}}
|
|
selectsEnd
|
|
startDate={reduxVonDatum ? new Date(reduxVonDatum) : new Date()}
|
|
endDate={reduxBisDatum ? new Date(reduxBisDatum) : new Date()}
|
|
minDate={reduxVonDatum ? new Date(reduxVonDatum) : new Date()}
|
|
dateFormat="dd.MM.yyyy"
|
|
className="border px-2 py-1 rounded"
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default DateRangePicker;
|