Refactor: Reorganize state management into atoms and selectors directories

Moved all Recoil atoms to a new 'atoms' directory and selectors to a 'selectors' directory to clarify the project structure and improve maintainability. This change separates concerns by clearly distinguishing between simple state (atoms) and derived state (selectors), facilitating better understanding and scalability of the application's state management.
This commit is contained in:
ISA
2024-05-03 10:18:42 +02:00
parent 9b8361dba7
commit 39e5e1cb5a
12 changed files with 132 additions and 36 deletions

View File

@@ -1,7 +1,10 @@
// components/ShowAddStationPopup.js
import React, { useState, useEffect } from "react";
import ReactDOM from "react-dom";
import { useRecoilValue } from "recoil";
import { loadDataStore } from "../store/selectors/loadDataStore";
const ShowAddStationPopup = ({ map, latlng }) => {
const loadData = useRecoilValue(loadDataStore);
const [poiTypData2, setPoiTypData2] = useState(); // Recoil State verwenden
const [name, setName] = useState("");
const [poiTypeId, setPoiTypeId] = useState(""); // Initialize as string
@@ -29,7 +32,7 @@ const ShowAddStationPopup = ({ map, latlng }) => {
fetchPoiTypData2();
}, []);
const handleSubmit = (event) => {
const handleSubmit = async (event) => {
event.preventDefault();
const formData = {
name, // Name der Station
@@ -46,6 +49,7 @@ const ShowAddStationPopup = ({ map, latlng }) => {
.then((response) => response.json())
.then((data) => console.log(data)) // Handle the response data
.catch((error) => console.error(error)); // Handle any errors
await loadData();
// Check if map is not undefined and call closePopup
if (map && typeof map.closePopup === "function") {