@messenger-box/platform-mobile 0.0.1-alpha.379 → 0.0.1-alpha.381

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@messenger-box/platform-mobile",
3
- "version": "0.0.1-alpha.379",
3
+ "version": "0.0.1-alpha.381",
4
4
  "description": "Sample core for higher packages to depend on",
5
5
  "license": "ISC",
6
6
  "author": "CDMBase LLC",
@@ -19,8 +19,8 @@
19
19
  "watch": "yarn build:lib:watch"
20
20
  },
21
21
  "dependencies": {
22
- "@messenger-box/core": "0.0.1-alpha.379",
23
- "@messenger-box/platform-client": "0.0.1-alpha.379",
22
+ "@messenger-box/core": "0.0.1-alpha.381",
23
+ "@messenger-box/platform-client": "0.0.1-alpha.381",
24
24
  "base-64": "1.0.0",
25
25
  "react-native-gifted-chat": "1.0.4"
26
26
  },
@@ -40,5 +40,5 @@
40
40
  "typescript": {
41
41
  "definition": "lib/index.d.ts"
42
42
  },
43
- "gitHead": "de3199a861a5d9a761aeeccf4ad0e8324eec58bd"
43
+ "gitHead": "a29575188273c7ba6f998bff5ea2a3234faaeb72"
44
44
  }
@@ -30,8 +30,10 @@ import {
30
30
  useGetNewMongooseObjectIdQuery,
31
31
  useOnChatMessageAddedSubscription,
32
32
  IPreDefinedRole,
33
+ useSendExpoNotificationOnPostMutation,
34
+ IPost,
33
35
  } from '@messenger-box/platform-client';
34
- import { IFileInfo } from '@messenger-box/core';
36
+ import { IExpoNotificationData, IFileInfo } from '@messenger-box/core';
35
37
  import { config } from '../config';
36
38
  import { userSelector } from '@adminide-stack/user-auth0-client';
37
39
  import { SlackMessage, ImageViewerModal } from '../components/SlackMessageContainer';
@@ -108,6 +110,8 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
108
110
 
109
111
  const [sendMsg] = useSendMessagesMutation();
110
112
 
113
+ const [sendExpoNotificationOnPostMutation] = useSendExpoNotificationOnPostMutation();
114
+
111
115
  const {
112
116
  data,
113
117
  loading: messageLoading,
@@ -391,45 +395,45 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
391
395
  if (imageSource.cancelled) setLoading(false);
392
396
  };
393
397
 
394
- const sendPushNotification = async (title: String, body: String, data: any, to: any) => {
395
- try {
396
- const response = await fetch('https://exp.host/--/api/v2/push/send/', {
397
- method: 'POST',
398
- headers: {
399
- Accept: 'application/json',
400
- 'Accept-Encoding': 'gzip, deflate',
401
- 'Content-Type': 'application/json',
402
- },
403
- body: JSON.stringify({
404
- to: to,
405
- data: data,
406
- title: title,
407
- body: body,
408
- sound: Platform.OS === 'android' ? undefined || null : 'default',
409
- }),
410
- });
411
- const result: any = await response.json();
412
- console.log('expo api response', result);
413
- } catch (error) {
414
- console.error('Error:', error);
415
- }
398
+ // const sendPushNotification = async (title: String, body: String, data: any, to: any) => {
399
+ // try {
400
+ // const response = await fetch('https://exp.host/--/api/v2/push/send/', {
401
+ // method: 'POST',
402
+ // headers: {
403
+ // Accept: 'application/json',
404
+ // 'Accept-Encoding': 'gzip, deflate',
405
+ // 'Content-Type': 'application/json',
406
+ // },
407
+ // body: JSON.stringify({
408
+ // to: to,
409
+ // data: data,
410
+ // title: title,
411
+ // body: body,
412
+ // sound: Platform.OS === 'android' ? undefined || null : 'default',
413
+ // }),
414
+ // });
415
+ // const result: any = await response.json();
416
+ // console.log('expo api response', result);
417
+ // } catch (error) {
418
+ // console.error('Error:', error);
419
+ // }
416
420
 
417
- // fetch('https://exp.host/--/api/v2/push/send/', {
418
- // method: 'POST',
419
- // headers: {
420
- // Accept: 'application/json',
421
- // 'Accept-Encoding': 'gzip, deflate',
422
- // 'Content-Type': 'application/json',
423
- // },
424
- // body: JSON.stringify({
425
- // to: to,
426
- // data: data,
427
- // title: title,
428
- // body: body,
429
- // sound: Platform.OS === 'android' ? null : 'default',
430
- // }),
431
- // });
432
- };
421
+ // // fetch('https://exp.host/--/api/v2/push/send/', {
422
+ // // method: 'POST',
423
+ // // headers: {
424
+ // // Accept: 'application/json',
425
+ // // 'Accept-Encoding': 'gzip, deflate',
426
+ // // 'Content-Type': 'application/json',
427
+ // // },
428
+ // // body: JSON.stringify({
429
+ // // to: to,
430
+ // // data: data,
431
+ // // title: title,
432
+ // // body: body,
433
+ // // sound: Platform.OS === 'android' ? null : 'default',
434
+ // // }),
435
+ // // });
436
+ // };
433
437
 
434
438
  // const handleSend = useCallback(
435
439
  // async (message: string) => {
@@ -572,7 +576,7 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
572
576
  setLoading(false);
573
577
  setMsg('');
574
578
  const msg = message == '' ? 'Send a file' : message;
575
- fetchTokenAndSendPushNotification(msg, channelId);
579
+ sendPushNotification(data?.sendMessage, channelId);
576
580
  },
577
581
  });
578
582
  }
@@ -593,7 +597,7 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
593
597
  setChannelToTop(channelToTop + 1);
594
598
  setLoading(false);
595
599
  setMsg('');
596
- fetchTokenAndSendPushNotification(message, channelId);
600
+ sendPushNotification(data?.sendMessage, channelId);
597
601
  },
598
602
  });
599
603
  }
@@ -601,41 +605,57 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
601
605
  [mongooseObjectId, setChannelMessages, channelId, images, channelToTop, expoTokens],
602
606
  );
603
607
 
604
- const fetchTokenAndSendPushNotification = (message: any, channelId: any) => {
605
- const givenName = auth?.profile?.given_name ?? '';
606
- const familyName = auth?.profile?.family_name ?? '';
607
- const fullName = givenName ? givenName + ' ' + familyName : '';
608
- const title: String = fullName ? fullName : 'Message';
609
- const body: String = message;
610
- const notificationData: any = {
608
+ const sendPushNotification = async (post: IPost, channelId: string) => {
609
+ const notificationData: IExpoNotificationData = {
611
610
  url: config.INBOX_MESSEGE_PATH,
612
611
  params: { channelId, hideTabBar: true },
613
612
  screen: 'DialogMessages',
613
+ other: { sound: Platform.OS === 'android' ? undefined || null : 'default' },
614
614
  };
615
- refetchChannelDetail({ id: channelId?.toString() })?.then((res: any) => {
616
- if (res?.data?.viewChannelDetail?.members?.length) {
617
- const channelData: any =
618
- res?.data?.viewChannelDetail?.members?.filter((mu: any) => mu?.user?.id != auth?.id) ?? [];
619
- const tokens: any =
620
- channelData
621
- ?.map(
622
- (u: any) =>
623
- u?.user?.tokens
624
- ?.filter((t: any) => t?.type == 'EXPO_NOTIFICATION_TOKEN')
625
- ?.map((et: any) => et?.token) ?? [],
626
- )
627
- ?.flat(1)
628
- ?.filter((t: any) => t)
629
- ?.filter((value: any, index: any, array: any) => array.indexOf(value) === index) ?? [];
630
- console.log('expo to', JSON.stringify(tokens));
631
- if (tokens?.length > 0) {
632
- const to: any = tokens?.length > 0 ? tokens : [];
633
- sendPushNotification(title, body, notificationData, to);
634
- }
635
- }
615
+
616
+ await sendExpoNotificationOnPostMutation({
617
+ variables: {
618
+ postId: post?.id?.toString(),
619
+ notificationData,
620
+ },
636
621
  });
637
622
  };
638
623
 
624
+ // const fetchTokenAndSendPushNotification = (message: any, channelId: any) => {
625
+ // const givenName = auth?.profile?.given_name ?? '';
626
+ // const familyName = auth?.profile?.family_name ?? '';
627
+ // const fullName = givenName ? givenName + ' ' + familyName : '';
628
+ // const title: String = fullName ? fullName : 'Message';
629
+ // const body: String = message;
630
+ // const notificationData: any = {
631
+ // url: config.INBOX_MESSEGE_PATH,
632
+ // params: { channelId, hideTabBar: true },
633
+ // screen: 'DialogMessages',
634
+ // };
635
+ // refetchChannelDetail({ id: channelId?.toString() })?.then((res: any) => {
636
+ // if (res?.data?.viewChannelDetail?.members?.length) {
637
+ // const channelData: any =
638
+ // res?.data?.viewChannelDetail?.members?.filter((mu: any) => mu?.user?.id != auth?.id) ?? [];
639
+ // const tokens: any =
640
+ // channelData
641
+ // ?.map(
642
+ // (u: any) =>
643
+ // u?.user?.tokens
644
+ // ?.filter((t: any) => t?.type == 'EXPO_NOTIFICATION_TOKEN')
645
+ // ?.map((et: any) => et?.token) ?? [],
646
+ // )
647
+ // ?.flat(1)
648
+ // ?.filter((t: any) => t)
649
+ // ?.filter((value: any, index: any, array: any) => array.indexOf(value) === index) ?? [];
650
+ // console.log('expo to', JSON.stringify(tokens));
651
+ // if (tokens?.length > 0) {
652
+ // const to: any = tokens?.length > 0 ? tokens : [];
653
+ // sendPushNotification(title, body, notificationData, to);
654
+ // }
655
+ // }
656
+ // });
657
+ // };
658
+
639
659
  // const handleSend1 = async (message: string) => {
640
660
  // if (!channelId) return;
641
661
  // if (!message && message != ' ' && images.length == 0) return;
@@ -819,23 +839,88 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
819
839
  }
820
840
 
821
841
  return (
822
- <Box bg={CALL_TO_ACTION_BOX_BGCOLOR} borderRadius={15} pb={2}>
823
- {attachment?.callToAction ? (
824
- <Button
825
- variant={'outline'}
826
- size={'sm'}
827
- borderColor={CALL_TO_ACTION_BUTTON_BORDERCOLOR}
828
- onPress={() => action && params && navigation.navigate(action, params)}
829
- // onPress={() => navigation.navigate(action, { reservationId: actionId })}
842
+ <>
843
+ {attachment?.callToAction && action ? (
844
+ <Box bg={CALL_TO_ACTION_BOX_BGCOLOR} borderRadius={15} pb={2}>
845
+ <Button
846
+ variant={'outline'}
847
+ size={'sm'}
848
+ borderColor={CALL_TO_ACTION_BUTTON_BORDERCOLOR}
849
+ onPress={() => action && params && navigation.navigate(action, params)}
850
+ // onPress={() => navigation.navigate(action, { reservationId: actionId })}
851
+ >
852
+ <Text color={CALL_TO_ACTION_TEXT_COLOR}>{attachment.callToAction.title}</Text>
853
+ </Button>
854
+ <MessageText
855
+ {...props}
856
+ textStyle={{
857
+ left: { marginLeft: 5, color: CALL_TO_ACTION_TEXT_COLOR, paddingHorizontal: 2 },
858
+ }}
859
+ />
860
+ </Box>
861
+ ) : (
862
+ <TouchableHighlight
863
+ underlayColor={'#c0c0c0'}
864
+ style={{ width: '100%' }}
865
+ onPress={() =>
866
+ navigation.navigate(config.THREAD_MESSEGE_PATH, {
867
+ channelId: channelId,
868
+ title: 'Message',
869
+ postParentId: currentMessage?._id,
870
+ isPostParentIdThread: true,
871
+ })
872
+ }
830
873
  >
831
- <Text color={CALL_TO_ACTION_TEXT_COLOR}>{attachment.callToAction.title}</Text>
832
- </Button>
833
- ) : null}
834
- <MessageText
874
+ <>
875
+ <MessageText {...props} textStyle={{ left: { marginLeft: 5 } }} />
876
+ {currentMessage?.replies?.data?.length > 0 && (
877
+ <HStack space={1} px={1} alignItems={'center'}>
878
+ <HStack>
879
+ {currentMessage?.replies?.data
880
+ ?.filter(
881
+ (v: any, i: any, a: any) =>
882
+ a.findIndex((t: any) => t?.author?.id === v?.author?.id) === i,
883
+ )
884
+ ?.slice(0, 2)
885
+ ?.reverse()
886
+ ?.map((p: any, i: Number) => (
887
+ <Avatar
888
+ key={'key' + i}
889
+ bg={'transparent'}
890
+ size={6}
891
+ // top={i == 1 ? 4 : 0}
892
+ // right={i == 1 ? -2 : 0}
893
+ // zIndex={i == 1 ? 5 : 1}
894
+ _image={{
895
+ borderRadius: 6,
896
+ borderWidth: 2,
897
+ borderColor: '#fff',
898
+ }}
899
+ source={{
900
+ uri: p?.author?.picture,
901
+ }}
902
+ >
903
+ {startCase(p?.author?.username?.charAt(0))}
904
+ </Avatar>
905
+ ))}
906
+ </HStack>
907
+ <Text fontSize={12} fontWeight={'bold'} color={'blue.800'}>
908
+ {currentMessage?.replies?.totalCount}{' '}
909
+ {currentMessage?.replies?.totalCount == 1 ? 'reply' : 'replies'}
910
+ </Text>
911
+ <Text fontSize={12} fontWeight={'bold'} color={'gray.500'}>
912
+ {lastReply ? createdAtText(lastReply?.createdAt) : ''}
913
+ </Text>
914
+ </HStack>
915
+ )}
916
+ </>
917
+ </TouchableHighlight>
918
+ )}
919
+ {/* <MessageText
835
920
  {...props}
836
921
  textStyle={{ left: { marginLeft: 5, color: CALL_TO_ACTION_TEXT_COLOR, paddingHorizontal: 2 } }}
837
- />
838
- </Box>
922
+ /> */}
923
+ </>
839
924
  );
840
925
  } else {
841
926
  return (
@@ -32,8 +32,11 @@ import {
32
32
  useUploadFilesNative,
33
33
  useGetNewMongooseObjectIdQuery,
34
34
  useOnThreadChatMessageAddedSubscription,
35
+ IPreDefinedRole,
36
+ useSendExpoNotificationOnPostMutation,
37
+ IPost,
35
38
  } from '@messenger-box/platform-client';
36
- import { IFileInfo } from '@messenger-box/core';
39
+ import { IExpoNotificationData, IFileInfo } from '@messenger-box/core';
37
40
  import { config } from '../config';
38
41
  import { userSelector } from '@adminide-stack/user-auth0-client';
39
42
  import { SlackMessage, ImageViewerModal } from '../components/SlackMessageContainer';
@@ -110,6 +113,7 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
110
113
  });
111
114
 
112
115
  const [sendThreadMessage] = useSendThreadMessageMutation();
116
+ const [sendExpoNotificationOnPostMutation] = useSendExpoNotificationOnPostMutation();
113
117
 
114
118
  const [getThreadMessages, { data: threadMessagesData, loading: threadLoading, refetch: refetchThreadMessages }] =
115
119
  useThreadMessagesLazyQuery({
@@ -327,29 +331,29 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
327
331
  if (imageSource.cancelled) setLoading(false);
328
332
  };
329
333
 
330
- const sendPushNotification = async (title: String, body: String, data: any, to: any) => {
331
- try {
332
- const response = await fetch('https://exp.host/--/api/v2/push/send/', {
333
- method: 'POST',
334
- headers: {
335
- Accept: 'application/json',
336
- 'Accept-Encoding': 'gzip, deflate',
337
- 'Content-Type': 'application/json',
338
- },
339
- body: JSON.stringify({
340
- to: to,
341
- data: data,
342
- title: title,
343
- body: body,
344
- sound: Platform.OS === 'android' ? undefined || null : 'default',
345
- }),
346
- });
347
- const result: any = await response.json();
348
- console.log('expo api response', result);
349
- } catch (error) {
350
- console.error('Error:', error);
351
- }
352
- };
334
+ // const sendPushNotification = async (title: String, body: String, data: any, to: any) => {
335
+ // try {
336
+ // const response = await fetch('https://exp.host/--/api/v2/push/send/', {
337
+ // method: 'POST',
338
+ // headers: {
339
+ // Accept: 'application/json',
340
+ // 'Accept-Encoding': 'gzip, deflate',
341
+ // 'Content-Type': 'application/json',
342
+ // },
343
+ // body: JSON.stringify({
344
+ // to: to,
345
+ // data: data,
346
+ // title: title,
347
+ // body: body,
348
+ // sound: Platform.OS === 'android' ? undefined || null : 'default',
349
+ // }),
350
+ // });
351
+ // const result: any = await response.json();
352
+ // console.log('expo api response', result);
353
+ // } catch (error) {
354
+ // console.error('Error:', error);
355
+ // }
356
+ // };
353
357
 
354
358
  // const ObjectId = (m = Math, d = Date, h = 16, s = (s:any) => m.floor(s).toString(h)) =>
355
359
  // s(d.now() / 1000) + ' '.repeat(h).replace(/./g, () => s(m.random() * h))
@@ -424,7 +428,12 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
424
428
  // setParentId(responseMessage?.id);
425
429
  // }
426
430
  const msg = message == '' ? 'Send a file' : message;
427
- fetchTokenAndSendPushNotification(msg, channelId, parentId);
431
+ sendPushNotification(
432
+ responseMessage,
433
+ channelId,
434
+ parentId,
435
+ data?.sendThreadMessage?.data?.id,
436
+ );
428
437
  },
429
438
  });
430
439
  }
@@ -456,7 +465,7 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
456
465
  // if (!parentId || parentId == 0) {
457
466
  // setParentId(responseMessage?.id);
458
467
  // }
459
- fetchTokenAndSendPushNotification(message, channelId, parentId);
468
+ sendPushNotification(responseMessage, channelId, parentId, data?.sendThreadMessage?.data?.id);
460
469
  },
461
470
  });
462
471
  }
@@ -464,48 +473,66 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
464
473
  [mongooseObjectId, setChannelMessages, channelId, images, parentId, expoTokens],
465
474
  );
466
475
 
467
- const fetchTokenAndSendPushNotification = (message: any, channelId: any, parentId: any) => {
468
- const givenName = auth?.profile?.given_name ?? '';
469
- const familyName = auth?.profile?.family_name ?? '';
470
- const fullName = givenName ? givenName + ' ' + familyName : '';
471
- const title: String = fullName ? fullName : 'Message';
472
- const body: String = message;
473
- const notificationData: any = {
476
+ const sendPushNotification = async (post: IPost, channelId: string, parentId: any, threadId: string) => {
477
+ const notificationData: IExpoNotificationData = {
474
478
  url: config.THREAD_MESSEGE_PATH,
475
479
  params: { channelId, title: params?.title ?? 'Thread', postParentId: parentId, hideTabBar: true },
476
480
  screen: 'DialogThreadMessages',
481
+ thread: { id: threadId },
482
+ other: { sound: Platform.OS === 'android' ? undefined || null : 'default' },
477
483
  };
478
484
  if (parentId || parentId == 0) {
479
- refetchThreadMessages({
480
- channelId: !parentId || parentId == 0 ? null : channelId?.toString(),
481
- role: role?.toString(),
482
- postParentId: !parentId || parentId == 0 ? null : parentId?.toString(),
483
- })?.then((res: any) => {
484
- if (res?.data?.threadMessages?.data?.length > 0) {
485
- const participants =
486
- res?.data?.threadMessages?.data?.map((t: any) => t?.participants)?.flat(1) ?? [];
487
- const participantsTokens =
488
- participants?.length > 0
489
- ? participants
490
- ?.filter((u: any) => u?.id != auth?.id)
491
- ?.map((p: any) => p.tokens)
492
- ?.flat(1)
493
- : [];
494
- const expoTokens =
495
- participantsTokens?.length > 0
496
- ? participantsTokens
497
- ?.filter((t: any) => t?.type == 'EXPO_NOTIFICATION_TOKEN')
498
- ?.map((et: any) => et?.token)
499
- : [];
500
- if (expoTokens?.length > 0) {
501
- const to: any = expoTokens;
502
- sendPushNotification(title, body, notificationData, to);
503
- }
504
- }
485
+ await sendExpoNotificationOnPostMutation({
486
+ variables: {
487
+ postId: post?.id?.toString(),
488
+ notificationData,
489
+ },
505
490
  });
506
491
  }
507
492
  };
508
493
 
494
+ // const fetchTokenAndSendPushNotification = (message: any, channelId: any, parentId: any) => {
495
+ // const givenName = auth?.profile?.given_name ?? '';
496
+ // const familyName = auth?.profile?.family_name ?? '';
497
+ // const fullName = givenName ? givenName + ' ' + familyName : '';
498
+ // const title: String = fullName ? fullName : 'Message';
499
+ // const body: String = message;
500
+ // const notificationData: any = {
501
+ // url: config.THREAD_MESSEGE_PATH,
502
+ // params: { channelId, title: params?.title ?? 'Thread', postParentId: parentId, hideTabBar: true },
503
+ // screen: 'DialogThreadMessages',
504
+ // };
505
+ // if (parentId || parentId == 0) {
506
+ // refetchThreadMessages({
507
+ // channelId: !parentId || parentId == 0 ? null : channelId?.toString(),
508
+ // role: role?.toString(),
509
+ // postParentId: !parentId || parentId == 0 ? null : parentId?.toString(),
510
+ // })?.then((res: any) => {
511
+ // if (res?.data?.threadMessages?.data?.length > 0) {
512
+ // const participants =
513
+ // res?.data?.threadMessages?.data?.map((t: any) => t?.participants)?.flat(1) ?? [];
514
+ // const participantsTokens =
515
+ // participants?.length > 0
516
+ // ? participants
517
+ // ?.filter((u: any) => u?.id != auth?.id)
518
+ // ?.map((p: any) => p.tokens)
519
+ // ?.flat(1)
520
+ // : [];
521
+ // const expoTokens =
522
+ // participantsTokens?.length > 0
523
+ // ? participantsTokens
524
+ // ?.filter((t: any) => t?.type == 'EXPO_NOTIFICATION_TOKEN')
525
+ // ?.map((et: any) => et?.token)
526
+ // : [];
527
+ // if (expoTokens?.length > 0) {
528
+ // const to: any = expoTokens;
529
+ // sendPushNotification(title, body, notificationData, to);
530
+ // }
531
+ // }
532
+ // });
533
+ // }
534
+ // };
535
+
509
536
  const messageList = useMemo(() => {
510
537
  let currentDate = '';
511
538
  let res: any = [];
@@ -566,28 +593,64 @@ const ThreadConversationViewComponent = ({ channelId, postParentId, isPostParent
566
593
  const attachment = currentMessage?.propsConfiguration?.contents?.attachment;
567
594
  let action: string = '';
568
595
  let actionId: any = '';
569
- if (attachment?.callToAction?.link?.includes('my-reservation-details')) {
596
+ let params: any = {};
597
+ if (attachment?.callToAction?.extraParams) {
598
+ const extraParams: any = attachment?.callToAction?.extraParams;
599
+ const route: any = extraParams?.route ?? null;
600
+ let path: any = null;
601
+ let param: any = null;
602
+ if (role && role == IPreDefinedRole.Guest) {
603
+ path = route?.guest?.name ? route?.guest?.name ?? null : null;
604
+ param = route?.guest?.params ? route?.guest?.params ?? null : null;
605
+ } else if (role && role == IPreDefinedRole.Owner) {
606
+ path = route?.host?.name ? route?.host?.name ?? null : null;
607
+ param = route?.host?.params ? route?.host?.params ?? null : null;
608
+ } else {
609
+ path = route?.host?.name ? route?.host?.name ?? null : null;
610
+ param = route?.host?.params ? route?.host?.params ?? null : null;
611
+ }
612
+
613
+ action = path;
614
+ params = { ...param };
615
+ } else if (attachment?.callToAction?.link) {
570
616
  action = CALL_TO_ACTION_PATH;
571
617
  actionId = attachment?.callToAction?.link.split('/').pop();
618
+ params = { reservationId: actionId };
572
619
  }
573
620
 
621
+ // if (attachment?.callToAction?.link?.includes('my-reservation-details')) {
622
+ // action = CALL_TO_ACTION_PATH;
623
+ // actionId = attachment?.callToAction?.link.split('/').pop();
624
+ // }
625
+
574
626
  return (
575
- <Box bg={CALL_TO_ACTION_BOX_BGCOLOR} borderRadius={15} pb={2}>
576
- {attachment?.callToAction ? (
577
- <Button
578
- variant={'outline'}
579
- size={'sm'}
580
- borderColor={CALL_TO_ACTION_BUTTON_BORDERCOLOR}
581
- onPress={() => navigation.navigate(action, { reservationId: actionId })}
582
- >
583
- <Text color={CALL_TO_ACTION_TEXT_COLOR}>{attachment.callToAction.title}</Text>
584
- </Button>
585
- ) : null}
586
- <MessageText
627
+ <>
628
+ {attachment?.callToAction && action ? (
629
+ <Box bg={CALL_TO_ACTION_BOX_BGCOLOR} borderRadius={15} pb={2}>
630
+ <Button
631
+ variant={'outline'}
632
+ size={'sm'}
633
+ borderColor={CALL_TO_ACTION_BUTTON_BORDERCOLOR}
634
+ onPress={() => action && params && navigation.navigate(action, params)}
635
+ //onPress={() => navigation.navigate(action, { reservationId: actionId })}
636
+ >
637
+ <Text color={CALL_TO_ACTION_TEXT_COLOR}>{attachment.callToAction.title}</Text>
638
+ </Button>
639
+ <MessageText
640
+ {...props}
641
+ textStyle={{
642
+ left: { marginLeft: 5, color: CALL_TO_ACTION_TEXT_COLOR, paddingHorizontal: 2 },
643
+ }}
644
+ />
645
+ </Box>
646
+ ) : (
647
+ <MessageText {...props} textStyle={{ left: { marginLeft: 5 } }} />
648
+ )}
649
+ {/* <MessageText
587
650
  {...props}
588
651
  textStyle={{ left: { marginLeft: 5, color: CALL_TO_ACTION_TEXT_COLOR, paddingHorizontal: 2 } }}
589
- />
590
- </Box>
652
+ /> */}
653
+ </>
591
654
  );
592
655
  } else {
593
656
  return <MessageText {...props} textStyle={{ left: { marginLeft: 5 } }} />;