From bfc6069a87750070db9dab36c848356db401416c Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Thu, 12 Dec 2024 15:38:47 +0100 Subject: [PATCH] =?UTF-8?q?On=20ne=20r=C3=A9cup=C3=A8re=20que=20ses=20prop?= =?UTF-8?q?res=20trains=20emprunt=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/app/(tabs)/train.tsx | 5 +++-- client/components/GameProvider.tsx | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/client/app/(tabs)/train.tsx b/client/app/(tabs)/train.tsx index 31d7857..d3339e5 100644 --- a/client/app/(tabs)/train.tsx +++ b/client/app/(tabs)/train.tsx @@ -5,7 +5,7 @@ import { TrainTrip } from '@/utils/features/train/trainSlice' import { FontAwesome6 } from '@expo/vector-icons' import { useMemo, useState } from 'react' import { FlatList, StyleSheet } from 'react-native' -import { Badge, Button, Dialog, Divider, FAB, HelperText, List, Portal, Surface, Text, TextInput } from 'react-native-paper' +import { Button, Dialog, Divider, FAB, HelperText, List, Portal, Surface, Text, TextInput } from 'react-native-paper' export default function TrainScreen() { const [addTrainVisible, setAddTrainVisible] = useState(false) @@ -24,6 +24,8 @@ export default function TrainScreen() { train.id} + ItemSeparatorComponent={() => } renderItem={(item) => } /> Durée : {duration}, distance : {distanceKm} km, coût : {cost} } /> - } diff --git a/client/components/GameProvider.tsx b/client/components/GameProvider.tsx index 7a95079..4b3a432 100644 --- a/client/components/GameProvider.tsx +++ b/client/components/GameProvider.tsx @@ -39,11 +39,11 @@ export default function GameProvider({ children }: { children: ReactNode }) { }, [playerQuery.status, playerQuery.dataUpdatedAt]) const trainsQuery = useQuery({ - queryKey: ['get-trains', auth.token], - queryFn: () => fetch(`${process.env.EXPO_PUBLIC_TRAINTRAPE_MOI_SERVER}/trains/`, { + queryKey: ['get-trains', game.playerId, auth.token], + queryFn: () => fetch(`${process.env.EXPO_PUBLIC_TRAINTRAPE_MOI_SERVER}/trains/?playerId=${game.playerId}`, { headers: { "Authorization": `Bearer ${auth.token}` }} ).then(resp => resp.json()), - enabled: isAuthValid(auth), + enabled: isAuthValid(auth) && !game.playerId, refetchInterval: 5000, }) useEffect(() => {