feat: redesign dashboard around place search

This commit is contained in:
zv
2026-06-01 19:05:31 +02:00
parent 6c2e731c60
commit 0632c67beb
18 changed files with 374 additions and 139 deletions

View File

@@ -2,12 +2,15 @@
import { create } from "zustand";
import { persist } from "zustand/middleware";
import type { SelectedLocation } from "@/types/location";
interface WeatherStore {
favorites: string[];
selectedStationId: string | null;
selectedLocation: SelectedLocation | null;
toggleFavorite: (id: string) => void;
selectStation: (id: string) => void;
selectLocation: (location: SelectedLocation) => void;
}
export const useWeatherStore = create<WeatherStore>()(
@@ -15,13 +18,15 @@ export const useWeatherStore = create<WeatherStore>()(
(set) => ({
favorites: [],
selectedStationId: null,
selectedLocation: null,
toggleFavorite: (id) =>
set((state) => ({
favorites: state.favorites.includes(id)
? state.favorites.filter((favoriteId) => favoriteId !== id)
: [...state.favorites, id],
})),
selectStation: (id) => set({ selectedStationId: id }),
selectStation: (id) => set({ selectedStationId: id, selectedLocation: null }),
selectLocation: (location) => set({ selectedStationId: location.stationId, selectedLocation: location }),
}),
{ name: "wtr:preferences" },
),