Browse Source

Podemos desplegar el chat indicado en el screen de cita. Se le esta pasando el id del appointment al screen de cita y se trae el chat de firestore que tanga como valor de cita ese id.

ErnestoOrtiz2 3 years ago
parent
commit
21c0b885cc
2 changed files with 34 additions and 7 deletions
  1. 31
    6
      screens/main/Cita.js
  2. 3
    1
      screens/main/Home_page.js

+ 31
- 6
screens/main/Cita.js View File

13
 import { fetchUser } from '../../redux/actions/index'
13
 import { fetchUser } from '../../redux/actions/index'
14
 
14
 
15
 
15
 
16
-export function Cita({navigation, route}) {
17
-   /*const [threads, setThreads] = useState([]);  
18
-    const [loading, setLoading] = useState(true);
19
-  useEffect(() => { 
16
+export function Cita({route, navigation}) {
17
+   const [threads, setThreads] = useState([]);  
18
+   const [loading, setLoading] = useState(true);
19
+   console.log("ID", route.params);
20
+
21
+
22
+
23
+ useEffect(() => { 
20
     const fire = firebase.firestore()
24
     const fire = firebase.firestore()
21
     .collection('THREADS')
25
     .collection('THREADS')
22
-    .where("cita", "==", route.params.appointment_id)
26
+    .where("cita", "==", route.params)
23
     .onSnapshot(querySnapshot => {
27
     .onSnapshot(querySnapshot => {
24
       const threads = querySnapshot.docs.map(documentSnapshot => {
28
       const threads = querySnapshot.docs.map(documentSnapshot => {
25
         return{
29
         return{
40
     return () => {
44
     return () => {
41
       fire();
45
       fire();
42
     }
46
     }
43
-  }, []);*/
47
+  }, []);
44
     
48
     
45
     
49
     
46
     
50
     
53
   
57
   
54
   return (
58
   return (
55
       <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
59
       <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
60
+        <FlatList style={{
61
+             flex: 1,
62
+             width: screenWidth,
63
+         }}
64
+          data={threads}
65
+          keyExtractor = {item => item._id}
66
+          ItemSeparatorComponent={() => <Divider />}
67
+          renderItem = {({item}) => (
68
+          <TouchableOpacity
69
+            onPress={() => navigation.navigate('Room', {thread: item})}
70
+          >
71
+            <List.Item
72
+              title={item.name}
73
+              titleNumberOfLines={1}
74
+              titleStyle={styles.listTitle}
75
+              descriptionStyle={styles.listDescription}
76
+              descriptionNumberOfLines={1}
77
+            />
78
+          </TouchableOpacity>
79
+        )}
80
+        />
56
       <Button
81
       <Button
57
         title ='Ver mapa'
82
         title ='Ver mapa'
58
         onPress= {() => navigation.navigate('Map')}
83
         onPress= {() => navigation.navigate('Map')}

+ 3
- 1
screens/main/Home_page.js View File

143
         renderItem = {({item}) => (
143
         renderItem = {({item}) => (
144
         <TouchableOpacity
144
         <TouchableOpacity
145
         onPress={async () => {
145
         onPress={async () => {
146
+          console.log(item._id)
146
           navigation.navigate('Cita', {appointment_id: item._id})
147
           navigation.navigate('Cita', {appointment_id: item._id})
147
         }}
148
         }}
148
         >
149
         >
214
           renderItem = {({item}) => (
215
           renderItem = {({item}) => (
215
           <TouchableOpacity
216
           <TouchableOpacity
216
           onPress={async () => {
217
           onPress={async () => {
217
-            navigation.navigate('Cita')
218
+            console.log(item._id)
219
+            navigation.navigate('Cita',{tag: item})
218
           }}
220
           }}
219
           >
221
           >
220
             <List.Item
222
             <List.Item