import { useAddTrainMutation } from '@/hooks/mutations/useTrainMutation' import { useAuth } from '@/hooks/useAuth' import { useMemo, useState } from 'react' import { StyleSheet } from 'react-native' import { Button, Dialog, FAB, HelperText, Portal, Surface, Text, TextInput } from 'react-native-paper' export default function TrainScreen() { const [addTrainVisible, setAddTrainVisible] = useState(false) const [addTrainUrl, setAddTrainUrl] = useState("") const trainId = useMemo(() => /[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}/.exec(addTrainUrl)?.[0], [addTrainUrl]) const auth = useAuth() const addTrainMutation = useAddTrainMutation({ auth, onPostSuccess: () => setAddTrainVisible(false) }) return ( Ici on aura la page pour ajouter un trajet en train depuis Rail Planner setAddTrainVisible(true)} /> setAddTrainVisible(false)}> Ajout d'un train { if (trainId !== undefined) addTrainMutation.mutate(trainId) }} placeholder="https://eurailapp.com/share/journey?id=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&type=list&brand=interrail" /> Le champ doit contenir l'identifiant d'un voyage au format UUID. {trainId} ) } const styles = StyleSheet.create({ addTrainButton: { position: 'absolute', right: 25, bottom: 25, } })