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 3 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
       navigation.navigate('Search');
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
     //const cita = firebase.firestore().collection('APPOINTMENTS').where("new", "==", "true").onSnapshot(snapShot => {
49
     //const cita = firebase.firestore().collection('APPOINTMENTS').where("new", "==", "true").onSnapshot(snapShot => {
50
     const cita = firebase.firestore().collection('APPOINTMENTS').where("citaID", "==", route.params.tag.citaID).onSnapshot(snapShot => {
50
     const cita = firebase.firestore().collection('APPOINTMENTS').where("citaID", "==", route.params.tag.citaID).onSnapshot(snapShot => {
51
       const appointments = snapShot.docs.map(docSnap => {
51
       const appointments = snapShot.docs.map(docSnap => {
128
           }}
128
           }}
129
           >
129
           >
130
           <List.Item
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
             title='Mes:'
139
             title='Mes:'
132
             description={item.Month}
140
             description={item.Month}
133
             titleNumberOfLines={1}
141
             titleNumberOfLines={1}

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

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