Browse Source

Merge branch 'Freehand' of https://git.ccom.uprrp.edu/ccorrada/ErEduGilMor into Freehand

Eduardo Santin 2 years ago
parent
commit
b51c56acab
2 changed files with 38 additions and 8 deletions
  1. 6
    2
      screens/main/Confirm.js
  2. 32
    6
      screens/main/Home_page.js

+ 6
- 2
screens/main/Confirm.js View File

63
       });
63
       });
64
       setAppointments(appointments);
64
       setAppointments(appointments);
65
       console.log("appointment query de confirm", appointments);
65
       console.log("appointment query de confirm", appointments);
66
+
67
+      if(loading){
68
+        setLoading(false);
69
+      }
66
     });
70
     });
67
       
71
       
68
     return () => {
72
     return () => {
73
     }
77
     }
74
   }, []);
78
   }, []);
75
   
79
   
76
- /* if (loading) {
80
+  if (loading) {
77
     return <Loading />;
81
     return <Loading />;
78
-  }*/
82
+  };
79
 
83
 
80
 
84
 
81
   function crearChat(cliente, citaID) {
85
   function crearChat(cliente, citaID) {

+ 32
- 6
screens/main/Home_page.js View File

52
 
52
 
53
     responseListener.current = Notifications.addNotificationResponseReceivedListener(response => {
53
     responseListener.current = Notifications.addNotificationResponseReceivedListener(response => {
54
       if (response.notification.request.content.body == 'Le solicitan una cita'){
54
       if (response.notification.request.content.body == 'Le solicitan una cita'){
55
-        console.log("response appointments ", appointments[0])
56
-        navigation.navigate('Confirm',{x})
55
+        console.log("response appointments ", response)
56
+        navigation.navigate('Confirm',{x: response.notification.request.content.data.someData})
57
       } 
57
       } 
58
     });
58
     });
59
 
59
 
238
               <Button
238
               <Button
239
               title ='Pedir Cita'
239
               title ='Pedir Cita'
240
               onPress={ async () => {
240
               onPress={ async () => {
241
-                await sendPushNotification(item.i_token);
242
-                citaId(item._id);
243
                 x = item._id;
241
                 x = item._id;
242
+                await sendPushNotification(item.i_token, x);
243
+                citaId(item._id);
244
+                //x = item._id;
244
                 }
245
                 }
245
               }
246
               }
246
             /> 
247
             /> 
312
           </TouchableOpacity>
313
           </TouchableOpacity>
313
         )}
314
         )}
314
         />
315
         />
316
+        <FlatList style={{
317
+             flex: 1,
318
+             width: screenWidth,
319
+         }}
320
+          data={appointments}
321
+          keyExtractor = {item => item._id}
322
+          ItemSeparatorComponent={() => <Divider />}
323
+          renderItem={({ item }) => {
324
+            if(item.new == 'true'){
325
+            return (
326
+              <Button
327
+              title ='Pedir Cita'
328
+              onPress={ async () => {
329
+                x = item._id;
330
+                await sendPushNotification(item.i_token, x);
331
+                citaId(item._id);
332
+                //x = item._id;
333
+                console.log(x);
334
+                console.log("en pedir cita, appointments", appointments[0])
335
+                }
336
+              }
337
+            /> 
338
+            )
339
+          }}}
340
+            />
315
           <Button
341
           <Button
316
           title ='Availability'
342
           title ='Availability'
317
           onPress= {() => navigation.navigate('Availability')}
343
           onPress= {() => navigation.navigate('Availability')}
325
       }
351
       }
326
   }
352
   }
327
 // Can use this function below, OR use Expo's Push Notification Tool-> https://expo.dev/notifications
353
 // Can use this function below, OR use Expo's Push Notification Tool-> https://expo.dev/notifications
328
-async function sendPushNotification(expoPushToken) {
354
+async function sendPushNotification(expoPushToken, x) {
329
   const message = {
355
   const message = {
330
     to: expoPushToken,
356
     to: expoPushToken,
331
     sound: 'default',
357
     sound: 'default',
332
     title: 'Freehand',
358
     title: 'Freehand',
333
     body: 'Le solicitan una cita',
359
     body: 'Le solicitan una cita',
334
-    data: { someData: 'goes here' },
360
+    data: { someData: x },
335
   };
361
   };
336
 
362
 
337
   await fetch('https://exp.host/--/api/v2/push/send', {
363
   await fetch('https://exp.host/--/api/v2/push/send', {