import { Location } from '../FilterBarTypes' type Props = { selectedLocations: Location[] locationsPlaceholder: string locationsSelectedLabel?: string } export const parseLocations = ({ selectedLocations, locationsPlaceholder, locationsSelectedLabel = 'locations', }: Props) => { if (!selectedLocations.length) { return locationsPlaceholder } if (selectedLocations.length === 1) { const singleSelection = selectedLocations[0].label if (!singleSelection) { return locationsPlaceholder } return singleSelection } return `${selectedLocations.length} ${locationsSelectedLabel}` }