mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-21 06:26:26 +00:00
8fd46c4c18
Small requests from the discussions, each built end to end: planner and map (cycling mode, date first headings, clear a day, stay times per day, off-route stops, map lock, compact unplanned markers, pending stays, cable car, transit quick picks), places (location filter, category from OSM, open in maps, geo: link, image from an attachment, enrichment on file import, places near a pin, place name language, Amap first in China), lists and costs (packed counter, inherited sharing, Markdown to-dos, payment notes, bookings CSV, my plan PDF), sharing (unplanned places, travel only, without photos), journey (photo zoom, drafts, photo order, trip suggestion, day jump), atlas (region counter, region bucket list, places per country), vacay half company holidays, studio copy and paste plus the book's own layouts, and RESTORE_FROM_BACKUP for a first start restore.
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import { useMemo } from 'react'
|
|
import { Bike, Car, Footprints, Zap, type LucideIcon } from 'lucide-react'
|
|
import { useTranslation } from '../../i18n'
|
|
import { usePluginStore } from '../../store/pluginStore'
|
|
|
|
export interface RouteModeOption {
|
|
key: string
|
|
label: string
|
|
}
|
|
|
|
/** The icon a route profile key is drawn with, wherever a leg or a day names its mode. */
|
|
export function routeModeIcon(mode: string | null | undefined): LucideIcon {
|
|
if (mode === 'walking') return Footprints
|
|
if (mode === 'cycling') return Bike
|
|
if (mode?.startsWith('plugin:')) return Zap
|
|
return Car
|
|
}
|
|
|
|
/**
|
|
* Every mode a day or a single leg can be given: the three built-in profiles plus
|
|
* each profile a granted routeProvider plugin declared, keyed 'plugin:<id>/<profile>'
|
|
* and labeled by the plugin's manifest.
|
|
*/
|
|
export function useRouteModeOptions(): RouteModeOption[] {
|
|
const { t } = useTranslation()
|
|
const activePlugins = usePluginStore(s => s.plugins)
|
|
return useMemo(() => {
|
|
const opts: RouteModeOption[] = [
|
|
{ key: 'driving', label: t('mobileTrip.profileDriving') },
|
|
{ key: 'walking', label: t('mobileTrip.profileWalking') },
|
|
{ key: 'cycling', label: t('mobileTrip.profileCycling') },
|
|
]
|
|
for (const p of activePlugins) {
|
|
for (const prof of p.routeProfiles ?? []) opts.push({ key: `plugin:${p.id}/${prof.id}`, label: prof.label })
|
|
}
|
|
return opts
|
|
}, [activePlugins, t])
|
|
}
|