diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c574c97b..193bdaa93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,37 @@ Alle bedeutenden Änderungen an diesem Projekt werden in dieser Datei dokumentie --- +[1.1.180] – 2025-05-26 +♻️ Refactor +poiTypesSlice.js wurde bereinigt: + +Alte createAsyncThunk-Definition entfernt (direkter fetch im Slice) + +Stattdessen Verwendung des ausgelagerten Thunks fetchPoiTypThunk aus fetchPoiTypThunk.js + +Einheitliche Architektur umgesetzt: + +Service → Thunk → Slice + +Keine Logik mehr im Slice selbst + +Verwendete Komponenten (MapComponent, AddPOIModal) rufen jetzt korrekt dispatch(fetchPoiTypThunk()) auf + +🐞 Fixed +Fehler fetchPoiTypes is not a function behoben durch Entfernen des alten Imports aus poiTypesSlice + +Richtiger Import fetchPoiTypThunk nun überall verwendet + +🧠 Architektur +Redux-Slice enthält nur noch Zustand & Status – keine Abfragen mehr + +fetchPoiTypService.js stellt fetch()-Logik bereit, Thunk übernimmt Fehlerbehandlung + +🔧 Version +📦 Version erhöht auf 1.1.180 + +--- + [1.1.177] – 2025-05-26 ✨ UI-Verbesserung POI-Tooltip auf der Karte wird jetzt bei Mouseover angezeigt (nicht mehr per Klick). diff --git a/components/mainComponent/MapComponent.js b/components/mainComponent/MapComponent.js index 7105f551c..4746ce414 100644 --- a/components/mainComponent/MapComponent.js +++ b/components/mainComponent/MapComponent.js @@ -42,7 +42,6 @@ import { useSelector, useDispatch } from "react-redux"; import { setSelectedPoi } from "../../redux/slices/database/pois/selectedPoiSlice.js"; import { setDisabled } from "../../redux/slices/database/polylines/polylineEventsDisabledSlice.js"; import { setMapId, setUserId } from "../../redux/slices/urlParameterSlice"; -import { fetchPoiTypes } from "../../redux/slices/database/pois/poiTypesSlice.js"; import { selectMapLayersState } from "../../redux/slices/mapLayersSlice"; import { setCurrentPoi } from "../../redux/slices/database/pois/currentPoiSlice.js"; import { selectGisLines } from "../../redux/slices/database/polylines/gisLinesSlice"; @@ -809,7 +808,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { //---------------------------------------------------- useEffect(() => { if (poiTypStatus === "idle") { - dispatch(fetchPoiTypes()); + dispatch(fetchPoiTypThunk()); } }, [poiTypStatus, dispatch]); diff --git a/components/pois/AddPOIModal.js b/components/pois/AddPOIModal.js index a21f9f52e..3631cbacb 100644 --- a/components/pois/AddPOIModal.js +++ b/components/pois/AddPOIModal.js @@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react"; import { useDispatch, useSelector } from "react-redux"; import { selectGisStationsStaticDistrict } from "../../redux/slices/webservice/gisStationsStaticDistrictSlice"; -import { fetchPoiTypes } from "../../redux/slices/database/pois/poiTypesSlice"; +import { fetchPoiTypThunk } from "../../redux/thunks/database/pois/fetchPoiTypThunk"; import { incrementTrigger } from "../../redux/slices/database/pois/poiReadFromDbTriggerSlice"; import { addPoiThunk } from "../../redux/thunks/database/pois/addPoiThunk"; import { resetAddPoiStatus } from "../../redux/slices/database/pois/addPoiSlice"; @@ -38,7 +38,7 @@ const AddPOIModal = ({ onClose, map, latlng }) => { }, [locationDeviceData]); useEffect(() => { - dispatch(fetchPoiTypes()); + dispatch(fetchPoiTypThunk()); }, [dispatch]); const handleSubmit = async (event) => { diff --git a/config/appVersion.js b/config/appVersion.js index 552d79b92..6e1c2097a 100644 --- a/config/appVersion.js +++ b/config/appVersion.js @@ -1,2 +1,2 @@ // /config/appVersion -export const APP_VERSION = "1.1.180"; +export const APP_VERSION = "1.1.181"; diff --git a/redux/slices/database/pois/poiTypesSlice.js b/redux/slices/database/pois/poiTypesSlice.js index 338203d06..8156e1ffc 100644 --- a/redux/slices/database/pois/poiTypesSlice.js +++ b/redux/slices/database/pois/poiTypesSlice.js @@ -1,37 +1,27 @@ // /redux/slices/database/pois/poiTypesSlice.js -import { createSlice, createAsyncThunk } from "@reduxjs/toolkit"; - -// API-Abruf für POI-Typen -export const fetchPoiTypes = createAsyncThunk("poiTypes/fetchPoiTypes", async () => { - let API_BASE_URL = ""; - - if (typeof window !== "undefined") { - // Browser - API_BASE_URL = `${window.location.protocol}//${window.location.hostname}:3000`; - } else { - // Server (z. B. SSR) - API_BASE_URL = "http://localhost:3000"; // oder env-Fallback z. B. process.env.API_BASE_URL - } - - const response = await fetch(`${API_BASE_URL}/api/talas_v5_DB/poiTyp/readPoiTyp`); - return await response.json(); -}); +import { createSlice } from "@reduxjs/toolkit"; +import { fetchPoiTypThunk } from "../../../thunks/database/pois/fetchPoiTypThunk"; const poiTypesSlice = createSlice({ name: "poiTypes", - initialState: { data: [], status: "idle" }, + initialState: { + data: [], + status: "idle", + error: null, + }, reducers: {}, extraReducers: (builder) => { builder - .addCase(fetchPoiTypes.pending, (state) => { + .addCase(fetchPoiTypThunk.pending, (state) => { state.status = "loading"; }) - .addCase(fetchPoiTypes.fulfilled, (state, action) => { + .addCase(fetchPoiTypThunk.fulfilled, (state, action) => { state.data = action.payload; state.status = "succeeded"; }) - .addCase(fetchPoiTypes.rejected, (state) => { + .addCase(fetchPoiTypThunk.rejected, (state, action) => { state.status = "failed"; + state.error = action.payload || "Unbekannter Fehler"; }); }, });