import { Check, ExternalLink, MapPinPlus, MoveHorizontal, Route, X } from 'lucide-react'; import type { Ferrata } from '@trek/shared'; import { useTranslation } from '../../i18n'; import { useSettingsStore } from '../../store/settingsStore'; import { formatDistance } from '../../utils/units'; import { MAP_CARD_GLASS } from '../Map/mapControlShadow'; import { SoftPill } from '../Planner/planParts'; import { fs } from '../shared/DialogShell'; import { type FerrataGroup, ferrataLabel } from './ferrataGroups'; import { ferrataOsmUrl } from './ferrataModel'; /** * One via ferrata, picked on the map: its name, the route it belongs to, its * grade range and total length as badges, and the way back to the source. * `segment` is the OSM way that was clicked, which the source link opens. * OpenStreetMap's data is ODbL, which asks for the attribution next to * anything shown from it, so the card carries it rather than relying on the * map's own corner. */ export default function FerrataDetailCard({ group, segment, onClose, onAdopt, onTour = false, width, }: { group: FerrataGroup; segment: Ferrata; onClose?: () => void; /** Puts the ferrata onto the tour being planned; absent where the tour cannot be edited. */ onAdopt?: (group: FerrataGroup) => void; /** The tour on the map already climbs this ferrata: the card says so instead of offering it again. */ onTour?: boolean; /** Set when the card stands on another control and takes its width. */ width?: number; }) { const { t } = useTranslation(); const unit = useSettingsStore((s) => s.settings.distance_unit); const label = ferrataLabel(group, t); const name = label.name; // The route line only adds something when it is not already the title. const route = group.routeName && group.routeName !== name ? group.routeName : null; // Without any grade the badge says so, rather than leaving a gap. const grade = label.grade ?? t('ferratas.unknownGrade'); return (
{grade} {group.lengthM > 0 && ( )}
{onTour ? (
}> {t('ferratas.onTour')}
) : ( onAdopt && ( ) )} {t('ferratas.viewInOsm')}

{t('ferratas.attribution')}

); }