refactor
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// /redux/slices/database/locationDevicesFromDBSlice.js
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
import { fetchLocationDevicesThunk } from "../../thunks/database/fetchLocationDevicesThunk";
|
||||
|
||||
|
||||
25
redux/slices/database/pois/addPoiOnPolylineSlice.js
Normal file
25
redux/slices/database/pois/addPoiOnPolylineSlice.js
Normal file
@@ -0,0 +1,25 @@
|
||||
// /redux/slices/database/pois/addPoiOnPolylineSlice.js
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
const initialState = {
|
||||
isOpen: false,
|
||||
latlng: null,
|
||||
};
|
||||
|
||||
const addPoiOnPolylineSlice = createSlice({
|
||||
name: "addPoiOnPolyline",
|
||||
initialState,
|
||||
reducers: {
|
||||
openAddPoiOnPolylineModal: (state, action) => {
|
||||
state.isOpen = true;
|
||||
state.latlng = action.payload;
|
||||
},
|
||||
closeAddPoiOnPolylineModal: (state) => {
|
||||
state.isOpen = false;
|
||||
state.latlng = null;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { openAddPoiOnPolylineModal, closeAddPoiOnPolylineModal } = addPoiOnPolylineSlice.actions;
|
||||
export default addPoiOnPolylineSlice.reducer;
|
||||
28
redux/slices/database/pois/currentPoiSlice.js
Normal file
28
redux/slices/database/pois/currentPoiSlice.js
Normal file
@@ -0,0 +1,28 @@
|
||||
// /redux/slices/database/pois/currentPoiSlice.js
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
const initialState = {
|
||||
currentPoi: null,
|
||||
};
|
||||
|
||||
const currentPoiSlice = createSlice({
|
||||
name: "currentPoi",
|
||||
initialState,
|
||||
reducers: {
|
||||
setCurrentPoi(state, action) {
|
||||
state.currentPoi = action.payload; // Zustand mit dem neuen POI aktualisieren
|
||||
},
|
||||
clearCurrentPoi(state) {
|
||||
state.currentPoi = null; // Zustand auf null zurücksetzen
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Actions exportieren
|
||||
export const { setCurrentPoi, clearCurrentPoi } = currentPoiSlice.actions;
|
||||
|
||||
// Selector exportieren (optional)
|
||||
export const selectCurrentPoi = (state) => state.currentPoi.currentPoi;
|
||||
|
||||
// Reducer exportieren
|
||||
export default currentPoiSlice.reducer;
|
||||
22
redux/slices/database/pois/poiLayerVisibleSlice.js
Normal file
22
redux/slices/database/pois/poiLayerVisibleSlice.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// /redux/slices/database/pois/poiLayerVisibleSlice.js
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
const initialState = {
|
||||
visible: true,
|
||||
};
|
||||
|
||||
export const poiLayerVisibleSlice = createSlice({
|
||||
name: "poiLayerVisible",
|
||||
initialState,
|
||||
reducers: {
|
||||
setVisible: (state, action) => {
|
||||
state.visible = action.payload;
|
||||
},
|
||||
toggleVisible: (state) => {
|
||||
state.visible = !state.visible;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setVisible, toggleVisible } = poiLayerVisibleSlice.actions;
|
||||
export default poiLayerVisibleSlice.reducer;
|
||||
22
redux/slices/database/pois/poiReadFromDbTriggerSlice.js
Normal file
22
redux/slices/database/pois/poiReadFromDbTriggerSlice.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// redux/slices/database/pois/poiReadFromDbTriggerSlice.js
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
const initialState = {
|
||||
trigger: 0,
|
||||
};
|
||||
|
||||
const poiReadFromDbTriggerSlice = createSlice({
|
||||
name: "poiReadFromDbTrigger",
|
||||
initialState,
|
||||
reducers: {
|
||||
incrementTrigger: (state) => {
|
||||
state.trigger += 1;
|
||||
},
|
||||
resetTrigger: (state) => {
|
||||
state.trigger = 0;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { incrementTrigger, resetTrigger } = poiReadFromDbTriggerSlice.actions;
|
||||
export default poiReadFromDbTriggerSlice.reducer;
|
||||
22
redux/slices/database/pois/readPoiMarkersStoreSlice.js
Normal file
22
redux/slices/database/pois/readPoiMarkersStoreSlice.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// redux/slices/database/pois/readPoiMarkersStoreSlice.js
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
const initialState = {
|
||||
poiMarkers: [],
|
||||
};
|
||||
|
||||
const readPoiMarkersStoreSlice = createSlice({
|
||||
name: "readPoiMarkersStore",
|
||||
initialState,
|
||||
reducers: {
|
||||
setPoiMarkers: (state, action) => {
|
||||
state.poiMarkers = action.payload;
|
||||
},
|
||||
clearPoiMarkers: (state) => {
|
||||
state.poiMarkers = [];
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setPoiMarkers, clearPoiMarkers } = readPoiMarkersStoreSlice.actions;
|
||||
export default readPoiMarkersStoreSlice.reducer;
|
||||
14
redux/slices/database/pois/selectedPoiSlice.js
Normal file
14
redux/slices/database/pois/selectedPoiSlice.js
Normal file
@@ -0,0 +1,14 @@
|
||||
// redux/slices/database/pois/selectedPoiSlice.js
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
export const selectedPoiSlice = createSlice({
|
||||
name: "selectedPoi",
|
||||
initialState: null,
|
||||
reducers: {
|
||||
setSelectedPoi: (state, action) => action.payload, // Speichert POI-Daten
|
||||
clearSelectedPoi: () => null, // Entfernt POI aus dem State
|
||||
},
|
||||
});
|
||||
|
||||
export const { setSelectedPoi, clearSelectedPoi } = selectedPoiSlice.actions;
|
||||
export default selectedPoiSlice.reducer;
|
||||
56
redux/slices/database/polylines/polylineContextMenuSlice.js
Normal file
56
redux/slices/database/polylines/polylineContextMenuSlice.js
Normal file
@@ -0,0 +1,56 @@
|
||||
// redux/slices/database/polylines/polylineContextMenuSlice.js
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
const initialState = {
|
||||
isOpen: false,
|
||||
position: null,
|
||||
forceClose: false,
|
||||
timerStart: null,
|
||||
countdown: 20,
|
||||
countdownActive: false, // **Neu: Redux merkt, ob der Timer aktiv ist**
|
||||
};
|
||||
|
||||
const polylineContextMenuSlice = createSlice({
|
||||
name: "polylineContextMenu",
|
||||
initialState,
|
||||
reducers: {
|
||||
openPolylineContextMenu: (state, action) => {
|
||||
state.isOpen = true;
|
||||
state.position = { lat: action.payload.position.lat, lng: action.payload.position.lng };
|
||||
state.forceClose = false;
|
||||
state.timerStart = Date.now();
|
||||
state.countdown = 20;
|
||||
state.countdownActive = true; // **Timer aktiv setzen**
|
||||
},
|
||||
closePolylineContextMenu: (state) => {
|
||||
state.isOpen = false;
|
||||
state.position = null;
|
||||
state.timerStart = null;
|
||||
state.countdown = 0;
|
||||
state.countdownActive = false; // **Timer stoppen**
|
||||
},
|
||||
updateCountdown: (state) => {
|
||||
if (state.timerStart && state.countdownActive) {
|
||||
const elapsedTime = (Date.now() - state.timerStart) / 1000;
|
||||
state.countdown = Math.max(20 - elapsedTime, 0);
|
||||
|
||||
if (state.countdown <= 2) {
|
||||
state.isOpen = false;
|
||||
state.position = null;
|
||||
state.countdownActive = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
forceCloseContextMenu: (state) => {
|
||||
state.isOpen = false;
|
||||
state.position = null;
|
||||
state.forceClose = true;
|
||||
state.timerStart = null;
|
||||
state.countdown = 0;
|
||||
state.countdownActive = false;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { openPolylineContextMenu, closePolylineContextMenu, updateCountdown, forceCloseContextMenu } = polylineContextMenuSlice.actions;
|
||||
export default polylineContextMenuSlice.reducer;
|
||||
@@ -0,0 +1,22 @@
|
||||
// redux/slices/database/polylines/polylineEventsDisabledSlice.js
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
const initialState = {
|
||||
disabled: false,
|
||||
};
|
||||
|
||||
const polylineEventsDisabledSlice = createSlice({
|
||||
name: "polylineEventsDisabled",
|
||||
initialState,
|
||||
reducers: {
|
||||
setDisabled: (state, action) => {
|
||||
state.disabled = action.payload;
|
||||
},
|
||||
toggleDisabled: (state) => {
|
||||
state.disabled = !state.disabled;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setDisabled, toggleDisabled } = polylineEventsDisabledSlice.actions;
|
||||
export default polylineEventsDisabledSlice.reducer;
|
||||
21
redux/slices/database/polylines/polylineLayerVisibleSlice.js
Normal file
21
redux/slices/database/polylines/polylineLayerVisibleSlice.js
Normal file
@@ -0,0 +1,21 @@
|
||||
// /redux/slices/database7polylines/polylineLayerVisibleSlice.js
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
const initialState = {
|
||||
visible: false, // oder Standardwert
|
||||
};
|
||||
|
||||
const polylineLayerVisibleSlice = createSlice({
|
||||
name: "polylineLayerVisible",
|
||||
initialState,
|
||||
reducers: {
|
||||
setPolylineVisible: (state, action) => {
|
||||
state.visible = action.payload;
|
||||
localStorage.setItem("polylineVisible", action.payload);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setPolylineVisible } = polylineLayerVisibleSlice.actions;
|
||||
export const selectPolylineVisible = (state) => state.polylineLayerVisible.visible;
|
||||
export default polylineLayerVisibleSlice.reducer;
|
||||
Reference in New Issue
Block a user