mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 13:36:48 +00:00
782e613506
- GPX files drop onto the map or a day; the import lands on that day - wanderer connection per user in Integrations; the workspace offers the user's own trails only, behind an admin switch under the Tours addon - wanderer difficulty is stored on the SAC scale (T1 to T3), backfilled - a GPX or wanderer import can be planned as an editable tour, either in place (the recorded track is kept and can be restored) or as a new tour that remembers the import it came from - rails, rows and detail dialog follow the plan sidebar's cards and badges - admin addon shelves with more than one row fold, collapsed by default - reverse-geocoded waypoint names are cached on the device
60 lines
1.3 KiB
TypeScript
60 lines
1.3 KiB
TypeScript
import { create } from 'zustand'
|
|
import { addonsApi } from '../api/client'
|
|
|
|
interface Addon {
|
|
id: string
|
|
name: string
|
|
description?: string
|
|
type: string
|
|
icon: string
|
|
enabled: boolean
|
|
config?: Record<string, unknown>
|
|
fields?: Array<{
|
|
key: string
|
|
label: string
|
|
input_type: string
|
|
placeholder?: string | null
|
|
required: boolean
|
|
secret: boolean
|
|
settings_key?: string | null
|
|
payload_key?: string | null
|
|
sort_order: number
|
|
}>
|
|
}
|
|
|
|
interface AddonState {
|
|
addons: Addon[]
|
|
bagTracking: boolean
|
|
/** Tours is on and the admin allows wanderer under it. */
|
|
toursWanderer: boolean
|
|
loaded: boolean
|
|
loadAddons: () => Promise<void>
|
|
isEnabled: (id: string) => boolean
|
|
}
|
|
|
|
export const useAddonStore = create<AddonState>((set, get) => ({
|
|
addons: [],
|
|
bagTracking: false,
|
|
toursWanderer: false,
|
|
loaded: false,
|
|
|
|
loadAddons: async () => {
|
|
try {
|
|
const data = await addonsApi.enabled()
|
|
set({ addons: data.addons || [], bagTracking: !!data.bagTracking,
|
|
toursWanderer: !!data.toursWanderer,
|
|
loaded: true,
|
|
})
|
|
} catch {
|
|
set({ loaded: true })
|
|
}
|
|
},
|
|
|
|
isEnabled: (id: string) => {
|
|
if (id === 'memories') {
|
|
return get().addons.some(a => a.type === 'photo_provider' && a.enabled)
|
|
}
|
|
return get().addons.some(a => a.id === id && a.enabled)
|
|
},
|
|
}))
|