Skip to content

Commit

Permalink
Add GeocoderResultsConstants and clean up results headers
Browse files Browse the repository at this point in the history
  • Loading branch information
amy-corson-ibigroup committed Oct 3, 2024
1 parent 39cc6e7 commit e2b352e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
37 changes: 25 additions & 12 deletions packages/location-field/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { LocationFieldProps, ResultType } from "./types";
import {
addInParentheses,
generateLabel,
GeocoderResultsConstants,
getCombinedLabel,
getGeocoderErrorMessage,
getMatchingLocations
Expand Down Expand Up @@ -648,20 +649,17 @@ const LocationField = ({
const FeaturesElements = ({
bgColor,
title,
title118nId,
HeaderMessage,
featuresArray
}: {
bgColor: string;
title: string;
title118nId: string;
HeaderMessage: JSX.Element;
featuresArray: JSX.Element[];
}) => {
const Header = () => (
<S.MenuGroupHeader as={headingType} bgColor={bgColor} key={title}>
<FormattedMessage
description="Text for header above the 'other' category of geocoder results"
id={title118nId}
/>
{HeaderMessage}
</S.MenuGroupHeader>
);
return (
Expand All @@ -677,36 +675,51 @@ const LocationField = ({
const featuresElementsArray = geocoderResultsOrder.map(result => {
let Element;
switch (result) {
case "OTHER":
case GeocoderResultsConstants.OTHER:
Element = (
<FeaturesElements
bgColor="#333"
HeaderMessage={
<FormattedMessage
id="otpUi.LocationField.other"
description="Text for header above the 'other' category of geocoder results"
/>
}
key="other-header"
featuresArray={otherFeatures}
title="other"
title118nId="otpUi.LocationField.other"
/>
);
break;
case "STATIONS":
case GeocoderResultsConstants.STATIONS:
Element = (
<FeaturesElements
bgColor={layerColorMap.stations}
HeaderMessage={
<FormattedMessage
id="otpUi.LocationField.stations"
description="Text for header above the 'stations' category of geocoder results"
/>
}
key="gtfs-stations-header"
featuresArray={stationFeatures}
title="stations"
title118nId="otpUi.LocationField.stations"
/>
);
break;
case "STOPS":
case GeocoderResultsConstants.STOPS:
Element = (
<FeaturesElements
bgColor={layerColorMap.stops}
HeaderMessage={
<FormattedMessage
id="otpUi.LocationField.stops"
description="Text for header above the 'stops' category of geocoder results"
/>
}
key="gtfs-stops-header"
featuresArray={stopFeatures}
title="stops"
title118nId="otpUi.LocationField.stops"
/>
);
break;
Expand Down
6 changes: 6 additions & 0 deletions packages/location-field/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,9 @@ export function getMatchingLocations(

return [];
}

export const GeocoderResultsConstants = {
STATIONS: "STATIONS",
STOPS: "STOPS",
OTHER: "OTHER"
};

0 comments on commit e2b352e

Please sign in to comment.