fix(journey): sort the stay dates by a compare, make the hint pills real buttons and keep the walk's no-boats default a constant

This commit is contained in:
Maurice
2026-10-21 21:34:53 +02:00
parent 3101b36f3d
commit bb3c0151d5
5 changed files with 13 additions and 11 deletions
@@ -80,11 +80,11 @@ export function openStayDatesWithin(
byDate: Map<string, DawarichSuggestion[]>,
span: Array<string | null | undefined>
): string[] {
const bounds = span.filter((date): date is string => !!date).sort();
const bounds = span.filter((date): date is string => !!date).sort((a, b) => a.localeCompare(b));
const first = bounds[0];
const last = bounds[bounds.length - 1];
if (!first || !last) return [];
return [...byDate.keys()].filter((date) => date >= first && date <= last).sort();
return [...byDate.keys()].filter((date) => date >= first && date <= last).sort((a, b) => a.localeCompare(b));
}
/** `HH:MM` out of an ISO timestamp, in the offset the timestamp carries. */
@@ -261,9 +261,9 @@ export function JourneyDayImportActions({ state, onCancel }: { state: JourneyDay
<>
{state.skipCount > 0 && (
<Tooltip label={t('journey.dayImport.skipHint')} placement="top">
<span tabIndex={0} className="inline-flex">
<button type="button" className="inline-flex cursor-default">
<SoftPill>{t('journey.dayImport.skipped', { count: state.skipCount })}</SoftPill>
</span>
</button>
</Tooltip>
)}
<FooterSpacer />
@@ -17,9 +17,9 @@ type Props = { state: JourneyDayImportState; dayColor: string };
function Hinted({ label, children }: { label: string; children: ReactNode }) {
return (
<Tooltip label={label} placement="top">
<span tabIndex={0} className="inline-flex">
<button type="button" className="inline-flex cursor-default">
{children}
</span>
</button>
</Tooltip>
);
}
@@ -97,20 +97,20 @@ function RecordingFacts({ preview }: { preview: JourneyRecordingPreview }) {
<SoftPill>{t('journey.recording.pieces', { count: stats.segmentCount })}</SoftPill>
{stats.gapCount > 0 && (
<Tooltip label={t('journey.recording.gapsHint')} placement="top">
<span tabIndex={0} className="inline-flex">
<button type="button" className="inline-flex cursor-default">
<SoftPill tone="info">{t('journey.recording.gaps', { count: stats.gapCount })}</SoftPill>
</span>
</button>
</Tooltip>
)}
{stats.modes.map((mode) => (
<SoftPill key={mode}>{modeLabel(mode, t)}</SoftPill>
))}
<Tooltip label={t('journey.recording.sourceHint')} placement="top">
<span tabIndex={0} className="inline-flex">
<button type="button" className="inline-flex cursor-default">
<SoftPill>
{t(preview.sourceKind === 'tracks' ? 'journey.recording.sourceTracks' : 'journey.recording.sourcePoints')}
</SoftPill>
</span>
</button>
</Tooltip>
</div>
</div>
+3 -1
View File
@@ -333,6 +333,8 @@ export interface WalkBoats {
landings: Array<{ at: number; minutes: number | null }>;
}
const NO_BOATS: Readonly<WalkBoats> = { spans: [], landings: [] };
/** Each stop's share of the walk with the index of the route's point it is passed at. */
function walkedAlong(
stops: readonly WalkStop[],
@@ -381,7 +383,7 @@ export function stationArrivals(
route: readonly RoutePoint[],
start: number | null,
walkingMinutes: number | null,
boats: Readonly<WalkBoats> = { spans: [], landings: [] },
boats: Readonly<WalkBoats> = NO_BOATS,
): WalkArrival[] | null {
if (start === null || walkingMinutes === null) return null;
const walked = walkedAlong(stops, route, boats.spans);