Skip to content

Commit

Permalink
fix(edit): remove duplicates of bus icon in dropdown and in tilecard (#…
Browse files Browse the repository at this point in the history
…1646)

* fix(edit): remove duplicates of bus icon in dropdown and in tilecard

* chore(edit): separate uniqTransportModes into own variable
  • Loading branch information
SelmaBergstrand authored Sep 12, 2024
1 parent e87597a commit 31211ea
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
8 changes: 5 additions & 3 deletions tavla/app/(admin)/edit/[id]/components/TileCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ function TileCard({
setDemoBoard && setDemoBoard({ ...demoBoard, tiles: remainingTiles })
}

const uniqTransportModeIcons = transportModes
.filter((tm) => !(tm === 'coach' && transportModes.includes('bus')))
.map((tm) => <TransportIcon transportMode={tm} key={tm} />)

return (
<div>
<div className="flex flex-row">
Expand All @@ -203,9 +207,7 @@ function TileCard({
{tile.displayName ?? tile.name}
</Heading3>
<div className="hidden sm:flex flex-row gap-4 h-8">
{transportModes.map((tm) => (
<TransportIcon transportMode={tm} key={tm} />
))}
{uniqTransportModeIcons}
</div>
</div>

Expand Down
3 changes: 2 additions & 1 deletion tavla/app/(admin)/utils/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { COUNTY_ENDPOINT, GEOCODER_ENDPOINT, CLIENT_NAME } from 'assets/env'
import { NormalizedDropdownItemType } from '@entur/dropdown'
import { TCategory, getIcons } from '../edit/utils'
import { TLocation } from 'types/meta'
import { uniq } from 'lodash'

type TPartialGeoResponse = {
features: Array<{
Expand Down Expand Up @@ -70,7 +71,7 @@ export async function fetchStopPlaces(
return data.features.map(({ properties }) => ({
value: properties.id ?? '',
label: properties.label || '',
icons: getIcons(properties.layer, properties.category),
icons: uniq(getIcons(properties.layer, properties.category)),
}))
})
}
Expand Down
15 changes: 0 additions & 15 deletions tavla/src/Shared/types/transport.d.ts

This file was deleted.

0 comments on commit 31211ea

Please sign in to comment.