Skip to content

Commit

Permalink
feat(board): show air public code
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindgrutle committed May 24, 2024
1 parent 0063b1e commit 1d642a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { DeparturesContext } from '../../contexts'
import { TableColumn } from '../TableColumn'
import { TableRow } from '../TableRow'
import { TravelTag } from 'components/TravelTag'
import { getAirPublicCode } from 'utils/publicCode'

function Line() {
const departures = useNonNullContext(DeparturesContext)
Expand All @@ -13,6 +14,7 @@ function Line() {
departure.serviceJourney.transportSubmode ?? undefined,
publicCode: departure.serviceJourney.line.publicCode ?? '',
key: `${departure.serviceJourney.id}_${departure.aimedDepartureTime}`,
id: departure.serviceJourney.id ?? '',
}))

return (
Expand All @@ -23,7 +25,11 @@ function Line() {
<TravelTag
transportMode={line.transportMode}
transportSubmode={line.transportSubmode}
publicCode={line.publicCode}
publicCode={
line.transportMode === 'air'
? getAirPublicCode(line.id) ?? ''
: line.publicCode
}
/>
</div>
</TableRow>
Expand Down
5 changes: 5 additions & 0 deletions next-tavla/src/Shared/utils/publicCode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function getAirPublicCode(id: string) {
const regex = /AVI:ServiceJourney:([A-Z0-9]+)-\d{2}-\d+/
const match = id.match(regex)
return match ? match[1] : undefined
}

0 comments on commit 1d642a5

Please sign in to comment.