|
@@ -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', {
|