24 lines
738 B
TypeScript
24 lines
738 B
TypeScript
import { create } from 'zustand'
|
|
|
|
import type { Point } from '@/types/api'
|
|
|
|
type Nullable<T> = T | null
|
|
|
|
interface AppState {
|
|
userLocation: Nullable<Point>
|
|
locationError: Nullable<string>
|
|
isRequestingLocation: boolean
|
|
setUserLocation: (location: Nullable<Point>) => void
|
|
setLocationError: (error: Nullable<string>) => void
|
|
setIsRequestingLocation: (isRequesting: boolean) => void
|
|
}
|
|
|
|
export const useAppStore = create<AppState>((set) => ({
|
|
userLocation: null,
|
|
locationError: null,
|
|
isRequestingLocation: false,
|
|
setUserLocation: (userLocation) => set({ userLocation }),
|
|
setLocationError: (locationError) => set({ locationError }),
|
|
setIsRequestingLocation: (isRequestingLocation) => set({ isRequestingLocation }),
|
|
}))
|