From a9b296efa1fe6862c5797eca45421e4a09e2f402 Mon Sep 17 00:00:00 2001 From: David Wheatley Date: Sun, 22 Sep 2024 22:24:33 +0100 Subject: [PATCH] feat: allow enter to submit rtt url --- src/components/ImportStateFromRtt.tsx | 5 +++++ src/data/RttUtils.ts | 14 ++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/components/ImportStateFromRtt.tsx b/src/components/ImportStateFromRtt.tsx index 9b2ff726b..f42b54f40 100644 --- a/src/components/ImportStateFromRtt.tsx +++ b/src/components/ImportStateFromRtt.tsx @@ -255,6 +255,11 @@ export default function ImportStateFromRtt({ importStateFromRttService, disabled required value={rttUri} onChange={e => setRttUri(e.target.value)} + onKeyDown={e => { + if (e.key === 'Enter') { + importService() + } + }} /> )} diff --git a/src/data/RttUtils.ts b/src/data/RttUtils.ts index fee2c4b50..453c048ca 100644 --- a/src/data/RttUtils.ts +++ b/src/data/RttUtils.ts @@ -33,12 +33,14 @@ export class RttUtils { if (i === arr.length - 1 && l.destination.some(d => d.tiploc === l.tiploc)) return false return true }) - .map(l => ({ - ...stationItemCompleter(l.crs!), - rttPlatform: l.platform ?? null, - arrLateness: l.realtimeGbttArrivalLateness ?? null, - depLateness: l.realtimeGbttDepartureLateness ?? null, - })) + .map(l => { + return { + ...stationItemCompleter(l.crs!), + rttPlatform: l.platform ?? null, + arrLateness: l.realtimeGbttArrivalLateness ?? null, + depLateness: l.realtimeGbttDepartureLateness ?? null, + } + }) } static getEligibleLocations(rttService: RttResponse): CallingAtPointWithRttDetail[] {