feat: build production-ready wtr weather PWA

This commit is contained in:
zv
2026-06-01 18:43:56 +02:00
commit 840555f4f5
60 changed files with 9052 additions and 0 deletions

28
lib/store.ts Normal file
View File

@@ -0,0 +1,28 @@
"use client";
import { create } from "zustand";
import { persist } from "zustand/middleware";
interface WeatherStore {
favorites: string[];
selectedStationId: string | null;
toggleFavorite: (id: string) => void;
selectStation: (id: string) => void;
}
export const useWeatherStore = create<WeatherStore>()(
persist(
(set) => ({
favorites: [],
selectedStationId: null,
toggleFavorite: (id) =>
set((state) => ({
favorites: state.favorites.includes(id)
? state.favorites.filter((favoriteId) => favoriteId !== id)
: [...state.favorites, id],
})),
selectStation: (id) => set({ selectedStationId: id }),
}),
{ name: "wtr:preferences" },
),
);