diff --git a/components/AddPOIModal.js b/components/AddPOIModal.js index 8761216b1..fa1a07077 100644 --- a/components/AddPOIModal.js +++ b/components/AddPOIModal.js @@ -4,11 +4,14 @@ import ReactDOM from "react-dom"; import { useRecoilValue, useRecoilState, useSetRecoilState } from "recoil"; import { readPoiMarkersStore } from "../redux/slices/readPoiMarkersStoreSlice.js"; import { poiReadFromDbTriggerAtom } from "../redux/slices/poiReadFromDbTriggerSlice.js"; -import { useSelector } from "react-redux"; import { selectGisStationsStatic } from "../redux/slices/webService/gisStationsStaticSlice"; +import { useDispatch, useSelector } from "react-redux"; +import { fetchPoiTypes } from "../redux/slices/db/poiTypesSlice"; const ShowAddStationPopup = ({ onClose, map, latlng }) => { - const [poiTypData, setpoiTypData] = useState(); // Recoil State verwenden + const dispatch = useDispatch(); + const poiTypData = useSelector((state) => state.poiTypes.data); + const [name, setName] = useState(""); const [poiTypeId, setPoiTypeId] = useState(""); // Initialize as string const [poiTypeName, setPoiTypeName] = useState(""); // Initialize as string @@ -82,8 +85,16 @@ const ShowAddStationPopup = ({ onClose, map, latlng }) => { if (map && typeof map.closePopup === "function") { map.closePopup(); } + //Seite neu laden + window.location.reload(); }; - //-----------------handleSubmit------------------- + //----------------- + // POI-Typen aus Redux laden, wenn die Komponente gemountet wird + useEffect(() => { + dispatch(fetchPoiTypes()); + }, [dispatch]); + + //--------------------- return (
@@ -119,18 +130,16 @@ const ShowAddStationPopup = ({ onClose, map, latlng }) => { )}
-
diff --git a/config/appVersion.js b/config/appVersion.js index 60752fb05..25b7a96f2 100644 --- a/config/appVersion.js +++ b/config/appVersion.js @@ -1,2 +1,2 @@ // /config/appVersion -export const APP_VERSION = "1.1.35"; +export const APP_VERSION = "1.1.36"; diff --git a/redux/slices/db/poiTypesSlice.js b/redux/slices/db/poiTypesSlice.js new file mode 100644 index 000000000..9f3af2872 --- /dev/null +++ b/redux/slices/db/poiTypesSlice.js @@ -0,0 +1,29 @@ +// /redux/slices/db/poiTypesSlice.js +import { createSlice, createAsyncThunk } from "@reduxjs/toolkit"; + +// API-Abruf für POI-Typen +export const fetchPoiTypes = createAsyncThunk("poiTypes/fetchPoiTypes", async () => { + const response = await fetch("http://192.168.10.33:3000/api/talas_v5_DB/poiTyp/readPoiTyp"); + return await response.json(); +}); + +const poiTypesSlice = createSlice({ + name: "poiTypes", + initialState: { data: [], status: "idle" }, + reducers: {}, + extraReducers: (builder) => { + builder + .addCase(fetchPoiTypes.pending, (state) => { + state.status = "loading"; + }) + .addCase(fetchPoiTypes.fulfilled, (state, action) => { + state.data = action.payload; + state.status = "succeeded"; + }) + .addCase(fetchPoiTypes.rejected, (state) => { + state.status = "failed"; + }); + }, +}); + +export default poiTypesSlice.reducer; diff --git a/redux/store.js b/redux/store.js index 322e1007d..552457811 100644 --- a/redux/store.js +++ b/redux/store.js @@ -9,6 +9,7 @@ import gisStationsStatusDistrictReducer from "./slices/webService/gisStationsSta import gisStationsMeasurementsReducer from "./slices/webService/gisStationsMeasurementsSlice"; import gisSystemStaticReducer from "./slices/webService/gisSystemStaticSlice"; import gisStationsStaticReducer from "./slices/webService/gisStationsStaticSlice"; +import poiTypesReducer from "./slices/db/poiTypesSlice"; export const store = configureStore({ reducer: { @@ -21,5 +22,6 @@ export const store = configureStore({ gisStationsMeasurements: gisStationsMeasurementsReducer, gisSystemStatic: gisSystemStaticReducer, gisStationsStatic: gisStationsStaticReducer, + poiTypes: poiTypesReducer, }, });