fix: API-URL-Format & dynamische Base-URL für Produktion korrigiert
This commit is contained in:
@@ -6,7 +6,8 @@ interface KabelueberwachungChartState {
|
||||
bisDatum: string;
|
||||
selectedMode: "DIA0" | "DIA1" | "DIA2";
|
||||
selectedSlotType: "isolationswiderstand" | "schleifenwiderstand";
|
||||
isChartOpen: boolean; // NEU: Schalter für das erste Öffnen des Charts
|
||||
isChartOpen: boolean;
|
||||
slotNumber: number | null; // NEU: Slot-Nummer speichern
|
||||
}
|
||||
|
||||
const initialState: KabelueberwachungChartState = {
|
||||
@@ -15,32 +16,27 @@ const initialState: KabelueberwachungChartState = {
|
||||
bisDatum: "2025-02-28",
|
||||
selectedMode: "DIA0",
|
||||
selectedSlotType: "schleifenwiderstand",
|
||||
isChartOpen: false, // Standard: Chart ist beim ersten Laden geschlossen
|
||||
isChartOpen: false,
|
||||
slotNumber: null, // Standard: Kein Slot gewählt
|
||||
};
|
||||
|
||||
const kabelueberwachungChartSlice = createSlice({
|
||||
name: "kabelueberwachungChart",
|
||||
initialState,
|
||||
reducers: {
|
||||
setSlotNumber: (state, action: PayloadAction<number | null>) => {
|
||||
state.slotNumber = action.payload;
|
||||
},
|
||||
setChartData: (state, action: PayloadAction<any[]>) => {
|
||||
state.chartData = action.payload;
|
||||
|
||||
// Falls das Chart das erste Mal geöffnet wird, setze vonDatum & bisDatum
|
||||
if (!state.isChartOpen && action.payload.length > 0) {
|
||||
const firstDate = new Date(action.payload[action.payload.length - 1].t);
|
||||
const lastDate = new Date(action.payload[0].t);
|
||||
state.vonDatum = firstDate.toISOString().split("T")[0];
|
||||
state.bisDatum = lastDate.toISOString().split("T")[0];
|
||||
|
||||
state.isChartOpen = true; // Schalter setzen, damit es nicht erneut passiert
|
||||
}
|
||||
},
|
||||
setVonDatum: (state, action: PayloadAction<string>) => {
|
||||
state.vonDatum = action.payload;
|
||||
state.vonDatum = action.payload.replace(/-/g, ";"); // Speichert als "YYYY;MM;DD"
|
||||
},
|
||||
setBisDatum: (state, action: PayloadAction<string>) => {
|
||||
state.bisDatum = action.payload;
|
||||
state.bisDatum = action.payload.replace(/-/g, ";"); // Speichert als "YYYY;MM;DD"
|
||||
},
|
||||
|
||||
setSelectedMode: (
|
||||
state,
|
||||
action: PayloadAction<"DIA0" | "DIA1" | "DIA2">
|
||||
@@ -66,6 +62,7 @@ export const {
|
||||
setSelectedMode,
|
||||
setSelectedSlotType,
|
||||
setChartOpen,
|
||||
setSlotNumber, // NEU: Action für Slot-Nummer exportieren
|
||||
} = kabelueberwachungChartSlice.actions;
|
||||
|
||||
export default kabelueberwachungChartSlice.reducer;
|
||||
|
||||
Reference in New Issue
Block a user