refactor: POI-Daten vollständig in Redux integriert

- useFetchPoiData.js entfernt
- Neue Redux-Slices für POI-Typen und POI-Icons erstellt
- Neue Services und Thunks hinzugefügt
- fetch-Aufrufe durch zentralisierte Redux-Logik ersetzt
- store.js aktualisiert und neue States registriert
This commit is contained in:
ISA
2025-05-23 11:14:13 +02:00
parent 08679761fb
commit 0a1c0e5fbe
20 changed files with 304 additions and 337 deletions

View File

@@ -0,0 +1,33 @@
// /redux/slices/database/poiIconsDataSlice.js
import { createSlice } from "@reduxjs/toolkit";
import { fetchPoiIconsDataThunk } from "../../thunks/database/fetchPoiIconsDataThunk";
const initialState = {
data: [],
status: "idle",
error: null,
};
const poiIconsDataSlice = createSlice({
name: "poiIconsData",
initialState,
reducers: {},
extraReducers: (builder) => {
builder
.addCase(fetchPoiIconsDataThunk.pending, (state) => {
state.status = "loading";
})
.addCase(fetchPoiIconsDataThunk.fulfilled, (state, action) => {
state.status = "succeeded";
state.data = action.payload;
})
.addCase(fetchPoiIconsDataThunk.rejected, (state, action) => {
state.status = "failed";
state.error = action.payload;
});
},
});
export default poiIconsDataSlice.reducer;
export const selectPoiIconsData = (state) => state.poiIconsData.data;
export const selectPoiIconsStatus = (state) => state.poiIconsData.status;

View File

@@ -0,0 +1,33 @@
// /redux/slices/database/poiTypSlice.js
import { createSlice } from "@reduxjs/toolkit";
import { fetchPoiTypThunk } from "../../thunks/database/fetchPoiTypThunk";
const initialState = {
data: [],
status: "idle",
error: null,
};
const poiTypSlice = createSlice({
name: "poiTyp",
initialState,
reducers: {},
extraReducers: (builder) => {
builder
.addCase(fetchPoiTypThunk.pending, (state) => {
state.status = "loading";
})
.addCase(fetchPoiTypThunk.fulfilled, (state, action) => {
state.status = "succeeded";
state.data = action.payload;
})
.addCase(fetchPoiTypThunk.rejected, (state, action) => {
state.status = "failed";
state.error = action.payload;
});
},
});
export default poiTypSlice.reducer;
export const selectPoiTypData = (state) => state.poiTyp.data;
export const selectPoiTypStatus = (state) => state.poiTyp.status;