Browse Source

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 3 years ago
parent
commit
bb438a8f4f
2 changed files with 68 additions and 0 deletions
  1. 57
    0
      screens/main/Cita.js
  2. 11
    0
      screens/main/Home_page.js

+ 57
- 0
screens/main/Cita.js View File

17
    const [threads, setThreads] = useState([]);  
17
    const [threads, setThreads] = useState([]);  
18
    const [loading, setLoading] = useState(true);
18
    const [loading, setLoading] = useState(true);
19
    console.log("ID", route.params);
19
    console.log("ID", route.params);
20
+   const [appointments, setAppointments] = useState([]); 
20
 
21
 
21
 
22
 
22
 
23
 
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
     return () => {
63
     return () => {
45
       fire();
64
       fire();
65
+      cita();
46
     }
66
     }
47
   }, []);
67
   }, []);
48
     
68
     
78
           </TouchableOpacity>
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
       <Button
138
       <Button
82
         title ='Ver mapa'
139
         title ='Ver mapa'
83
         onPress= {() => navigation.navigate('Map', {View_Only: true, Pin: Pin})}
140
         onPress= {() => navigation.navigate('Map', {View_Only: true, Pin: Pin})}

+ 11
- 0
screens/main/Home_page.js View File

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
   check_user_type_INT();
141
   check_user_type_INT();
133
   console.log("interpreter", interpreter);
142
   console.log("interpreter", interpreter);
186
               title ='Pedir Cita'
195
               title ='Pedir Cita'
187
               onPress={ async () => {
196
               onPress={ async () => {
188
                 await sendPushNotification(item.i_token);
197
                 await sendPushNotification(item.i_token);
198
+                citaId(item._id);
189
                 }
199
                 }
190
               }
200
               }
191
             /> 
201
             /> 
259
                 title ='Pedir Cita'
269
                 title ='Pedir Cita'
260
                 onPress={ async () => {
270
                 onPress={ async () => {
261
                   await sendPushNotification(item.i_token);
271
                   await sendPushNotification(item.i_token);
272
+                  citaId(item._id);
262
                   }
273
                   }
263
                 }
274
                 }
264
               /> 
275
               />