ソースを参照

Se añadió un campo a los appointments desde el home_page con la funcion citaId, esto permite desplegar la informacion de la cita en el screen Cita.js usando el mismo parametro en ambos queries, el de los threads y el del appointment

ErnestoOrtiz2 2 年 前
コミット
bb438a8f4f
共有2 個のファイルを変更した68 個の追加0 個の削除を含む
  1. 57
    0
      screens/main/Cita.js
  2. 11
    0
      screens/main/Home_page.js

+ 57
- 0
screens/main/Cita.js ファイルの表示

@@ -17,6 +17,7 @@ export function Cita({route, navigation}) {
17 17
    const [threads, setThreads] = useState([]);  
18 18
    const [loading, setLoading] = useState(true);
19 19
    console.log("ID", route.params);
20
+   const [appointments, setAppointments] = useState([]); 
20 21
 
21 22
 
22 23
 
@@ -41,8 +42,27 @@ export function Cita({route, navigation}) {
41 42
       }
42 43
     });
43 44
 
45
+    const cita = firebase.firestore().collection('APPOINTMENTS').where("citaID", "==", route.params.tag._id).onSnapshot(snapShot => {
46
+      const appointments = snapShot.docs.map(docSnap => {
47
+        return{
48
+          _id:docSnap.id,
49
+          new:'',
50
+          Day:'',
51
+          Month:'',
52
+          Time:'',
53
+          i_token:'',
54
+          u_token:'',
55
+          Pin: {},
56
+          ...docSnap.data()
57
+        };
58
+      });
59
+      setAppointments(appointments);
60
+      console.log("appointment", appointments);
61
+    });
62
+
44 63
     return () => {
45 64
       fire();
65
+      cita();
46 66
     }
47 67
   }, []);
48 68
     
@@ -78,6 +98,43 @@ export function Cita({route, navigation}) {
78 98
           </TouchableOpacity>
79 99
         )}
80 100
         />
101
+        <FlatList style={{
102
+           flex: 1,
103
+           width: screenWidth,
104
+       }}
105
+        data={appointments}
106
+        keyExtractor = {item => item._id}
107
+        ItemSeparatorComponent={() => <Divider />}
108
+        renderItem = {({item}) => (
109
+        <TouchableOpacity
110
+        onPress={async () => {
111
+          console.log("cita")
112
+        }}
113
+        >
114
+          <List.Item
115
+            title={item.Month}
116
+            titleNumberOfLines={1}
117
+            titleStyle={styles.listTitle}
118
+            descriptionStyle={styles.listDescription}
119
+            descriptionNumberOfLines={1}
120
+          />
121
+          <List.Item
122
+            title={item.Day}
123
+            titleNumberOfLines={1}
124
+            titleStyle={styles.listTitle}
125
+            descriptionStyle={styles.listDescription}
126
+            descriptionNumberOfLines={1}
127
+          />
128
+          <List.Item
129
+            title={item.Time}
130
+            titleNumberOfLines={1}
131
+            titleStyle={styles.listTitle}
132
+            descriptionStyle={styles.listDescription}
133
+            descriptionNumberOfLines={1}
134
+          />
135
+        </TouchableOpacity>
136
+      )}
137
+          />
81 138
       <Button
82 139
         title ='Ver mapa'
83 140
         onPress= {() => navigation.navigate('Map', {View_Only: true, Pin: Pin})}

+ 11
- 0
screens/main/Home_page.js ファイルの表示

@@ -128,6 +128,15 @@ export function Home_page({navigation}) {
128 128
     }
129 129
 
130 130
   }
131
+
132
+  function citaId(citaID) {
133
+    firebase.firestore()
134
+      .collection('APPOINTMENTS')
135
+      .doc(citaID)
136
+      .update({
137
+        citaID: citaID,
138
+      })
139
+  }
131 140
   
132 141
   check_user_type_INT();
133 142
   console.log("interpreter", interpreter);
@@ -186,6 +195,7 @@ export function Home_page({navigation}) {
186 195
               title ='Pedir Cita'
187 196
               onPress={ async () => {
188 197
                 await sendPushNotification(item.i_token);
198
+                citaId(item._id);
189 199
                 }
190 200
               }
191 201
             /> 
@@ -259,6 +269,7 @@ export function Home_page({navigation}) {
259 269
                 title ='Pedir Cita'
260 270
                 onPress={ async () => {
261 271
                   await sendPushNotification(item.i_token);
272
+                  citaId(item._id);
262 273
                   }
263 274
                 }
264 275
               />