ordering-ui-react-native 0.17.6 → 0.17.7-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 (212) hide show
  1. package/package.json +5 -5
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessInformation/index.tsx +11 -4
  4. package/src/components/BusinessInformation/styles.tsx +2 -2
  5. package/src/components/BusinessesListing/index.tsx +1 -1
  6. package/src/components/OrderCreating/index.tsx +1 -21
  7. package/src/components/PaymentOptionsWebView/index.tsx +119 -120
  8. package/src/components/SingleProductReview/index.tsx +7 -4
  9. package/src/components/StripeMethodForm/index.tsx +6 -14
  10. package/src/components/VerifyPhone/styles.tsx +1 -2
  11. package/src/components/shared/OToast.tsx +4 -4
  12. package/src/utils/index.tsx +7 -1
  13. package/themes/business/index.tsx +2 -0
  14. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +265 -240
  15. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
  16. package/themes/business/src/components/BusinessController/index.tsx +0 -1
  17. package/themes/business/src/components/Chat/index.tsx +118 -107
  18. package/themes/business/src/components/DriverMap/index.tsx +22 -9
  19. package/themes/business/src/components/GoogleMap/index.tsx +58 -57
  20. package/themes/business/src/components/LoginForm/Otp/index.tsx +120 -0
  21. package/themes/business/src/components/LoginForm/Otp/styles.tsx +7 -0
  22. package/themes/business/src/components/LoginForm/index.tsx +238 -80
  23. package/themes/business/src/components/LoginForm/styles.tsx +10 -0
  24. package/themes/business/src/components/MapView/index.tsx +18 -7
  25. package/themes/business/src/components/NewOrderNotification/index.tsx +43 -50
  26. package/themes/business/src/components/OrderDetails/Delivery.tsx +4 -3
  27. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +96 -50
  28. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +59 -62
  29. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +195 -0
  30. package/themes/business/src/components/OrderDetailsLogistic/styles.tsx +5 -0
  31. package/themes/business/src/components/OrderMessage/index.tsx +18 -17
  32. package/themes/business/src/components/OrderSummary/index.tsx +113 -121
  33. package/themes/business/src/components/OrdersOption/index.tsx +32 -75
  34. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +250 -0
  35. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
  36. package/themes/business/src/components/PreviousOrders/index.tsx +445 -243
  37. package/themes/business/src/components/PreviousOrders/styles.tsx +31 -3
  38. package/themes/business/src/components/ProductItemAccordion/index.tsx +27 -3
  39. package/themes/business/src/components/ReviewCustomer/index.tsx +41 -24
  40. package/themes/business/src/components/StoresList/index.tsx +2 -2
  41. package/themes/business/src/components/shared/OLink.tsx +33 -13
  42. package/themes/business/src/components/shared/OModal.tsx +16 -9
  43. package/themes/business/src/components/shared/OText.tsx +8 -2
  44. package/themes/business/src/types/index.tsx +33 -2
  45. package/themes/business/src/utils/index.tsx +51 -0
  46. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  47. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  48. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  49. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -1
  50. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  51. package/themes/kiosk/src/components/LoginForm/Otp/index.tsx +92 -0
  52. package/themes/kiosk/src/components/LoginForm/Otp/styles.tsx +7 -0
  53. package/themes/kiosk/src/components/LoginForm/index.tsx +473 -151
  54. package/themes/kiosk/src/components/LoginForm/styles.tsx +14 -1
  55. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  56. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  57. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  58. package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +3 -2
  59. package/themes/kiosk/src/components/PhoneInputNumber/styles.tsx +1 -3
  60. package/themes/kiosk/src/components/ProductForm/index.tsx +1 -14
  61. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  62. package/themes/kiosk/src/components/shared/OModal.tsx +14 -11
  63. package/themes/kiosk/src/layouts/Container.tsx +7 -1
  64. package/themes/kiosk/src/types/index.d.ts +13 -0
  65. package/themes/kiosk/src/utils/index.tsx +15 -0
  66. package/themes/original/index.tsx +8 -0
  67. package/themes/original/src/components/AddressDetails/index.tsx +29 -11
  68. package/themes/original/src/components/AddressForm/index.tsx +41 -16
  69. package/themes/original/src/components/AddressList/index.tsx +26 -21
  70. package/themes/original/src/components/AddressList/styles.tsx +4 -2
  71. package/themes/original/src/components/AnalyticsSegment/index.tsx +189 -9
  72. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  73. package/themes/original/src/components/BusinessBasicInformation/index.tsx +125 -82
  74. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +9 -4
  75. package/themes/original/src/components/BusinessController/index.tsx +145 -68
  76. package/themes/original/src/components/BusinessController/styles.tsx +22 -9
  77. package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
  78. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
  79. package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
  80. package/themes/original/src/components/BusinessItemAccordion/index.tsx +24 -23
  81. package/themes/original/src/components/BusinessListingSearch/index.tsx +52 -24
  82. package/themes/original/src/components/BusinessPreorder/index.tsx +97 -16
  83. package/themes/original/src/components/BusinessProductsList/index.tsx +20 -11
  84. package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
  85. package/themes/original/src/components/BusinessProductsListing/index.tsx +617 -490
  86. package/themes/original/src/components/BusinessProductsListing/styles.tsx +7 -13
  87. package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
  88. package/themes/original/src/components/BusinessTypeFilter/index.tsx +3 -3
  89. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  90. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +98 -78
  91. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -9
  92. package/themes/original/src/components/BusinessesListing/index.tsx +5 -3
  93. package/themes/original/src/components/Cart/index.tsx +88 -43
  94. package/themes/original/src/components/CartContent/index.tsx +110 -19
  95. package/themes/original/src/components/CartContent/styles.tsx +15 -1
  96. package/themes/original/src/components/Checkout/index.tsx +311 -178
  97. package/themes/original/src/components/Checkout/styles.tsx +4 -2
  98. package/themes/original/src/components/CitiesControl/index.tsx +89 -0
  99. package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
  100. package/themes/original/src/components/CouponControl/index.tsx +10 -3
  101. package/themes/original/src/components/DriverTips/index.tsx +52 -37
  102. package/themes/original/src/components/DriverTips/styles.tsx +2 -1
  103. package/themes/original/src/components/Favorite/index.tsx +7 -4
  104. package/themes/original/src/components/Favorite/styles.tsx +1 -1
  105. package/themes/original/src/components/FavoriteList/index.tsx +51 -80
  106. package/themes/original/src/components/FloatingButton/index.tsx +1 -2
  107. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  108. package/themes/original/src/components/GPSButton/styles.ts +3 -3
  109. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +96 -0
  110. package/themes/original/src/components/GiftCard/GiftCardUI/styles.tsx +5 -0
  111. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +100 -0
  112. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +8 -0
  113. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +178 -0
  114. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +8 -0
  115. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +165 -0
  116. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +9 -0
  117. package/themes/original/src/components/Help/index.tsx +8 -8
  118. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +11 -22
  119. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +6 -0
  120. package/themes/original/src/components/HelpGuide/index.tsx +12 -16
  121. package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
  122. package/themes/original/src/components/HelpOrder/index.tsx +12 -25
  123. package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
  124. package/themes/original/src/components/Home/index.tsx +13 -4
  125. package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
  126. package/themes/original/src/components/LastOrder/index.tsx +1 -34
  127. package/themes/original/src/components/LoginForm/Otp/index.tsx +89 -73
  128. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  129. package/themes/original/src/components/LoginForm/index.tsx +43 -19
  130. package/themes/original/src/components/LottieAnimation/index.tsx +78 -0
  131. package/themes/original/src/components/MessageListing/index.tsx +16 -42
  132. package/themes/original/src/components/Messages/index.tsx +32 -10
  133. package/themes/original/src/components/MomentOption/index.tsx +195 -88
  134. package/themes/original/src/components/MultiCart/index.tsx +50 -0
  135. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +117 -96
  136. package/themes/original/src/components/MultiCheckout/index.tsx +248 -83
  137. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
  138. package/themes/original/src/components/MultiOrdersDetails/index.tsx +67 -20
  139. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
  140. package/themes/original/src/components/MyOrders/index.tsx +66 -17
  141. package/themes/original/src/components/NavBar/index.tsx +6 -11
  142. package/themes/original/src/components/Notifications/index.tsx +144 -0
  143. package/themes/original/src/components/Notifications/styles.tsx +20 -0
  144. package/themes/original/src/components/OrderDetails/OrderEta.tsx +61 -0
  145. package/themes/original/src/components/OrderDetails/index.tsx +262 -347
  146. package/themes/original/src/components/OrderDetails/styles.tsx +10 -1
  147. package/themes/original/src/components/OrderItAgain/index.tsx +47 -43
  148. package/themes/original/src/components/OrderProgress/index.tsx +74 -112
  149. package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
  150. package/themes/original/src/components/OrderSummary/index.tsx +67 -29
  151. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -3
  152. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +28 -19
  153. package/themes/original/src/components/OrdersOption/index.tsx +99 -89
  154. package/themes/original/src/components/PageBanner/index.tsx +171 -0
  155. package/themes/original/src/components/PageBanner/styles.tsx +11 -0
  156. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
  157. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  158. package/themes/original/src/components/PaymentOptions/index.tsx +3 -3
  159. package/themes/original/src/components/PhoneInputNumber/index.tsx +3 -3
  160. package/themes/original/src/components/PlaceSpot/index.tsx +12 -6
  161. package/themes/original/src/components/PreviousOrders/index.tsx +3 -2
  162. package/themes/original/src/components/ProductForm/index.tsx +240 -261
  163. package/themes/original/src/components/ProductForm/styles.tsx +4 -7
  164. package/themes/original/src/components/ProductItemAccordion/index.tsx +197 -138
  165. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -10
  166. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +1 -2
  167. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  168. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -49
  169. package/themes/original/src/components/ProfessionalProfile/index.tsx +54 -14
  170. package/themes/original/src/components/Promotions/index.tsx +234 -220
  171. package/themes/original/src/components/Promotions/styles.tsx +10 -3
  172. package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
  173. package/themes/original/src/components/ReviewOrder/index.tsx +26 -9
  174. package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
  175. package/themes/original/src/components/ReviewProducts/index.tsx +7 -4
  176. package/themes/original/src/components/ReviewTrigger/index.tsx +27 -9
  177. package/themes/original/src/components/ReviewTrigger/styles.tsx +8 -1
  178. package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
  179. package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
  180. package/themes/original/src/components/ServiceForm/index.tsx +377 -270
  181. package/themes/original/src/components/Sessions/index.tsx +11 -8
  182. package/themes/original/src/components/Sessions/styles.tsx +5 -0
  183. package/themes/original/src/components/SignupForm/index.tsx +79 -66
  184. package/themes/original/src/components/SingleOrderCard/index.tsx +148 -62
  185. package/themes/original/src/components/SingleOrderCard/styles.tsx +11 -9
  186. package/themes/original/src/components/SingleProductCard/index.tsx +111 -56
  187. package/themes/original/src/components/SingleProductCard/styles.tsx +27 -13
  188. package/themes/original/src/components/SingleProductReview/index.tsx +38 -5
  189. package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
  190. package/themes/original/src/components/StripeCardsList/index.tsx +1 -1
  191. package/themes/original/src/components/StripeElementsForm/index.tsx +4 -1
  192. package/themes/original/src/components/UpsellingProducts/index.tsx +238 -218
  193. package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
  194. package/themes/original/src/components/UserDetails/index.tsx +8 -4
  195. package/themes/original/src/components/UserFormDetails/index.tsx +53 -54
  196. package/themes/original/src/components/UserProfile/index.tsx +58 -35
  197. package/themes/original/src/components/UserProfile/styles.ts +17 -0
  198. package/themes/original/src/components/UserProfileForm/index.tsx +21 -28
  199. package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
  200. package/themes/original/src/components/Wallets/index.tsx +31 -17
  201. package/themes/original/src/components/Wallets/styles.tsx +2 -0
  202. package/themes/original/src/components/shared/CardAnimation.tsx +47 -0
  203. package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
  204. package/themes/original/src/components/shared/OBottomPopup.tsx +1 -1
  205. package/themes/original/src/components/shared/OButton.tsx +6 -2
  206. package/themes/original/src/components/shared/OIcon.tsx +8 -1
  207. package/themes/original/src/components/shared/OInput.tsx +10 -1
  208. package/themes/original/src/components/shared/OModal.tsx +3 -3
  209. package/themes/original/src/layouts/Container.tsx +13 -9
  210. package/themes/original/src/types/index.tsx +43 -9
  211. package/themes/original/src/utils/index.tsx +375 -58
  212. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,9 +1,8 @@
1
1
  import React, { useEffect } from 'react'
2
2
  import { AddressList as AddressListController, useLanguage, useOrder, useSession } from 'ordering-components/native'
3
- import { AddressListContainer, AddressItem } from './styles'
3
+ import { AddressItem, Container } from './styles'
4
4
  import { Platform, RefreshControl, StyleSheet, View } from 'react-native'
5
5
  import { OButton, OText, OAlert, OModal, OIcon } from '../shared'
6
- import { Container } from '../../layouts/Container'
7
6
  import { AddressListParams } from '../../types'
8
7
  import { NotFoundSource } from '../NotFoundSource'
9
8
  import NavBar from '../NavBar'
@@ -40,9 +39,6 @@ const AddressListUI = (props: AddressListParams) => {
40
39
 
41
40
  const [isProfile, setIsProfile] = useState(isFromProfile || route?.params?.isFromProfile);
42
41
 
43
- const goToBack = () => navigation?.canGoBack() && navigation.goBack()
44
- const onNavigationRedirect = (route: string, params?: any) => navigation.navigate(route, params)
45
-
46
42
  const onNavigatorRedirect = () => {
47
43
  if (route && (isFromBusinesses || isGoBack)) {
48
44
  isGoBack ? goToBack() : onNavigationRedirect('BottomTab')
@@ -104,7 +100,6 @@ const AddressListUI = (props: AddressListParams) => {
104
100
  const handleSetAddress = (address: any) => {
105
101
  if (address.id === orderState?.options?.address_id) return
106
102
  handleSetDefault(address)
107
- onNavigatorRedirect()
108
103
  }
109
104
 
110
105
  const handleSaveAddress = (address: any) => {
@@ -133,13 +128,21 @@ const AddressListUI = (props: AddressListParams) => {
133
128
  }
134
129
  }
135
130
 
131
+ const goToBack = () => navigation?.canGoBack() && navigation.goBack()
132
+ const onNavigationRedirect = (route: string, params?: any) => navigation.navigate(route, params)
133
+
134
+ useEffect(() => {
135
+ if (orderState.loading && auth && orderState.options.address?.location) {
136
+ onNavigatorRedirect()
137
+ }
138
+ }, [orderState.options.address])
139
+
136
140
  useEffect(() => {
137
141
  console.log('From profile : ' + isProfile)
138
142
  }, [])
139
143
 
140
144
  return (
141
- <Container
142
- noPadding
145
+ <Container
143
146
  refreshControl={
144
147
  <RefreshControl
145
148
  refreshing={refreshing}
@@ -147,17 +150,18 @@ const AddressListUI = (props: AddressListParams) => {
147
150
  />
148
151
  }
149
152
  >
150
- {isProfile && (
151
- <NavBar
152
- title={t('SAVED_PLACES', 'My saved places')}
153
- titleAlign={'center'}
154
- onActionLeft={goToBack}
155
- showCall={false}
156
- style={{ paddingHorizontal: 40, paddingVertical: Platform.OS === 'ios' ? 0 : 20, marginTop: Platform.OS === 'ios' ? 0 : 30 }}
157
- />
158
- )}
159
153
  {(!addressList.loading || (isFromProductsList || isFromBusinesses || isFromProfile || isProfile)) && (
160
- <AddressListContainer>
154
+ <>
155
+ {isProfile && (
156
+ <NavBar
157
+ title={t('SAVED_PLACES', 'My saved places')}
158
+ titleAlign={'center'}
159
+ onActionLeft={goToBack}
160
+ showCall={false}
161
+ paddingTop={10}
162
+ btnStyle={{ paddingLeft: 0 }}
163
+ />
164
+ )}
161
165
  {
162
166
  route &&
163
167
  (
@@ -173,8 +177,8 @@ const AddressListUI = (props: AddressListParams) => {
173
177
  onActionLeft={() => goToBack()}
174
178
  showCall={false}
175
179
  btnStyle={{ paddingLeft: 0 }}
176
- paddingTop={0}
177
- style={{ marginTop: Platform.OS === 'ios' ? 0 : 40 }}
180
+ paddingTop={10}
181
+ style={{ marginTop: 0 }}
178
182
  titleWrapStyle={{ paddingHorizontal: 0 }}
179
183
  titleStyle={{ marginLeft: 0, marginRight: 0 }}
180
184
  />
@@ -323,7 +327,8 @@ const AddressListUI = (props: AddressListParams) => {
323
327
  />
324
328
  </>
325
329
  )}
326
- </AddressListContainer>
330
+ </>
331
+
327
332
  )}
328
333
  </Container>
329
334
  )
@@ -1,10 +1,12 @@
1
1
  import styled from 'styled-components/native'
2
2
 
3
- export const AddressListContainer = styled.View`
3
+ export const Container = styled.ScrollView`
4
+ position: relative;
4
5
  flex: 1;
5
6
  paddingLeft: 40px;
6
7
  paddingRight: 40px;
7
- paddingBottom: 20px;
8
+ margin-bottom: 40px;
9
+ padding-top: 10px;
8
10
  `
9
11
 
10
12
  export const AddressItem = styled.TouchableOpacity`
@@ -1,14 +1,46 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { createClient, AnalyticsProvider } from '@segment/analytics-react-native';
3
- import { useEvent, useConfig } from 'ordering-components/native';
3
+ import { useEvent, useConfig, useLanguage } from 'ordering-components/native';
4
4
 
5
5
  export const AnalyticsSegment = (props: any) => {
6
6
  const { children } = props
7
7
 
8
8
  const [events] = useEvent()
9
9
  const [configState] = useConfig()
10
+ const [, t] = useLanguage()
10
11
  const [segmentClient, setSegmentClient] = useState<any>({})
11
12
 
13
+ const handleProductsSearched = (query: any) => {
14
+ segmentClient.track('Products Searched', {
15
+ query: query
16
+ })
17
+ }
18
+
19
+ const handleProductListViewed = (category: any) => {
20
+ segmentClient.track('Product List Viewed', {
21
+ business_id: category?.business_id,
22
+ category_id: category?.id,
23
+ category: category?.name,
24
+ products: category?.products
25
+ })
26
+ }
27
+
28
+ const handlePromotionViewed = (promotion: any) => {
29
+ segmentClient.track('Promotion Viewed', {
30
+ promotion_id: (promotion?.id || '').toString(),
31
+ name: promotion.name,
32
+ position: promotion.position
33
+ })
34
+ }
35
+
36
+ const handlePromotionClicked = (promotion: any) => {
37
+ segmentClient.track('Promotion Clicked', {
38
+ promotion_id: (promotion?.id || '').toString(),
39
+ name: promotion.name,
40
+ position: promotion.position
41
+ })
42
+ }
43
+
12
44
  const handleClickProduct = (product: any) => {
13
45
  segmentClient.track('Product Clicked', {
14
46
  id: product.id,
@@ -18,6 +50,15 @@ export const AnalyticsSegment = (props: any) => {
18
50
  })
19
51
  }
20
52
 
53
+ const handleProductViewed = (product: any) => {
54
+ segmentClient.track('Product Viewed', {
55
+ id: product.id,
56
+ name: product.name,
57
+ category: product.category_id,
58
+ price: product.price
59
+ })
60
+ }
61
+
21
62
  const handleProductAdded = (product: any) => {
22
63
  segmentClient.track('Product Added', {
23
64
  id: product.id,
@@ -38,6 +79,23 @@ export const AnalyticsSegment = (props: any) => {
38
79
  })
39
80
  }
40
81
 
82
+ const handleCartViewed = (cart: any) => {
83
+ segmentClient.track('Cart Viewed', {
84
+ id: cart.uuid,
85
+ products: cart?.products
86
+ })
87
+ }
88
+
89
+ const handleCheckoutStarted = (cart: any) => {
90
+ segmentClient.track('Checkout Started', {
91
+ cart_id: cart?.uuid,
92
+ affiliation: cart?.business?.name,
93
+ revenue: cart?.total,
94
+ tax: cart?.tax_total,
95
+ shipping: cart?.delivery_zone_price
96
+ })
97
+ }
98
+
41
99
  const handleOrderPlaced = (order: any) => {
42
100
  segmentClient.track('Order Placed', {
43
101
  id: order.id,
@@ -65,6 +123,35 @@ export const AnalyticsSegment = (props: any) => {
65
123
  tax: order.tax_total,
66
124
  shipping: order.delivery_zone_price
67
125
  })
126
+
127
+ if (order?.history?.length) {
128
+ const lasthistory = order.history[order.history.length - 1]
129
+ if (lasthistory?.data) {
130
+ lasthistory.data.forEach(item => {
131
+ if (item.attribute === 'status') {
132
+ if (item.new === 15) {
133
+ segmentClient.track('Order Completed', {
134
+ id: order.id,
135
+ affiliation: order.business?.name,
136
+ revenue: order.total,
137
+ tax: order.tax_total,
138
+ shipping: order.delivery_zone_price
139
+ })
140
+ }
141
+ const orderCancelled = [2, 5, 6, 10, 12, 16, 17]
142
+ if (orderCancelled.includes(item.new)) {
143
+ segmentClient.track('Order Cancelled', {
144
+ id: order.id,
145
+ affiliation: order.business?.name,
146
+ revenue: order.total,
147
+ tax: order.tax_total,
148
+ shipping: order.delivery_zone_price
149
+ })
150
+ }
151
+ }
152
+ })
153
+ }
154
+ }
68
155
  }
69
156
 
70
157
  const handleAddOrder = (order: any) => {
@@ -77,6 +164,51 @@ export const AnalyticsSegment = (props: any) => {
77
164
  })
78
165
  }
79
166
 
167
+ const handleCouponEntered = (cart: any) => {
168
+ segmentClient.track('Coupon Entered', {
169
+ cart_id: cart.uuid,
170
+ coupon: cart.coupon
171
+ })
172
+ }
173
+
174
+ const handleCouponApplied = (cart: any) => {
175
+ const coupon: any = cart?.offers?.find(offer => offer.type === 2)
176
+ if (coupon) {
177
+ segmentClient.track('Coupon Applied', {
178
+ cart_id: cart.uuid,
179
+ coupon_id: coupon.id,
180
+ coupon_name: coupon?.name,
181
+ discount: coupon?.summary?.discount
182
+ })
183
+ }
184
+ }
185
+
186
+ const handleCouponDenied = (coupon: any) => {
187
+ segmentClient.track('Coupon Denied', {
188
+ business_id: coupon.business_id,
189
+ coupon: coupon.coupon,
190
+ user_id: coupon.user.id,
191
+ reason: typeof coupon.reason === 'string' ? t(coupon.reason) : t(coupon.reason[0])
192
+ })
193
+ }
194
+
195
+ const handleCouponRemoved = (coupon: any) => {
196
+ segmentClient.track('Coupon Removed', {
197
+ business_id: coupon.business_id,
198
+ coupon_id: coupon.offer_id,
199
+ })
200
+ }
201
+
202
+ const handleProductReviewed = (products: any) => {
203
+ products.forEach((product: any) => {
204
+ segmentClient.track('Product Reviewed', {
205
+ product_id: product.product_id,
206
+ review_body: product.comment,
207
+ rating: product.qualification
208
+ })
209
+ })
210
+ }
211
+
80
212
  const handleLogin = (data: any) => {
81
213
  segmentClient.identify(data.id, {
82
214
  email: data.email,
@@ -84,25 +216,74 @@ export const AnalyticsSegment = (props: any) => {
84
216
  })
85
217
  }
86
218
 
219
+ const handleProductAddedToWishlist = (product: any) => {
220
+ segmentClient.track('Product Added to Wishlist', product)
221
+ }
222
+
223
+ const handleProductRemovedFromWishlist = (product: any) => {
224
+ segmentClient.track('Product Removed from Wishlist', product)
225
+ }
226
+
227
+ const handleWishlistProductAddedToCart = (product: any, result: any) => {
228
+ segmentClient.track('Wishlist Product Added to Cart', {
229
+ cart_id: result.uuid,
230
+ product_id: product.id,
231
+ name: product.name,
232
+ category: product.categoryId,
233
+ price: product.price,
234
+ quantity: product.quantity
235
+ })
236
+ }
237
+
87
238
  useEffect(() => {
88
239
  if (segmentClient?.config?.writeKey) {
240
+ events.on('products_searched', handleProductsSearched)
241
+ events.on('product_list_viewed', handleProductListViewed)
242
+ events.on('promotion_viewed', handlePromotionViewed)
243
+ events.on('promotion_clicked', handlePromotionClicked)
89
244
  events.on('product_clicked', handleClickProduct)
90
- events.on('userLogin', handleLogin)
245
+ events.on('product_viewed', handleProductViewed)
91
246
  events.on('product_added', handleProductAdded)
92
- events.on('order_placed', handleOrderPlaced)
247
+ events.on('cart_product_removed', handleProductRemoved)
248
+ events.on('cart_viewed', handleCartViewed)
249
+ events.on('checkout_started', handleCheckoutStarted)
93
250
  events.on('order_updated', handleUpdateOrder)
251
+ events.on('coupon_entered', handleCouponEntered)
252
+ events.on('offer_applied', handleCouponApplied)
253
+ events.on('offer_denied', handleCouponDenied)
254
+ events.on('offer_removed', handleCouponRemoved)
255
+ events.on('product_reviewed', handleProductReviewed)
256
+ events.on('userLogin', handleLogin)
257
+ events.on('order_placed', handleOrderPlaced)
94
258
  events.on('order_added', handleAddOrder)
95
- events.on('cart_product_removed', handleProductRemoved)
259
+ events.on('product_added_to_wishlist', handleProductAddedToWishlist)
260
+ events.on('product_removed_from_wishlist', handleProductRemovedFromWishlist)
261
+ events.on('wishlist_product_added_to_cart', handleWishlistProductAddedToCart)
96
262
  }
97
263
  return () => {
98
264
  if (segmentClient?.config?.writeKey) {
265
+ events.off('products_searched', handleProductsSearched)
266
+ events.off('product_list_viewed', handleProductListViewed)
267
+ events.off('promotion_viewed', handlePromotionViewed)
268
+ events.off('promotion_clicked', handlePromotionClicked)
99
269
  events.off('product_clicked', handleClickProduct)
100
- events.off('userLogin', handleLogin)
270
+ events.off('product_viewed', handleProductViewed)
101
271
  events.off('product_added', handleProductAdded)
102
- events.off('order_placed', handleOrderPlaced)
272
+ events.off('cart_product_removed', handleProductRemoved)
273
+ events.off('cart_viewed', handleCartViewed)
274
+ events.off('checkout_started', handleCheckoutStarted)
103
275
  events.off('order_updated', handleUpdateOrder)
276
+ events.off('coupon_entered', handleCouponEntered)
277
+ events.off('offer_applied', handleCouponApplied)
278
+ events.off('offer_denied', handleCouponDenied)
279
+ events.off('offer_removed', handleCouponRemoved)
280
+ events.off('product_reviewed', handleProductReviewed)
281
+ events.off('userLogin', handleLogin)
282
+ events.off('order_placed', handleOrderPlaced)
104
283
  events.off('order_added', handleAddOrder)
105
- events.off('cart_product_removed', handleProductRemoved)
284
+ events.off('product_added_to_wishlist', handleProductAddedToWishlist)
285
+ events.off('product_removed_from_wishlist', handleProductRemovedFromWishlist)
286
+ events.off('wishlist_product_added_to_cart', handleWishlistProductAddedToCart)
106
287
  }
107
288
  }
108
289
  }, [segmentClient])
@@ -110,7 +291,7 @@ export const AnalyticsSegment = (props: any) => {
110
291
  useEffect(() => {
111
292
  if (configState?.configs?.segment_track_id?.value) {
112
293
  const _segmentClient: any = createClient({
113
- writeKey: configState?.configs?.segment_track_id?.value
294
+ writeKey: configState?.configs?.segment_track_id?.value,
114
295
  });
115
296
  setSegmentClient(_segmentClient)
116
297
  }
@@ -122,6 +303,5 @@ export const AnalyticsSegment = (props: any) => {
122
303
  {children}
123
304
  </AnalyticsProvider>
124
305
  </>
125
-
126
306
  )
127
307
  }
@@ -21,7 +21,7 @@ export const AppleLogin = (props: any) => {
21
21
  const [{ configs }] = useConfig();
22
22
  const [credentialStateForUser, updateCredentialStateForUser] = useState<any>(-1);
23
23
 
24
- let user : any= null
24
+ let user: any = null
25
25
 
26
26
  const buttonText = auth
27
27
  ? t('CONTINUE_WITH_APPLE', 'Logout with Apple')
@@ -53,7 +53,7 @@ export const AppleLogin = (props: any) => {
53
53
  }
54
54
  }
55
55
 
56
- const fetchAndUpdateCredentialState = async (updateCredentialStateForUser : any) => {
56
+ const fetchAndUpdateCredentialState = async (updateCredentialStateForUser: any) => {
57
57
  if (user === null) {
58
58
  updateCredentialStateForUser('N/A');
59
59
  } else {
@@ -66,7 +66,7 @@ export const AppleLogin = (props: any) => {
66
66
  }
67
67
  }
68
68
 
69
- const onIOSButtonPress = async (updateCredentialStateForUser : any) => {
69
+ const onIOSButtonPress = async (updateCredentialStateForUser: any) => {
70
70
  try {
71
71
  const appleAuthRequestResponse = await appleAuth.performRequest({
72
72
  requestedOperation: appleAuth.Operation.LOGIN,
@@ -79,7 +79,7 @@ export const AppleLogin = (props: any) => {
79
79
  identityToken,
80
80
  authorizationCode
81
81
  } = appleAuthRequestResponse;
82
-
82
+
83
83
  user = newUser;
84
84
 
85
85
  fetchAndUpdateCredentialState(updateCredentialStateForUser).catch(error =>