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 2 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,13 +13,17 @@ import { bindActionCreators } from 'redux'
13 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 24
     const fire = firebase.firestore()
21 25
     .collection('THREADS')
22
-    .where("cita", "==", route.params.appointment_id)
26
+    .where("cita", "==", route.params)
23 27
     .onSnapshot(querySnapshot => {
24 28
       const threads = querySnapshot.docs.map(documentSnapshot => {
25 29
         return{
@@ -40,7 +44,7 @@ export function Cita({navigation, route}) {
40 44
     return () => {
41 45
       fire();
42 46
     }
43
-  }, []);*/
47
+  }, []);
44 48
     
45 49
     
46 50
     
@@ -53,6 +57,27 @@ export function Cita({navigation, route}) {
53 57
   
54 58
   return (
55 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 81
       <Button
57 82
         title ='Ver mapa'
58 83
         onPress= {() => navigation.navigate('Map')}

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

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