ordering-ui-react-native 0.14.93 → 0.14.94-release

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.
Files changed (120) hide show
  1. package/package.json +6 -3
  2. package/src/DeliveryApp.tsx +32 -1
  3. package/src/components/BusinessTypeFilter/index.tsx +9 -2
  4. package/src/components/BusinessTypeFilter/styles.tsx +1 -1
  5. package/src/components/BusinessesListing/index.tsx +1 -1
  6. package/src/components/Cart/index.tsx +1 -1
  7. package/src/components/Checkout/index.tsx +0 -1
  8. package/src/components/Home/index.tsx +3 -5
  9. package/src/components/LanguageSelector/index.tsx +65 -97
  10. package/src/components/LanguageSelector/styles.tsx +4 -17
  11. package/src/components/Messages/index.tsx +38 -30
  12. package/src/components/MomentOption/index.tsx +3 -1
  13. package/src/components/OrderDetails/index.tsx +26 -5
  14. package/src/components/PaymentOptions/index.tsx +7 -16
  15. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  16. package/src/components/ProductForm/index.tsx +1 -1
  17. package/src/components/ProductForm/styles.tsx +1 -0
  18. package/src/components/StripeElementsForm/index.tsx +27 -48
  19. package/src/components/UserProfileForm/index.tsx +35 -1
  20. package/src/components/VerifyPhone/styles.tsx +1 -2
  21. package/src/config.json +0 -2
  22. package/src/pages/Checkout.tsx +1 -1
  23. package/src/types/index.tsx +2 -9
  24. package/src/utils/index.tsx +2 -1
  25. package/themes/business/index.tsx +2 -0
  26. package/themes/business/src/components/Chat/index.tsx +32 -31
  27. package/themes/business/src/components/OrderDetails/Business.tsx +1 -0
  28. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +85 -17
  29. package/themes/business/src/components/OrdersListManager/index.tsx +871 -0
  30. package/themes/business/src/components/OrdersListManager/styles.tsx +123 -0
  31. package/themes/business/src/components/OrdersListManager/utils.tsx +216 -0
  32. package/themes/business/src/components/OrdersOption/index.tsx +18 -68
  33. package/themes/business/src/components/OrdersOption/styles.tsx +2 -5
  34. package/themes/business/src/components/PreviousOrders/index.tsx +80 -23
  35. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  36. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  37. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  38. package/themes/kiosk/src/components/BusinessController/index.tsx +27 -6
  39. package/themes/kiosk/src/components/BusinessController/styles.tsx +1 -1
  40. package/themes/kiosk/src/components/BusinessProductsListing/index.tsx +51 -24
  41. package/themes/kiosk/src/components/Cart/index.tsx +1 -1
  42. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +1 -1
  43. package/themes/kiosk/src/components/CartBottomSheet/styles.tsx +1 -1
  44. package/themes/kiosk/src/components/CartContent/index.tsx +13 -3
  45. package/themes/kiosk/src/components/CartItem/index.tsx +20 -8
  46. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +7 -5
  47. package/themes/kiosk/src/components/CustomerName/index.tsx +89 -88
  48. package/themes/kiosk/src/components/Intro/index.tsx +13 -13
  49. package/themes/kiosk/src/components/LanguageSelector/index.tsx +12 -8
  50. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  51. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  52. package/themes/kiosk/src/components/OrderDetails/index.tsx +2 -2
  53. package/themes/kiosk/src/components/OrderSummary/index.tsx +1 -1
  54. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
  55. package/themes/kiosk/src/components/ProductForm/index.tsx +172 -124
  56. package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
  57. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -0
  58. package/themes/kiosk/src/components/ProductOption/styles.tsx +1 -0
  59. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +48 -34
  60. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  61. package/themes/kiosk/src/components/shared/OCard.tsx +112 -78
  62. package/themes/original/index.tsx +34 -6
  63. package/themes/original/src/components/AddressForm/index.tsx +15 -10
  64. package/themes/original/src/components/AddressList/index.tsx +27 -1
  65. package/themes/original/src/components/AnalyticsSegment/index.tsx +127 -0
  66. package/themes/original/src/components/BusinessBasicInformation/index.tsx +100 -45
  67. package/themes/original/src/components/BusinessController/index.tsx +34 -18
  68. package/themes/original/src/components/BusinessMenuList/index.tsx +14 -5
  69. package/themes/original/src/components/BusinessPreorder/index.tsx +142 -121
  70. package/themes/original/src/components/BusinessProductsCategories/index.tsx +7 -5
  71. package/themes/original/src/components/BusinessProductsList/index.tsx +52 -8
  72. package/themes/original/src/components/BusinessProductsListing/index.tsx +21 -15
  73. package/themes/original/src/components/BusinessReviews/index.tsx +4 -3
  74. package/themes/original/src/components/BusinessesListing/index.tsx +39 -52
  75. package/themes/original/src/components/Cart/index.tsx +42 -9
  76. package/themes/original/src/components/CartContent/index.tsx +2 -2
  77. package/themes/original/src/components/Checkout/index.tsx +56 -32
  78. package/themes/original/src/components/Checkout/styles.tsx +7 -0
  79. package/themes/original/src/components/CouponControl/index.tsx +1 -0
  80. package/themes/original/src/components/DriverTips/index.tsx +1 -1
  81. package/themes/original/src/components/ForgotPasswordForm/index.tsx +8 -12
  82. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +105 -90
  83. package/themes/original/src/components/LoginForm/index.tsx +83 -68
  84. package/themes/original/src/components/Messages/index.tsx +52 -45
  85. package/themes/original/src/components/Messages/styles.tsx +1 -3
  86. package/themes/original/src/components/MomentOption/index.tsx +127 -152
  87. package/themes/original/src/components/MomentOption/styles.tsx +42 -18
  88. package/themes/original/src/components/OrderDetails/index.tsx +103 -124
  89. package/themes/original/src/components/OrderDetails/styles.tsx +3 -1
  90. package/themes/original/src/components/OrderProgress/index.tsx +5 -6
  91. package/themes/original/src/components/OrderSummary/index.tsx +34 -1
  92. package/themes/original/src/components/OrdersOption/index.tsx +15 -46
  93. package/themes/original/src/components/OrdersOption/styles.tsx +0 -6
  94. package/themes/original/src/components/PaymentOptions/index.tsx +24 -25
  95. package/themes/original/src/components/PhoneInputNumber/index.tsx +15 -8
  96. package/themes/original/src/components/PlaceSpot/index.tsx +114 -0
  97. package/themes/original/src/components/PlaceSpot/styles.tsx +11 -0
  98. package/themes/original/src/components/PreviousOrders/index.tsx +19 -13
  99. package/themes/original/src/components/ProductForm/index.tsx +154 -105
  100. package/themes/original/src/components/ProductForm/styles.tsx +5 -3
  101. package/themes/original/src/components/ProductOptionSubOption/index.tsx +6 -1
  102. package/themes/original/src/components/ReviewOrder/index.tsx +10 -9
  103. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  104. package/themes/original/src/components/SignupForm/index.tsx +173 -154
  105. package/themes/original/src/components/SingleProductCard/index.tsx +6 -13
  106. package/themes/original/src/components/SingleProductCard/styles.tsx +1 -1
  107. package/themes/original/src/components/StripeElementsForm/index.tsx +55 -72
  108. package/themes/original/src/components/UpsellingProducts/index.tsx +6 -6
  109. package/themes/original/src/components/UserDetails/index.tsx +4 -95
  110. package/themes/original/src/components/UserFormDetails/index.tsx +2 -14
  111. package/themes/original/src/components/UserProfile/index.tsx +16 -11
  112. package/themes/original/src/components/UserProfileForm/index.tsx +16 -8
  113. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  114. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  115. package/themes/original/src/components/shared/HeaderTitle.tsx +20 -0
  116. package/themes/original/src/components/shared/index.tsx +2 -0
  117. package/themes/original/src/types/index.tsx +25 -9
  118. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +5 -5
  119. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  120. package/src/components/StripeMethodForm/index.tsx +0 -163
@@ -1,110 +1,144 @@
1
1
  import React from 'react';
2
- import { TextStyle, ViewStyle, Platform } from 'react-native';
2
+ import { TextStyle, ImageBackground, StyleSheet } from 'react-native';
3
3
  import { useTheme } from 'styled-components/native';
4
+ import FastImage from 'react-native-fast-image'
4
5
 
5
- import styled from 'styled-components/native';
6
- import OImage from './OImage';
6
+ import styled, { css } from 'styled-components/native';
7
7
  import OText from './OText';
8
8
 
9
9
  const CardContainer = styled.TouchableOpacity`
10
- width: 21%;
11
- margin: 10px 20px;
12
- overflow: hidden;
10
+ position: relative;
11
+ flex-direction: column;
12
+ border-radius: 10px;
13
+ position: relative;
14
+ margin: 0 30px 30px 0;
15
+ align-self: flex-start;
13
16
  `
14
17
 
15
- const CardBody = styled.View`
16
- padding: 4%;
18
+ const WrapPrice = styled.View`
19
+ display: flex;
20
+ flex-direction: row;
21
+ align-items: center;
22
+ margin-top: 10px;
17
23
  `
18
24
 
19
- const CardBadge = styled.Text`
20
- padding: 2% 4%;
21
- position: absolute;
22
- background-color: ${(props: any) => props.theme.theme.colors.primary};
23
- z-index: 100;
24
- border-radius: 5px;
25
- color: #fff;
26
- font-weight: bold;
27
- margin: 10px 0;
25
+ const WrapImage = styled.View`
26
+ width: 100%;
27
+ height: 120px;
28
+ `
29
+
30
+ const WrapContent = styled.View`
31
+ display: flex;
32
+ flex-direction: column;
33
+ ${(props: any) => props.isCentered && css`
34
+ align-items: center;
35
+ `}
28
36
  `
29
37
 
30
38
  const OCard = (props: Props): React.ReactElement => {
31
39
  const theme = useTheme()
32
40
 
41
+ const styles = StyleSheet.create({
42
+ textStyle: {
43
+ marginTop: 10
44
+ },
45
+ image: {
46
+ width: '100%',
47
+ height: '100%',
48
+ borderBottomLeftRadius: 0,
49
+ borderBottomRightRadius: 0,
50
+ }
51
+ })
52
+
33
53
  return (
34
54
  <CardContainer
35
- style={{...props.style}}
36
- onPress={props?.onPress}
37
- disabled={!props?.onPress}
38
- activeOpacity={1}
39
- >
40
- {props?.badgeText && (
41
- <CardBadge>
42
- {props?.badgeText}
43
- </CardBadge>
44
- )}
45
- <OImage
46
- source={props.image}
47
- height={120}
48
- resizeMode="cover"
49
- borderRadius={16}
50
- />
51
- <CardBody>
52
- <OText
53
- mLeft={0}
54
- size={18}
55
- numberOfLines={2}
56
- mBottom={8}
57
- style={{...props?.titleStyle}}
58
- >
59
- {props.title}
60
- </OText>
61
-
62
- {props?.description && (
63
- <OText
64
- color={theme.colors.mediumGray}
65
- numberOfLines={3}
66
- mBottom={8}
67
- style={{...props?.descriptionStyle}}
68
- >
69
- {props.description}
70
- </OText>
55
+ activeOpacity={1}
56
+ style={props.style}
57
+ onPress={props?.onPress}
58
+ disabled={!props?.onPress}
59
+ >
60
+ <WrapImage>
61
+ {props.isUri ? (
62
+ <FastImage
63
+ style={[styles.image, props.style]}
64
+ source={{
65
+ uri: props.image?.uri,
66
+ priority: FastImage.priority.normal,
67
+ // cache:FastImage.cacheControl.web
68
+ }}
69
+ resizeMode={FastImage.resizeMode.cover}
70
+ />
71
+ ) : (
72
+ <ImageBackground
73
+ style={[styles.image, props.style]}
74
+ source={props.image}
75
+ imageStyle={{
76
+ borderBottomLeftRadius: 0,
77
+ borderBottomRightRadius: 0,
78
+ borderRadius: 10
79
+ }}
80
+ resizeMode='cover'
81
+ />
71
82
  )}
72
-
73
- {props?.price && (
74
- <OText>
75
- <OText
76
- color={theme.colors.primary}
77
- weight="bold"
78
- >
79
- {props.price}
80
- </OText>
81
-
82
- <OText
83
- color={theme.colors.mediumGray}
84
- size={12}
85
- style={{textDecorationLine: 'line-through', textDecorationStyle: 'solid'}}
86
- >
87
- {props?.prevPrice ? ` ${props?.prevPrice} ` : ''}
88
- </OText>
89
- </OText>
90
- )}
91
-
92
- </CardBody>
93
- </CardContainer>
94
- );
83
+ </WrapImage>
84
+ <WrapContent isCentered={props.isCentered}>
85
+ <OText
86
+ size={18}
87
+ numberOfLines={1}
88
+ ellipsizeMode='tail'
89
+ style={styles.textStyle}
90
+ >
91
+ {props.title}
92
+ </OText>
93
+ {!!props?.description && (
94
+ <OText
95
+ color={theme.colors.mediumGray}
96
+ size={18}
97
+ numberOfLines={3}
98
+ ellipsizeMode='tail'
99
+ style={styles.textStyle}
100
+ >
101
+ {props?.description}
102
+ </OText>
103
+ )}
104
+ <WrapPrice>
105
+ <OText
106
+ size={18}
107
+ >
108
+ {props.price}
109
+ </OText>
110
+ {props?.prevPrice && (
111
+ <OText
112
+ size={18}
113
+ color={theme.colors.mediumGray}
114
+ style={{
115
+ textDecorationLine: 'line-through',
116
+ textDecorationStyle: 'solid',
117
+ marginLeft: 20,
118
+ }}
119
+ >
120
+ {props?.prevPrice}
121
+ </OText>
122
+ )}
123
+ </WrapPrice>
124
+ </WrapContent>
125
+ </CardContainer>
126
+ )
95
127
  }
96
128
 
97
129
  interface Props {
98
130
  badgeText?: string;
131
+ isUri?: boolean;
99
132
  onPress?(): void;
100
- image: string | { uri: string };
133
+ image: any;
134
+ isCentered?: any;
101
135
  title: string;
102
136
  titleStyle?: TextStyle;
103
137
  description?: string;
104
138
  descriptionStyle?: TextStyle;
105
139
  price?: string;
106
140
  prevPrice?: string;
107
- style?: ViewStyle;
141
+ style?: any;
108
142
  }
109
143
 
110
144
  export default OCard;
@@ -1,16 +1,21 @@
1
1
  import { AddressForm } from './src/components/AddressForm';
2
2
  import { AddressDetails } from './src/components/AddressDetails';
3
+ import { AnalyticsSegment } from './src/components/AnalyticsSegment';
3
4
  import { Home } from './src/components/Home';
4
5
  import { LoginForm } from './src/components/LoginForm';
5
6
  import { SignupForm } from './src/components/SignupForm';
6
7
  import { ActiveOrders } from './src/components/ActiveOrders';
7
8
  import { AddressList } from './src/components/AddressList';
8
9
  import { AppleLogin } from './src/components/AppleLogin';
10
+ import { BusinessBasicInformation } from './src/components/BusinessBasicInformation';
11
+ import { BusinessProductsCategories } from './src/components/BusinessProductsCategories';
12
+ import { BusinessProductsList } from './src/components/BusinessProductsList';
9
13
  import { BusinessesListing } from './src/components/BusinessesListing';
10
14
  import { BusinessProductsListing } from './src/components/BusinessProductsListing';
11
15
  import { CartContent } from './src/components/CartContent';
12
16
  import { BusinessCart } from './src/components/BusinessCart';
13
17
  import { Checkout } from './src/components/Checkout';
18
+ import { FloatingButton } from './src/components/FloatingButton';
14
19
  import { ForgotPasswordForm } from './src/components/ForgotPasswordForm';
15
20
  import { MomentOption } from './src/components/MomentOption';
16
21
  import { OrdersOption } from './src/components/OrdersOption';
@@ -24,6 +29,7 @@ import { ReviewProducts } from './src/components/ReviewProducts';
24
29
  import { ReviewDriver } from './src/components/ReviewDriver';
25
30
  import { UserProfile } from './src/components/UserProfile';
26
31
  import { MessageListing } from './src/components/MessageListing';
32
+ import { Messages } from './src/components/Messages';
27
33
  import { Help } from './src/components/Help';
28
34
  import { HelpAccountAndPayment } from './src/components/HelpAccountAndPayment';
29
35
  import { HelpGuide } from './src/components/HelpGuide';
@@ -31,11 +37,18 @@ import { HelpOrder } from './src/components/HelpOrder';
31
37
  import { NetworkError } from './src/components/NetworkError';
32
38
  import { NotFoundSource } from './src/components/NotFoundSource';
33
39
  import { OrderTypeSelector } from './src/components/OrderTypeSelector';
40
+ import { SearchBar } from './src/components/SearchBar';
34
41
  import { Wallets } from './src/components/Wallets';
35
42
  import { PaymentOptionWallet } from './src/components/PaymentOptionWallet';
36
43
  import { ProductForm } from './src/components/ProductForm';
37
44
  import { UpsellingProducts } from './src/components/UpsellingProducts';
38
45
  import { UserVerification } from './src/components/UserVerification';
46
+ import { LastOrders } from './src/components/LastOrders';
47
+ import NavBar from './src/components/NavBar';
48
+ import { BusinessTypeFilter } from './src/components/BusinessTypeFilter';
49
+ import { BusinessController } from './src/components/BusinessController';
50
+ import { BusinessFeaturedController } from './src/components/BusinessFeaturedController';
51
+ import { HighestRatedBusinesses } from './src/components/HighestRatedBusinesses';
39
52
 
40
53
  import { Toast } from './src/components/shared/OToast';
41
54
  import {
@@ -52,6 +65,7 @@ import {
52
65
  OAlert,
53
66
  OModal,
54
67
  OBottomPopup,
68
+ HeaderTitle
55
69
  } from './src/components/shared';
56
70
 
57
71
  import { Container } from './src/layouts/Container';
@@ -66,6 +80,7 @@ import {
66
80
  export {
67
81
  AddressForm,
68
82
  AddressDetails,
83
+ AnalyticsSegment,
69
84
  Home as HomeView,
70
85
  SignupForm,
71
86
  LoginForm,
@@ -75,7 +90,7 @@ export {
75
90
  BusinessesListing,
76
91
  BusinessProductsListing,
77
92
  CartContent,
78
- BusinessCart,
93
+ BusinessCart,
79
94
  Checkout,
80
95
  ForgotPasswordForm,
81
96
  MomentOption,
@@ -90,6 +105,7 @@ export {
90
105
  BusinessMenuList,
91
106
  UserProfile,
92
107
  MessageListing,
108
+ Messages,
93
109
  Help,
94
110
  HelpAccountAndPayment,
95
111
  HelpGuide,
@@ -97,11 +113,21 @@ export {
97
113
  NetworkError,
98
114
  NotFoundSource,
99
115
  OrderTypeSelector,
100
- Wallets,
101
- PaymentOptionWallet,
102
- ProductForm,
103
- UpsellingProducts,
104
- UserVerification,
116
+ Wallets,
117
+ PaymentOptionWallet,
118
+ ProductForm,
119
+ UpsellingProducts,
120
+ UserVerification,
121
+ BusinessBasicInformation,
122
+ BusinessProductsCategories,
123
+ BusinessProductsList,
124
+ FloatingButton,
125
+ SearchBar,
126
+ LastOrders,
127
+ BusinessTypeFilter,
128
+ BusinessController,
129
+ BusinessFeaturedController,
130
+ HighestRatedBusinesses,
105
131
 
106
132
  // OComponents
107
133
  Toast,
@@ -118,10 +144,12 @@ export {
118
144
  OAlert,
119
145
  OModal,
120
146
  OBottomPopup,
147
+ HeaderTitle,
121
148
 
122
149
  // layout
123
150
  Container,
124
151
  SafeAreaContainer,
152
+ NavBar,
125
153
 
126
154
  // utils
127
155
  _retrieveStoreData,
@@ -108,6 +108,9 @@ const AddressFormUI = (props: AddressFormParams) => {
108
108
  top: 12,
109
109
  zIndex: 1002,
110
110
  },
111
+ wrapperNavbar: Platform.OS === 'ios'
112
+ ? { paddingVertical: 0, paddingHorizontal: 40 }
113
+ : { paddingVertical: 20, paddingHorizontal: 40 }
111
114
  });
112
115
 
113
116
  const [, t] = useLanguage();
@@ -500,16 +503,18 @@ const AddressFormUI = (props: AddressFormParams) => {
500
503
  keyboardShouldPersistTaps='always'
501
504
  listViewDisplayed={false}
502
505
  >
503
- <NavBar
504
- title={t('WHERE_DO_WE_DELIVERY', 'Where do we delivery?')}
505
- titleAlign={'center'}
506
- onActionLeft={goToBack}
507
- showCall={false}
508
- paddingTop={20}
509
- btnStyle={{ paddingLeft: 40 }}
510
- titleStyle={{ fontSize: 14 }}
511
- titleWrapStyle={{ paddingHorizontal: 0 }}
512
- />
506
+ <View style={styles.wrapperNavbar}>
507
+ <NavBar
508
+ title={t('WHERE_DO_WE_DELIVERY', 'Where do we delivery?')}
509
+ titleAlign={'center'}
510
+ onActionLeft={goToBack}
511
+ showCall={false}
512
+ btnStyle={{ paddingLeft: 0 }}
513
+ style={{ flexDirection: 'column', alignItems: 'flex-start' }}
514
+ titleWrapStyle={{ paddingHorizontal: 0 }}
515
+ titleStyle={{ marginRight: 0, marginLeft: 0 }}
516
+ />
517
+ </View>
513
518
  <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
514
519
  <AddressFormContainer style={{ height: 600, overflow: 'scroll' }}>
515
520
  <View>
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect } from 'react'
2
2
  import { AddressList as AddressListController, useLanguage, useOrder, useSession } from 'ordering-components/native'
3
3
  import { AddressListContainer, AddressItem } from './styles'
4
- import { StyleSheet, View } from 'react-native'
4
+ import { Platform, StyleSheet, View } from 'react-native'
5
5
  import { OButton, OText, OAlert, OModal, OIcon } from '../shared'
6
6
  import { Container } from '../../layouts/Container'
7
7
  import { AddressListParams } from '../../types'
@@ -261,6 +261,32 @@ const AddressListUI = (props: AddressListParams) => {
261
261
  )}
262
262
  {!addressList.loading && !addressList.error && (
263
263
  <>
264
+ {addressList?.addresses?.length === 0 && (
265
+ <View
266
+ style={{
267
+ flexDirection: 'column',
268
+ paddingHorizontal: 10,
269
+ paddingTop: 20
270
+ }}
271
+ >
272
+ <OText
273
+ size={24}
274
+ lineHeight={36}
275
+ weight={Platform.OS === 'ios' ? '600' : 'bold'}
276
+ style={{
277
+ textAlign: 'center',
278
+ marginRight: 40,
279
+ color: theme.colors.textNormal,
280
+ paddingHorizontal: 0,
281
+ width: '100%',
282
+ marginLeft: 0
283
+ }}
284
+ >
285
+ {t('ADDRESS_LIST', 'Address List')}
286
+ </OText>
287
+ </View>
288
+ )}
289
+
264
290
  <OButton
265
291
  text={t('ADD_NEW_ADDRESS', 'Add new Address')}
266
292
  imgRightSrc=''
@@ -0,0 +1,127 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { createClient, AnalyticsProvider } from '@segment/analytics-react-native';
3
+ import { useEvent, useConfig } from 'ordering-components/native';
4
+
5
+ export const AnalyticsSegment = (props: any) => {
6
+ const { children } = props
7
+
8
+ const [events] = useEvent()
9
+ const [configState] = useConfig()
10
+ const [segmentClient, setSegmentClient] = useState<any>({})
11
+
12
+ const handleClickProduct = (product: any) => {
13
+ segmentClient.track('Product Clicked', {
14
+ id: product.id,
15
+ name: product.name,
16
+ category: product.category_id,
17
+ price: product.price
18
+ })
19
+ }
20
+
21
+ const handleProductAdded = (product: any) => {
22
+ segmentClient.track('Product Added', {
23
+ id: product.id,
24
+ name: product.name,
25
+ category: product.category_id,
26
+ price: product.price,
27
+ quantity: product.quantity
28
+ })
29
+ }
30
+
31
+ const handleProductRemoved = (product: any) => {
32
+ segmentClient.track('Product Removed', {
33
+ id: product.id,
34
+ name: product.name,
35
+ category: product.category_id,
36
+ price: product.price,
37
+ quantity: product.quantity
38
+ })
39
+ }
40
+
41
+ const handleOrderPlaced = (order: any) => {
42
+ segmentClient.track('Order Placed', {
43
+ id: order.id,
44
+ affiliation: order.business?.name,
45
+ revenue: order.total,
46
+ tax: order.tax_total,
47
+ shipping: order.delivery_zone_price
48
+ })
49
+ segmentClient.track('Payment Info Entered', {
50
+ order: order.id,
51
+ business: order.business?.name,
52
+ business_id: order.business_id,
53
+ total: order.total,
54
+ tax: order.tax_total,
55
+ delivery: order.delivery_zone_price,
56
+ paymethod: order.paymethod
57
+ })
58
+ }
59
+
60
+ const handleUpdateOrder = (order: any) => {
61
+ segmentClient.track('Order Updated', {
62
+ id: order.id,
63
+ affiliation: order.business?.name,
64
+ revenue: order.total,
65
+ tax: order.tax_total,
66
+ shipping: order.delivery_zone_price
67
+ })
68
+ }
69
+
70
+ const handleAddOrder = (order: any) => {
71
+ segmentClient.track('Order Added', {
72
+ id: order.id,
73
+ affiliation: order.business?.name,
74
+ revenue: order.total,
75
+ tax: order.tax_total,
76
+ shipping: order.delivery_zone_price
77
+ })
78
+ }
79
+
80
+ const handleLogin = (data: any) => {
81
+ segmentClient.identify(data.id, {
82
+ email: data.email,
83
+ name: data.name
84
+ })
85
+ }
86
+
87
+ useEffect(() => {
88
+ if (segmentClient?.config?.writeKey) {
89
+ events.on('product_clicked', handleClickProduct)
90
+ events.on('userLogin', handleLogin)
91
+ events.on('product_added', handleProductAdded)
92
+ events.on('order_placed', handleOrderPlaced)
93
+ events.on('order_updated', handleUpdateOrder)
94
+ events.on('order_added', handleAddOrder)
95
+ events.on('cart_product_removed', handleProductRemoved)
96
+ }
97
+ return () => {
98
+ if (segmentClient?.config?.writeKey) {
99
+ events.off('product_clicked', handleClickProduct)
100
+ events.off('userLogin', handleLogin)
101
+ events.off('product_added', handleProductAdded)
102
+ events.off('order_placed', handleOrderPlaced)
103
+ events.off('order_updated', handleUpdateOrder)
104
+ events.off('order_added', handleAddOrder)
105
+ events.off('cart_product_removed', handleProductRemoved)
106
+ }
107
+ }
108
+ }, [segmentClient])
109
+
110
+ useEffect(() => {
111
+ if (configState?.configs?.segment_track_id?.value) {
112
+ const _segmentClient: any = createClient({
113
+ writeKey: configState?.configs?.segment_track_id?.value
114
+ });
115
+ setSegmentClient(_segmentClient)
116
+ }
117
+ }, [configState])
118
+
119
+ return (
120
+ <>
121
+ <AnalyticsProvider client={segmentClient}>
122
+ {children}
123
+ </AnalyticsProvider>
124
+ </>
125
+
126
+ )
127
+ }