From 5fd6484a3780695bfa7fb33410421f18182b48ee Mon Sep 17 00:00:00 2001 From: Tsubasa SEKIGUCHI Date: Thu, 10 Oct 2024 19:33:47 +0900 Subject: [PATCH] =?UTF-8?q?=E6=99=AE=E9=80=9A/=E5=90=84=E5=81=9C=E3=81=A7?= =?UTF-8?q?=E7=B5=8C=E8=B7=AF=E9=81=B8=E6=8A=9E=E3=82=92=E7=A2=BA=E5=AE=9A?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84=E3=83=90=E3=82=B0=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/RouteList.tsx | 4 ++-- src/components/RouteListModal.tsx | 2 +- src/components/TrainTypeInfoModal.tsx | 6 +++--- src/screens/RouteSearchScreen.tsx | 14 ++++---------- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/components/RouteList.tsx b/src/components/RouteList.tsx index 58edc3677..6d2d0ad21 100644 --- a/src/components/RouteList.tsx +++ b/src/components/RouteList.tsx @@ -85,7 +85,7 @@ export const RouteList = ({ loading, }: { routes: Route[] - onSelect: (item: Route) => void + onSelect: (item: Route | undefined) => void loading: boolean }) => { const [trainTypeInfoModalVisible, setTrainTypeInfoModalVisible] = @@ -174,7 +174,7 @@ export const RouteList = ({ disabled={loading} stations={selectedRoute?.stops ?? []} onClose={() => setTrainTypeInfoModalVisible(false)} - onConfirmed={() => selectedRoute && onSelect(selectedRoute)} + onConfirmed={() => onSelect(selectedRoute)} /> ) diff --git a/src/components/RouteListModal.tsx b/src/components/RouteListModal.tsx index d63b0c86f..3a24548d3 100644 --- a/src/components/RouteListModal.tsx +++ b/src/components/RouteListModal.tsx @@ -25,7 +25,7 @@ type Props = { isTrainTypesLoading: boolean error: ConnectError | null onClose: () => void - onSelect: (route: Route) => void + onSelect: (route: Route | undefined) => void } const styles = StyleSheet.create({ diff --git a/src/components/TrainTypeInfoModal.tsx b/src/components/TrainTypeInfoModal.tsx index 23bac1d0a..3dafca6e0 100644 --- a/src/components/TrainTypeInfoModal.tsx +++ b/src/components/TrainTypeInfoModal.tsx @@ -25,7 +25,7 @@ type Props = { disabled?: boolean error: ConnectError | null onClose: () => void - onConfirmed: (trainType: TrainType) => void + onConfirmed: (trainType: TrainType | undefined) => void } const styles = StyleSheet.create({ @@ -223,8 +223,8 @@ export const TrainTypeInfoModal: React.FC = ({ diff --git a/src/screens/RouteSearchScreen.tsx b/src/screens/RouteSearchScreen.tsx index cb28e41eb..c58a38712 100644 --- a/src/screens/RouteSearchScreen.tsx +++ b/src/screens/RouteSearchScreen.tsx @@ -146,15 +146,9 @@ const RouteSearchScreen = () => { selectedLine: stationFromSearch.line ?? null, })) setSelectedStation(stationFromSearch) - - if (stationFromSearch.hasTrainTypes) { - setIsRouteListModalVisible(true) - return - } - - navigation.navigate('SelectBound') + setIsRouteListModalVisible(true) }, - [navigation, setLineState] + [setLineState] ) const onKeyPress = useCallback( @@ -174,8 +168,8 @@ const RouteSearchScreen = () => { ) const handleSelect = useCallback( - async (route: Route) => { - const trainType = route.stops.find( + async (route: Route | undefined) => { + const trainType = route?.stops.find( (s) => s.groupId === currentStation?.groupId )?.trainType