Browse Source

Tratando todavia de resolver bug en Confirm. Ahora mismo funciona. Por alguna razon, a veces el arreglo appointments llega vacio al listener de respuesta a la notificacion, en cuyo caso no pasa nada a Confirm y se rompe en confirm porque no tiene ningun valor para usar en el query.

ErnestoOrtiz2 2 years ago
parent
commit
857f084c6e
2 changed files with 18 additions and 9 deletions
  1. 9
    1
      screens/main/Confirm.js
  2. 9
    8
      screens/main/Home_page.js

+ 9
- 1
screens/main/Confirm.js View File

@@ -45,7 +45,7 @@ export function Confirm({route, navigation}) {
45 45
       navigation.navigate('Search');
46 46
     });
47 47
 
48
-    console.log("en confirm", route.params.tag._id);
48
+    console.log("en confirm", route.params.tag.citaID);
49 49
     //const cita = firebase.firestore().collection('APPOINTMENTS').where("new", "==", "true").onSnapshot(snapShot => {
50 50
     const cita = firebase.firestore().collection('APPOINTMENTS').where("citaID", "==", route.params.tag.citaID).onSnapshot(snapShot => {
51 51
       const appointments = snapShot.docs.map(docSnap => {
@@ -128,6 +128,14 @@ export function Confirm({route, navigation}) {
128 128
           }}
129 129
           >
130 130
           <List.Item
131
+            title='Usuario:'
132
+            description={item.User}
133
+            titleNumberOfLines={1}
134
+            titleStyle={styles.listTitle}
135
+            descriptionStyle={styles.listDescription}
136
+            descriptionNumberOfLines={1}
137
+          />
138
+          <List.Item
131 139
             title='Mes:'
132 140
             description={item.Month}
133 141
             titleNumberOfLines={1}

+ 9
- 8
screens/main/Home_page.js View File

@@ -24,7 +24,9 @@ Notifications.setNotificationHandler({
24 24
 });
25 25
 
26 26
 
27
-const double = [];
27
+let x = "x";
28
+console.log(x);
29
+
28 30
 
29 31
 export function Home_page({navigation}) {
30 32
 
@@ -49,10 +51,8 @@ export function Home_page({navigation}) {
49 51
     });
50 52
 
51 53
     responseListener.current = Notifications.addNotificationResponseReceivedListener(response => {
52
-      //console.log("response", response);
53 54
       if (response.notification.request.content.body == 'Le solicitan una cita'){
54
-        console.log("en pedir response", {appointments});
55
-        console.log("el id", appointments[0]._id);
55
+        console.log("response appointments ", appointments[0])
56 56
         navigation.navigate('Confirm',{tag: appointments[0]})
57 57
       } 
58 58
     });
@@ -272,7 +272,7 @@ export function Home_page({navigation}) {
272 272
           renderItem = {({item}) => (
273 273
           <TouchableOpacity
274 274
           onPress={async () => {
275
-            console.log("item._id, home, interpreter", item)
275
+            //console.log("item._id, home, interpreter", item)
276 276
             navigation.navigate('Cita',{tag: item, Pin: item})
277 277
           }}
278 278
           >
@@ -328,8 +328,9 @@ export function Home_page({navigation}) {
328 328
               onPress={ async () => {
329 329
                 await sendPushNotification(item.i_token);
330 330
                 citaId(item._id);
331
-                //double = appointments.map((number) => number);
332
-                //console.log("double", double);
331
+                x = item._id;
332
+                console.log(x);
333
+                console.log("en pedir cita, appointments", appointments[0])
333 334
                 }
334 335
               }
335 336
             /> 
@@ -385,7 +386,7 @@ async function registerForPushNotificationsAsync() {
385 386
       return;
386 387
     }
387 388
     token = (await Notifications.getExpoPushTokenAsync()).data;
388
-    console.log('Token:', token)
389
+    //console.log('Token:', token)
389 390
   } else {
390 391
     alert('Must use physical device for Push Notifications');
391 392
   }