Skip to content

Commit

Permalink
feat(board): adds via destination column for departures (#1093)
Browse files Browse the repository at this point in the history
* feat(graphql): adds via destination to queried data

* feat(board): adds via column to table view and edit

* fix(via): better coverage for diff arrays fetched from api

* refactor(via): simplifies stringify via destinations

* chore(via): removes redundant styles
  • Loading branch information
stianjsu authored Jul 4, 2023
1 parent a8050f1 commit 23236fa
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions next-tavla/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const config: CodegenConfig = {
},
},
generates: {
'src/types/graphql-schema.ts': {
'src/Shared/types/graphql-schema.ts': {
plugins: ['typescript'],
},
'src/graphql/index.ts': {
'src/Shared/graphql/index.ts': {
preset: 'import-types',
presetConfig: {
typesPath: 'types/graphql-schema',
Expand Down
15 changes: 15 additions & 0 deletions next-tavla/src/Board/scenarios/Table/components/Via/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { useNonNullContext } from 'hooks/useNonNullContext'
import { DepartureContext } from 'Board/scenarios/Table/contexts'
import { isNotNullOrUndefined } from 'utils/typeguards'

function Via() {
const departure = useNonNullContext(DepartureContext)

const viaDestinations = departure.destinationDisplay?.via
?.filter(isNotNullOrUndefined)
.join(', ')

return <td>{viaDestinations}</td>
}

export { Via }
2 changes: 2 additions & 0 deletions next-tavla/src/Board/scenarios/Table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import { Destination } from './components/Destination'
import { Line } from './components/Line'
import { Platform } from './components/Platform'
import { Situations } from './components/Situations'
import { Via } from './components/Via'

const columnComponents: Record<TColumn, () => JSX.Element> = {
destination: Destination,
line: Line,
time: Time,
platform: Platform,
via: Via,
situations: Situations,
}

Expand Down
1 change: 1 addition & 0 deletions next-tavla/src/Shared/graphql/fragments/departure.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ fragment departure on EstimatedCall {
}
destinationDisplay {
frontText
via
}
aimedDepartureTime
expectedDepartureTime
Expand Down
6 changes: 6 additions & 0 deletions next-tavla/src/Shared/graphql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type TDepartureFragment = {
destinationDisplay: {
__typename?: 'DestinationDisplay'
frontText: string | null
via: Array<string | null> | null
} | null
serviceJourney: {
__typename?: 'ServiceJourney'
Expand Down Expand Up @@ -96,6 +97,7 @@ export type TGetQuayQuery = {
destinationDisplay: {
__typename?: 'DestinationDisplay'
frontText: string | null
via: Array<string | null> | null
} | null
serviceJourney: {
__typename?: 'ServiceJourney'
Expand Down Expand Up @@ -179,6 +181,7 @@ export type TStopPlaceQuery = {
destinationDisplay: {
__typename?: 'DestinationDisplay'
frontText: string | null
via: Array<string | null> | null
} | null
serviceJourney: {
__typename?: 'ServiceJourney'
Expand Down Expand Up @@ -273,6 +276,7 @@ export const DepartureFragment = new TypedDocumentString(
}
destinationDisplay {
frontText
via
}
aimedDepartureTime
expectedDepartureTime
Expand Down Expand Up @@ -341,6 +345,7 @@ export const GetQuayQuery = new TypedDocumentString(`
}
destinationDisplay {
frontText
via
}
aimedDepartureTime
expectedDepartureTime
Expand Down Expand Up @@ -413,6 +418,7 @@ export const StopPlaceQuery = new TypedDocumentString(`
}
destinationDisplay {
frontText
via
}
aimedDepartureTime
expectedDepartureTime
Expand Down
1 change: 1 addition & 0 deletions next-tavla/src/Shared/types/tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const Columns = {
platform: 'Plattform',
time: 'Avgangstid',
situations: 'Avvik',
via: 'Via',
} as const

export type TColumn = keyof typeof Columns
Expand Down

0 comments on commit 23236fa

Please sign in to comment.