Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tile): add lines to TileSelector #1554

Merged
merged 4 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions next-tavla/app/(admin)/hooks/useQuaySearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,29 @@ import { useCallback, useEffect, useMemo, useState } from 'react'
import { countBy } from 'lodash'
import { getTransportIcon } from 'components/TransportIcon'
import { useQuery } from 'hooks/useQuery'
import { TLineFragment } from '../edit/[id]/components/TileCard/types'

function getPlatformLabel(
index: number,
publicCode?: string | null,
description?: string | null,
directionTypes?: (TDirectionType | null | undefined)[] | null,
lines?: TLineFragment[] | null,
) {
const lineInformation = lines
?.map((line) => line.publicCode)
.slice(0, 5)
emilielr marked this conversation as resolved.
Show resolved Hide resolved
.sort()
.join(', ')

if (!publicCode && !description) {
return `${index + 1} ${getDirection(directionTypes)}`
return `${index + 1} ${getDirection(
directionTypes,
)} (${lineInformation})`
}
return [publicCode, description].filter(isNotNullOrUndefined).join(' ')
return [publicCode, description, `(${lineInformation})`]
.filter(isNotNullOrUndefined)
.join(' ')
}

function getDirection(
Expand Down Expand Up @@ -52,6 +64,7 @@ function useQuaySearch(stopPlaceId: string) {
quay.publicCode,
quay.description,
quay.journeyPatterns.map((jp) => jp?.directionType),
quay.lines,
),
icons: quay.stopPlace?.transportMode?.map((mode) =>
getTransportIcon(mode ?? 'unknown'),
Expand Down
17 changes: 16 additions & 1 deletion next-tavla/src/Shared/graphql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ export type TQuaysSearchQuery = {
__typename?: 'JourneyPattern'
directionType: Types.TDirectionType | null
} | null>
lines: Array<{
__typename?: 'Line'
id: string
publicCode: string | null
name: string | null
transportMode: Types.TTransportMode | null
}>
} | null> | null
} | null
}
Expand Down Expand Up @@ -557,10 +564,18 @@ export const QuaysSearchQuery = new TypedDocumentString(`
journeyPatterns {
directionType
}
...lines
}
}
}
`) as unknown as TypedDocumentString<
fragment lines on Quay {
lines {
id
publicCode
name
transportMode
}
}`) as unknown as TypedDocumentString<
TQuaysSearchQuery,
TQuaysSearchQueryVariables
>
Expand Down
1 change: 1 addition & 0 deletions next-tavla/src/Shared/graphql/queries/quaySearch.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ query quaysSearch($stopPlaceId: String!) {
journeyPatterns {
directionType
}
...lines
}
}
}