import { Type } from 'lucide-react'; import { useTranslation } from '../../i18n'; import { useSettingsStore } from '../../store/settingsStore'; import { useToast } from '../shared/Toast'; import { MapTogglePill } from './MapTogglePill'; import { usePlaceNamesSetting } from './usePlaceNameLayout'; /** * Turns the place names beside the trip map's pins on and off (#2796). The choice is * the reader's own setting, so it holds on every trip and on the other device too. */ export function PlaceNamesPill() { const { t } = useTranslation(); const on = usePlaceNamesSetting(); const updateSetting = useSettingsStore((s) => s.updateSetting); const toast = useToast(); // The switch flips at once; a save that fails turns it back and says so. const toggle = async () => { try { await updateSetting('map_place_labels', !on); } catch (err) { useSettingsStore.setState((s) => ({ settings: { ...s.settings, map_place_labels: on } })); toast.error(err instanceof Error ? err.message : t('common.error')); } }; return ( { void toggle(); }} label={on ? t('map.placeNames.hide') : t('map.placeNames.show')} testId="place-names-pill" icon={} /> ); }