Files
CityExplorer/store.jsx
2025-04-22 19:13:59 +02:00

22 lines
661 B
JavaScript

import { create } from 'zustand';
import { locations as initialLocations } from '@/data/locations';
const useLocationStore = create((set) => ({
locations: initialLocations,
addLocation: (newLocation) =>
set((state) => ({
locations: [newLocation, ...state.locations],
})),
updateLocation: (id, updatedData) =>
set((state) => ({
locations: state.locations.map((loc) =>
loc.id == id ? { ...loc, ...updatedData } : loc
),
})),
deleteLocation: (id) =>
set((state) => ({
locations: state.locations.filter((loc) => loc.id != id),
})),
}));
export default useLocationStore;