feat: add configurable wind units
This commit is contained in:
@@ -4,6 +4,8 @@ import { create } from "zustand";
|
||||
import { persist } from "zustand/middleware";
|
||||
import type { SelectedLocation } from "@/types/location";
|
||||
import type { Province } from "@/types/province";
|
||||
import type { WindSpeedUnit } from "@/types/units";
|
||||
import { DEFAULT_WIND_SPEED_UNIT } from "@/lib/weather-utils";
|
||||
|
||||
type NotificationProvinceMode = "selected" | "manual";
|
||||
|
||||
@@ -16,6 +18,7 @@ interface WeatherStore {
|
||||
tomorrowBriefNotificationsEnabled: boolean;
|
||||
warningNotificationProvinceMode: NotificationProvinceMode;
|
||||
warningNotificationProvince: Province | null;
|
||||
windSpeedUnit: WindSpeedUnit;
|
||||
toggleFavorite: (id: string) => void;
|
||||
selectStation: (id: string) => void;
|
||||
selectLocation: (location: SelectedLocation) => void;
|
||||
@@ -24,6 +27,7 @@ interface WeatherStore {
|
||||
setTomorrowBriefNotificationsEnabled: (enabled: boolean) => void;
|
||||
setWarningNotificationProvinceMode: (mode: NotificationProvinceMode) => void;
|
||||
setWarningNotificationProvince: (province: Province | null) => void;
|
||||
setWindSpeedUnit: (unit: WindSpeedUnit) => void;
|
||||
}
|
||||
|
||||
export const useWeatherStore = create<WeatherStore>()(
|
||||
@@ -37,6 +41,7 @@ export const useWeatherStore = create<WeatherStore>()(
|
||||
tomorrowBriefNotificationsEnabled: false,
|
||||
warningNotificationProvinceMode: "selected",
|
||||
warningNotificationProvince: null,
|
||||
windSpeedUnit: DEFAULT_WIND_SPEED_UNIT,
|
||||
toggleFavorite: (id) =>
|
||||
set((state) => ({
|
||||
favorites: state.favorites.includes(id)
|
||||
@@ -50,6 +55,7 @@ export const useWeatherStore = create<WeatherStore>()(
|
||||
setTomorrowBriefNotificationsEnabled: (enabled) => set({ tomorrowBriefNotificationsEnabled: enabled }),
|
||||
setWarningNotificationProvinceMode: (mode) => set({ warningNotificationProvinceMode: mode }),
|
||||
setWarningNotificationProvince: (province) => set({ warningNotificationProvince: province }),
|
||||
setWindSpeedUnit: (unit) => set({ windSpeedUnit: unit }),
|
||||
}),
|
||||
{ name: "wtr:preferences" },
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user