I need to redirect user on the screen with detailed data about PastMK or FutureMK,…
- User
I need to redirect user on the screen with detailed data about PastMK or FutureMK, depends on what the user found. i need it to be simple so i would understand. i already have screens with detailed info PastMK: import { Text, View, Image, ScrollView, Pressable} from 'react-native'; import { gStyle } from '../styles/style'; import Header from '../components/Header'; import Footer from '../components/Footer'; import { useNavigation } from '@react-navigation/native'; import moment from 'moment';
export default function PastMKInfo({route}) { const navigation = useNavigation(); const {mkData}=route.params; const handleGoBack=()=>{ navigation.goBack(); };
return ( {mkData.name} {new Intl.DateTimeFormat('ru-RU',{ day:'numeric', month:'long', year:'numeric' }).format(mkData.time.toDate())} {mkData.description} Назад ); }
FutureMK: import { Text, View, Image, Pressable, ScrollView } from 'react-native'; import { gStyle } from '../styles/style'; import React, {useState, useEffect} from 'react'; import Header from '../components/Header'; import Footer from '../components/Footer'; import { Ionicons, MaterialCommunityIcons } from '@expo/vector-icons'; import { useNavigation } from '@react-navigation/native'; import moment from 'moment'; import {firebase} from '../Firebase/firebase'; import 'firebase/compat/auth'; import 'firebase/compat/database'; import 'firebase/compat/firestore';
export default function SignUpForMK({route}) { const [userAuthenticated, setUserAuthenticated] = useState(false); useEffect(() => { const unsubscribe = firebase.auth().onAuthStateChanged(user => { if (user) { setUserAuthenticated(true); } else { setUserAuthenticated(false); } });
return unsubscribe; }, []); const {mkData}=route.params; const navigation = useNavigation(); const bookMK=()=>{ const currentUserID=firebase.auth().currentUser.uid; const bookedMKData={ name:mkData.name, time:mkData.time.toDate().toISOString(), image:mkData.image, price:mkData.price }; firebase .database() .ref(`users/${currentUserID}/bookedMK`) .push(bookedMKData) .then(()=>{ navigation.navigate('Profile'); }) }return ( {mkData.name} {new Intl.DateTimeFormat('ru-RU',{ day:'numeric', month:'long', year:'numeric', hour:'numeric', minute:'numeric', hour12:false }).format(mkData.time.toDate())} Цена: {mkData.price} Р. {mkData.description} {mkData.person} человек {mkData.timeOfMK} час(а) {userAuthenticated ? Забронировать : <Pressable style={gStyle.SupMoreDetails} onPress={()=>navigation.navigate('Auth')} > Забронировать }
</View> </View> </View> <Footer/> </ScrollView> </View>); }
its the component from where the user must be redirected: import { Text, View, Image, Pressable } from 'react-native'; import { gStyle } from '../styles/style'; import React from 'react';
- Assistant
- User
- Assistant