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

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

@@ -52,8 +52,8 @@ export function Home_page({navigation}) {
52 52
 
53 53
     responseListener.current = Notifications.addNotificationResponseReceivedListener(response => {
54 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,9 +238,10 @@ export function Home_page({navigation}) {
238 238
               <Button
239 239
               title ='Pedir Cita'
240 240
               onPress={ async () => {
241
-                await sendPushNotification(item.i_token);
242
-                citaId(item._id);
243 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,6 +313,31 @@ export function Home_page({navigation}) {
312 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 341
           <Button
316 342
           title ='Availability'
317 343
           onPress= {() => navigation.navigate('Availability')}
@@ -325,13 +351,13 @@ export function Home_page({navigation}) {
325 351
       }
326 352
   }
327 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 355
   const message = {
330 356
     to: expoPushToken,
331 357
     sound: 'default',
332 358
     title: 'Freehand',
333 359
     body: 'Le solicitan una cita',
334
-    data: { someData: 'goes here' },
360
+    data: { someData: x },
335 361
   };
336 362
 
337 363
   await fetch('https://exp.host/--/api/v2/push/send', {