ordering-ui-react-native 0.17.56 → 0.17.57-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 (211) hide show
  1. package/package.json +8 -7
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessesListing/index.tsx +1 -1
  4. package/src/components/OrderCreating/index.tsx +1 -21
  5. package/src/components/PaymentOptionsWebView/index.tsx +29 -8
  6. package/src/components/PhoneInputNumber/index.tsx +6 -2
  7. package/src/components/StripeMethodForm/index.tsx +136 -102
  8. package/src/components/VerifyPhone/styles.tsx +1 -2
  9. package/src/components/shared/OToast.tsx +4 -4
  10. package/src/types/index.tsx +5 -0
  11. package/src/utils/index.tsx +5 -0
  12. package/themes/business/index.tsx +2 -0
  13. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +265 -240
  14. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
  15. package/themes/business/src/components/BusinessController/index.tsx +0 -1
  16. package/themes/business/src/components/Chat/index.tsx +125 -113
  17. package/themes/business/src/components/DriverMap/index.tsx +17 -6
  18. package/themes/business/src/components/DriverSchedule/index.tsx +42 -5
  19. package/themes/business/src/components/GoogleMap/index.tsx +58 -57
  20. package/themes/business/src/components/LoginForm/Otp/index.tsx +31 -3
  21. package/themes/business/src/components/LoginForm/index.tsx +15 -22
  22. package/themes/business/src/components/MapView/index.tsx +10 -10
  23. package/themes/business/src/components/NewOrderNotification/index.tsx +35 -21
  24. package/themes/business/src/components/NotFoundSource/index.tsx +2 -2
  25. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  26. package/themes/business/src/components/OrderDetails/Delivery.tsx +191 -6
  27. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +93 -50
  28. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +64 -63
  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 +19 -18
  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 +249 -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 +30 -15
  40. package/themes/business/src/components/StoresList/index.tsx +3 -4
  41. package/themes/business/src/components/UserProfileForm/index.tsx +11 -13
  42. package/themes/business/src/components/shared/OLink.tsx +33 -13
  43. package/themes/business/src/components/shared/OModal.tsx +16 -9
  44. package/themes/business/src/components/shared/OText.tsx +8 -2
  45. package/themes/business/src/types/index.tsx +28 -12
  46. package/themes/business/src/utils/index.tsx +29 -2
  47. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  48. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  49. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  50. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  51. package/themes/kiosk/src/components/Intro/index.tsx +16 -1
  52. package/themes/kiosk/src/components/LoginForm/index.tsx +7 -9
  53. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  54. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  55. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  56. package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +2 -2
  57. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  58. package/themes/original/index.tsx +4 -0
  59. package/themes/original/src/components/AddressDetails/index.tsx +28 -10
  60. package/themes/original/src/components/AddressForm/index.tsx +68 -40
  61. package/themes/original/src/components/AddressList/index.tsx +27 -22
  62. package/themes/original/src/components/AddressList/styles.tsx +4 -2
  63. package/themes/original/src/components/AnalyticsSegment/index.tsx +193 -10
  64. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  65. package/themes/original/src/components/AppleLogin/styles.tsx +3 -1
  66. package/themes/original/src/components/BusinessBasicInformation/index.tsx +153 -96
  67. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +10 -12
  68. package/themes/original/src/components/BusinessController/index.tsx +122 -68
  69. package/themes/original/src/components/BusinessController/styles.tsx +23 -4
  70. package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
  71. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
  72. package/themes/original/src/components/BusinessInformation/index.tsx +110 -108
  73. package/themes/original/src/components/BusinessItemAccordion/index.tsx +15 -20
  74. package/themes/original/src/components/BusinessListingSearch/index.tsx +352 -326
  75. package/themes/original/src/components/BusinessListingSearch/styles.tsx +0 -18
  76. package/themes/original/src/components/BusinessPreorder/index.tsx +103 -19
  77. package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -2
  78. package/themes/original/src/components/BusinessProductsList/index.tsx +25 -15
  79. package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
  80. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +1 -1
  81. package/themes/original/src/components/BusinessProductsListing/index.tsx +683 -555
  82. package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -2
  83. package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
  84. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  85. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +96 -91
  86. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -4
  87. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  88. package/themes/original/src/components/Cart/index.tsx +77 -50
  89. package/themes/original/src/components/CartContent/index.tsx +117 -20
  90. package/themes/original/src/components/CartContent/styles.tsx +17 -7
  91. package/themes/original/src/components/Checkout/index.tsx +359 -171
  92. package/themes/original/src/components/Checkout/styles.tsx +4 -2
  93. package/themes/original/src/components/CitiesControl/index.tsx +89 -0
  94. package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
  95. package/themes/original/src/components/CouponControl/index.tsx +10 -3
  96. package/themes/original/src/components/DriverTips/index.tsx +52 -34
  97. package/themes/original/src/components/FacebookLogin/styles.tsx +3 -1
  98. package/themes/original/src/components/Favorite/index.tsx +8 -9
  99. package/themes/original/src/components/Favorite/styles.tsx +1 -1
  100. package/themes/original/src/components/FavoriteList/index.tsx +51 -80
  101. package/themes/original/src/components/FloatingButton/index.tsx +1 -2
  102. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  103. package/themes/original/src/components/GPSButton/index.tsx +6 -4
  104. package/themes/original/src/components/GPSButton/styles.ts +3 -3
  105. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +96 -0
  106. package/themes/original/src/components/GiftCard/GiftCardUI/styles.tsx +5 -0
  107. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +100 -0
  108. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +8 -0
  109. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +191 -0
  110. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +8 -0
  111. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +165 -0
  112. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +9 -0
  113. package/themes/original/src/components/GoogleLogin/styles.tsx +1 -1
  114. package/themes/original/src/components/GoogleMap/index.tsx +15 -4
  115. package/themes/original/src/components/Help/index.tsx +8 -8
  116. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +10 -31
  117. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +5 -3
  118. package/themes/original/src/components/HelpGuide/index.tsx +6 -6
  119. package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
  120. package/themes/original/src/components/HelpOrder/index.tsx +6 -15
  121. package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
  122. package/themes/original/src/components/Home/index.tsx +13 -4
  123. package/themes/original/src/components/LastOrder/index.tsx +1 -34
  124. package/themes/original/src/components/LoginForm/Otp/index.tsx +55 -13
  125. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  126. package/themes/original/src/components/LoginForm/index.tsx +64 -26
  127. package/themes/original/src/components/LottieAnimation/index.tsx +89 -55
  128. package/themes/original/src/components/MessageListing/index.tsx +16 -42
  129. package/themes/original/src/components/Messages/index.tsx +32 -10
  130. package/themes/original/src/components/MomentOption/index.tsx +194 -89
  131. package/themes/original/src/components/MultiCart/index.tsx +50 -0
  132. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +153 -49
  133. package/themes/original/src/components/MultiCheckout/index.tsx +308 -88
  134. package/themes/original/src/components/MultiCheckout/styles.tsx +3 -1
  135. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
  136. package/themes/original/src/components/MultiOrdersDetails/index.tsx +68 -21
  137. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
  138. package/themes/original/src/components/MyOrders/index.tsx +65 -52
  139. package/themes/original/src/components/NavBar/index.tsx +18 -18
  140. package/themes/original/src/components/NotFoundSource/index.tsx +14 -10
  141. package/themes/original/src/components/Notifications/index.tsx +46 -50
  142. package/themes/original/src/components/Notifications/styles.tsx +6 -3
  143. package/themes/original/src/components/OrderDetails/OrderEta.tsx +76 -0
  144. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +15 -3
  145. package/themes/original/src/components/OrderDetails/index.tsx +190 -358
  146. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  147. package/themes/original/src/components/OrderItAgain/index.tsx +3 -1
  148. package/themes/original/src/components/OrderProgress/index.tsx +33 -59
  149. package/themes/original/src/components/OrderSummary/index.tsx +85 -57
  150. package/themes/original/src/components/OrderTypeSelector/index.tsx +1 -1
  151. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +24 -19
  152. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +14 -14
  153. package/themes/original/src/components/OrdersOption/index.tsx +78 -67
  154. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  155. package/themes/original/src/components/PageBanner/index.tsx +106 -31
  156. package/themes/original/src/components/PageBanner/styles.tsx +4 -4
  157. package/themes/original/src/components/PaymentOptionCard/index.tsx +180 -0
  158. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
  159. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  160. package/themes/original/src/components/PaymentOptions/index.tsx +68 -9
  161. package/themes/original/src/components/PhoneInputNumber/index.tsx +3 -3
  162. package/themes/original/src/components/PlaceSpot/index.tsx +12 -6
  163. package/themes/original/src/components/ProductForm/index.tsx +109 -33
  164. package/themes/original/src/components/ProductForm/styles.tsx +5 -7
  165. package/themes/original/src/components/ProductItemAccordion/index.tsx +22 -19
  166. package/themes/original/src/components/ProductOptionSubOption/index.tsx +24 -14
  167. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +3 -4
  168. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  169. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -50
  170. package/themes/original/src/components/ProfessionalProfile/index.tsx +36 -7
  171. package/themes/original/src/components/Promotions/index.tsx +234 -220
  172. package/themes/original/src/components/Promotions/styles.tsx +10 -3
  173. package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
  174. package/themes/original/src/components/ReviewOrder/index.tsx +26 -9
  175. package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
  176. package/themes/original/src/components/ReviewProducts/index.tsx +23 -11
  177. package/themes/original/src/components/ReviewTrigger/index.tsx +27 -9
  178. package/themes/original/src/components/ReviewTrigger/styles.tsx +8 -1
  179. package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
  180. package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
  181. package/themes/original/src/components/ServiceForm/index.tsx +66 -17
  182. package/themes/original/src/components/Sessions/index.tsx +11 -8
  183. package/themes/original/src/components/Sessions/styles.tsx +5 -0
  184. package/themes/original/src/components/SignupForm/index.tsx +43 -20
  185. package/themes/original/src/components/SingleOrderCard/index.tsx +130 -52
  186. package/themes/original/src/components/SingleOrderCard/styles.tsx +11 -2
  187. package/themes/original/src/components/SingleProductCard/index.tsx +71 -34
  188. package/themes/original/src/components/SingleProductCard/styles.tsx +21 -4
  189. package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
  190. package/themes/original/src/components/StripeCardsList/index.tsx +13 -3
  191. package/themes/original/src/components/StripeElementsForm/index.tsx +48 -34
  192. package/themes/original/src/components/UpsellingProducts/index.tsx +238 -224
  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 +76 -7
  196. package/themes/original/src/components/UserFormDetails/styles.tsx +1 -1
  197. package/themes/original/src/components/UserProfile/index.tsx +88 -79
  198. package/themes/original/src/components/UserProfileForm/index.tsx +27 -29
  199. package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
  200. package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
  201. package/themes/original/src/components/WalletTransactions/index.tsx +3 -3
  202. package/themes/original/src/components/Wallets/index.tsx +67 -24
  203. package/themes/original/src/components/Wallets/styles.tsx +3 -4
  204. package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
  205. package/themes/original/src/components/shared/OButton.tsx +6 -2
  206. package/themes/original/src/components/shared/OInput.tsx +6 -1
  207. package/themes/original/src/components/shared/OModal.tsx +3 -3
  208. package/themes/original/src/layouts/Container.tsx +1 -1
  209. package/themes/original/src/types/index.tsx +41 -11
  210. package/themes/original/src/utils/index.tsx +273 -1
  211. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import { View, StyleSheet, useWindowDimensions, Keyboard } from 'react-native';
3
- import { useLanguage, useSession, useConfig } from 'ordering-components/native';
2
+ import { View, StyleSheet, useWindowDimensions, Keyboard, Platform } from 'react-native';
3
+ import { useLanguage, useSession, useConfig, useValidationFields } from 'ordering-components/native';
4
4
  import {
5
5
  StripeProvider,
6
6
  CardField,
@@ -28,7 +28,12 @@ const StripeElementsFormUI = (props: any) => {
28
28
  onCancel,
29
29
  cart,
30
30
  merchantId,
31
- businessIds
31
+ businessIds,
32
+ setMethodPaySupported,
33
+ placeByMethodPay,
34
+ methodPaySupported,
35
+ setPlaceByMethodPay,
36
+ cartTotal
32
37
  } = props;
33
38
 
34
39
  const theme = useTheme();
@@ -36,6 +41,7 @@ const StripeElementsFormUI = (props: any) => {
36
41
  const [, t] = useLanguage();
37
42
  const [{ user }] = useSession();
38
43
  const [{ configs }] = useConfig();
44
+ const [validationFields] = useValidationFields()
39
45
  const [card, setCard] = useState<any>(null);
40
46
  const [isCompleted, setIsCompleted] = useState(false);
41
47
  const [errors, setErrors] = useState('')
@@ -44,6 +50,23 @@ const StripeElementsFormUI = (props: any) => {
44
50
  const { height } = useWindowDimensions();
45
51
  const { top, bottom } = useSafeAreaInsets();
46
52
  const [isKeyboardShow, setIsKeyboardShow] = useState(false);
53
+ const zipCodeEnabled = validationFields?.fields?.card?.zipcode?.enabled
54
+ const zipCodeRequired = validationFields?.fields?.card?.zipcode?.required
55
+ const styles = StyleSheet.create({
56
+ container: {
57
+ width: '100%',
58
+ paddingHorizontal: 40,
59
+ justifyContent: 'space-between',
60
+ paddingBottom: 12
61
+ },
62
+ btnAddStyle: {
63
+ marginTop: 20,
64
+ borderRadius: 7.6,
65
+ shadowOpacity: 0,
66
+ height: 44,
67
+ marginBottom: isKeyboardShow && Platform.OS === 'ios' ? 40 : 0
68
+ },
69
+ })
47
70
 
48
71
  let billingDetails: any = {}
49
72
 
@@ -62,24 +85,24 @@ const StripeElementsFormUI = (props: any) => {
62
85
 
63
86
  if (user?.address) {
64
87
  billingDetails.address = {
65
- line1: user?.address
66
- }
88
+ line1: user?.address
89
+ }
67
90
  }
68
91
 
69
92
  const createPayMethod = async () => {
70
93
  const params: any = { paymentMethodType: 'Card', paymentMethodData: {} }
71
94
  if (Object.keys(billingDetails).length > 0) {
72
- params.paymentMethodData.billingDetails = {...billingDetails, token: card?.last4}
95
+ params.paymentMethodData.billingDetails = { ...billingDetails, token: card?.last4 }
73
96
  }
74
97
  try {
75
98
  setCreatePmLoading(true)
76
99
  const { paymentMethod, error } = await createPaymentMethod(params);
77
100
 
78
- if (error) {
79
- setErrors(error?.message);
80
- setCreatePmLoading(false)
81
- return
82
- }
101
+ if (error) {
102
+ setErrors(error?.message);
103
+ setCreatePmLoading(false)
104
+ return
105
+ }
83
106
 
84
107
  setCreatePmLoading(false)
85
108
  handleSource && handleSource({
@@ -102,7 +125,7 @@ const StripeElementsFormUI = (props: any) => {
102
125
  setErrors(error?.message || error?.toString());
103
126
  }
104
127
  }
105
-
128
+
106
129
  const handleSaveCard = async () => {
107
130
  setErrors('');
108
131
  if (!requirements) {
@@ -111,7 +134,7 @@ const StripeElementsFormUI = (props: any) => {
111
134
  }
112
135
  const params: any = { paymentMethodType: 'Card', paymentMethodData: {} }
113
136
  if (Object.keys(billingDetails).length > 0) {
114
- params.paymentMethodData.billingDetails = {...billingDetails, token: card?.last4}
137
+ params.paymentMethodData.billingDetails = { ...billingDetails, token: card?.last4 }
115
138
  }
116
139
  try {
117
140
  const { setupIntent, error } = await confirmSetupIntent(requirements, params);
@@ -119,8 +142,8 @@ const StripeElementsFormUI = (props: any) => {
119
142
  if (setupIntent?.status === 'Succeeded') {
120
143
  if (businessIds) {
121
144
  businessIds.forEach((_businessId: any, index: any) => {
122
- const _isNewCard = index === 0
123
- stripeTokenHandler(setupIntent?.paymentMethodId, user, businessId, _isNewCard);
145
+ const _isNewCard = index === 0
146
+ stripeTokenHandler(setupIntent?.paymentMethodId, user, businessId, _isNewCard);
124
147
  })
125
148
  } else {
126
149
  stripeTokenHandler(setupIntent?.paymentMethodId, user, businessId);
@@ -145,7 +168,8 @@ const StripeElementsFormUI = (props: any) => {
145
168
  !!card?.last4 &&
146
169
  !!card?.expiryMonth &&
147
170
  !!card?.expiryYear &&
148
- !!card?.brand
171
+ !!card?.brand &&
172
+ ((!zipCodeEnabled || !zipCodeRequired || !!card?.postalCode))
149
173
  )
150
174
  }
151
175
  }, [card])
@@ -172,12 +196,12 @@ const StripeElementsFormUI = (props: any) => {
172
196
  }, []);
173
197
 
174
198
  return (
175
- <View style={{ ...styles.container, height: height - top - bottom - 60 - (isKeyboardShow ? 250 : 0) }}>
199
+ <View style={{ ...styles.container, height: methodsPay?.includes(paymethod) ? 'auto' : height - top - bottom - 60 - (isKeyboardShow ? 250 : 0) }}>
176
200
  {publicKey ? (
177
201
  <View style={{ flex: 1 }}>
178
202
  <StripeProvider
179
203
  publishableKey={publicKey}
180
- merchantIdentifier={`merchant.${merchantId}`}
204
+ merchantIdentifier={merchantId}
181
205
  urlScheme={merchantId}
182
206
  >
183
207
  {methodsPay?.includes(paymethod) ? (
@@ -185,13 +209,18 @@ const StripeElementsFormUI = (props: any) => {
185
209
  handleSource={handleSource}
186
210
  onCancel={onCancel}
187
211
  cart={cart}
212
+ cartTotal={cartTotal}
188
213
  setErrors={setErrors}
189
214
  paymethod={paymethod}
190
215
  devMode={publicKey?.includes('test')}
216
+ setMethodPaySupported={setMethodPaySupported}
217
+ placeByMethodPay={placeByMethodPay}
218
+ methodPaySupported={methodPaySupported}
219
+ setPlaceByMethodPay={setPlaceByMethodPay}
191
220
  />
192
221
  ) : (
193
222
  <CardField
194
- postalCodeEnabled={true}
223
+ postalCodeEnabled={zipCodeEnabled}
195
224
  cardStyle={{
196
225
  backgroundColor: '#FFFFFF',
197
226
  textColor: '#000000',
@@ -249,21 +278,6 @@ const StripeElementsFormUI = (props: any) => {
249
278
  )
250
279
  }
251
280
 
252
- const styles = StyleSheet.create({
253
- container: {
254
- width: '100%',
255
- paddingHorizontal: 40,
256
- justifyContent: 'space-between',
257
- paddingBottom: 12
258
- },
259
- btnAddStyle: {
260
- marginTop: 20,
261
- borderRadius: 7.6,
262
- shadowOpacity: 0,
263
- height: 44
264
- },
265
- })
266
-
267
281
  export const StripeElementsForm = (props: any) => {
268
282
  const stripeProps = {
269
283
  ...props,
@@ -1,252 +1,266 @@
1
1
  import React, { useState, useEffect } from 'react'
2
2
  import { Platform, StyleSheet, TouchableOpacity, View } from 'react-native'
3
3
  import {
4
- UpsellingPage as UpsellingPageController,
5
- useUtils,
6
- useLanguage,
7
- useOrder
4
+ UpsellingPage as UpsellingPageController,
5
+ useUtils,
6
+ useLanguage,
7
+ useOrder,
8
+ useConfig
8
9
  } from 'ordering-components/native'
9
10
  import { useTheme } from 'styled-components/native';
10
11
  import { OText, OIcon, OBottomPopup, OButton } from '../shared'
11
12
  import { UpsellingProductsParams } from '../../types'
12
13
  import {
13
- Container,
14
- UpsellingContainer,
15
- Item,
16
- Details,
17
- AddButton,
18
- TopBar,
19
- TopActions
14
+ Container,
15
+ UpsellingContainer,
16
+ Item,
17
+ Details,
18
+ AddButton,
19
+ CartList,
20
+ CartDivider
20
21
  } from './styles'
21
22
  import { OrderSummary } from '../OrderSummary';
23
+ import { Cart } from '../Cart';
22
24
  import { ScrollView } from 'react-native-gesture-handler';
23
25
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
24
- import AntDesignIcon from 'react-native-vector-icons/AntDesign'
25
26
 
26
27
  const UpsellingProductsUI = (props: UpsellingProductsParams) => {
27
- const {
28
- isCustomMode,
29
- upsellingProducts,
30
- business,
31
- handleUpsellingPage,
32
- handleCloseUpsellingPage,
33
- openUpselling,
34
- canOpenUpselling,
35
- setCanOpenUpselling,
36
- isFromCart,
37
- onNavigationRedirect,
38
- onGoBack
39
- } = props
28
+ const {
29
+ isCustomMode,
30
+ upsellingProducts,
31
+ business,
32
+ handleUpsellingPage,
33
+ openUpselling,
34
+ canOpenUpselling,
35
+ setCanOpenUpselling,
36
+ isFromCart,
37
+ onNavigationRedirect,
38
+ onGoBack
39
+ } = props
40
40
 
41
- const theme = useTheme();
41
+ const theme = useTheme();
42
42
 
43
- const styles = StyleSheet.create({
44
- imageStyle: {
45
- width: 73,
46
- height: 73,
47
- resizeMode: 'cover',
48
- borderRadius: 7.6,
49
- },
50
- closeUpsellingButton: {
51
- borderRadius: 7.6,
52
- borderColor: theme.colors.primary,
53
- backgroundColor: theme.colors.primary,
54
- borderWidth: 1,
55
- alignSelf: 'center',
56
- height: 44,
57
- shadowOpacity: 0,
58
- width: '80%',
59
- },
60
- cancelBtn: {
61
- paddingHorizontal: 18,
62
- borderWidth: 1,
63
- borderRadius: 7.6,
64
- borderColor: theme.colors.textSecondary,
65
- height: 38
66
- },
67
- headerItem: {
68
- flexDirection: 'row',
69
- alignItems: 'center',
70
- marginVertical: 2,
71
- marginHorizontal: 20,
72
- },
73
- btnBackArrow: {
74
- borderWidth: 0,
75
- width: 26,
76
- height: 26,
77
- backgroundColor: theme.colors.clear,
78
- borderColor: theme.colors.clear,
79
- shadowColor: theme.colors.clear,
80
- paddingLeft: 0,
81
- paddingRight: 0,
82
- marginLeft: 20,
83
- marginBottom: 10
84
- },
85
- })
43
+ const styles = StyleSheet.create({
44
+ imageStyle: {
45
+ width: 73,
46
+ height: 73,
47
+ resizeMode: 'cover',
48
+ borderRadius: 7.6,
49
+ },
50
+ closeUpsellingButton: {
51
+ borderRadius: 7.6,
52
+ borderColor: theme.colors.primary,
53
+ backgroundColor: theme.colors.primary,
54
+ borderWidth: 1,
55
+ alignSelf: 'center',
56
+ height: 44,
57
+ shadowOpacity: 0,
58
+ width: '80%',
59
+ },
60
+ cancelBtn: {
61
+ paddingHorizontal: 18,
62
+ borderWidth: 1,
63
+ borderRadius: 7.6,
64
+ borderColor: theme.colors.textSecondary,
65
+ height: 38
66
+ },
67
+ headerItem: {
68
+ flexDirection: 'row',
69
+ alignItems: 'center',
70
+ marginVertical: 2,
71
+ marginHorizontal: 20,
72
+ },
73
+ btnBackArrow: {
74
+ borderWidth: 0,
75
+ width: 26,
76
+ height: 26,
77
+ backgroundColor: theme.colors.clear,
78
+ borderColor: theme.colors.clear,
79
+ shadowColor: theme.colors.clear,
80
+ paddingLeft: 0,
81
+ paddingRight: 0,
82
+ marginLeft: 20,
83
+ marginBottom: 10
84
+ },
85
+ })
86
86
 
87
- const [modalIsOpen, setModalIsOpen] = useState(false)
88
- const [{ carts }] = useOrder()
89
- const [{ parsePrice }] = useUtils()
90
- const [, t] = useLanguage()
91
- const { bottom } = useSafeAreaInsets()
92
- const [isCheckout, setIsCheckout] = useState(false)
87
+ const [{ carts }] = useOrder()
88
+ const [{ parsePrice }] = useUtils()
89
+ const [{ configs }] = useConfig()
90
+ const [, t] = useLanguage()
91
+ const { bottom } = useSafeAreaInsets()
92
+ const [isCartsLoading, setIsCartsLoading] = useState(false)
93
93
 
94
- const cart = carts?.[`businessId:${props.businessId}`] ?? {}
95
- const cartProducts = cart?.products?.length
96
- ? cart?.products.map((product: any) => product.id)
97
- : []
94
+ const isMultiCheckout = configs?.checkout_multi_business_enabled?.value === '1'
95
+ const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
96
+ const showCartList = isChewLayout
97
+ const commentDelayTime = isChewLayout ? 500 : null
98
98
 
99
- const productsList = !upsellingProducts.loading && !upsellingProducts.error
100
- ? upsellingProducts?.products?.length
101
- ? upsellingProducts?.products.filter((product: any) => !cartProducts.includes(product.id))
102
- : (props?.products ?? []).filter((product: any) => !cartProducts.includes(product.id)) ?? []
103
- : []
99
+ const cart = carts?.[`businessId:${props.businessId}`] ?? {}
100
+ const cartList = (carts && Object.values(carts).filter((_cart: any) => _cart?.products?.length > 0 && _cart.uuid !== cart?.uuid)) || []
101
+ const cartProducts = cart?.products?.length
102
+ ? cart?.products.map((product: any) => product.id)
103
+ : []
104
104
 
105
- useEffect(() => {
106
- if (!isCustomMode && !props.products) {
107
- if (!upsellingProducts.loading) {
108
- if (upsellingProducts?.products?.length && !isFromCart) {
109
- setCanOpenUpselling && setCanOpenUpselling(true)
110
- } else {
111
- handleUpsellingPage && handleUpsellingPage()
112
- }
113
- }
114
- }
115
- }, [upsellingProducts.loading, upsellingProducts?.products.length])
105
+ const productsList = !upsellingProducts.loading && !upsellingProducts.error
106
+ ? upsellingProducts?.products?.length
107
+ ? upsellingProducts?.products.filter((product: any) => !cartProducts.includes(product.id))
108
+ : (props?.products ?? []).filter((product: any) => !cartProducts.includes(product.id)) ?? []
109
+ : []
116
110
 
117
- const handleFormProduct = (product: any) => {
118
- onNavigationRedirect && onNavigationRedirect('ProductDetails', {
119
- product: product,
120
- businessId: product?.api?.businessId,
121
- businessSlug: business.slug,
122
- })
123
- }
111
+ useEffect(() => {
112
+ if (!isCustomMode && !props.products) {
113
+ if (!upsellingProducts.loading) {
114
+ if (upsellingProducts?.products?.length && !isFromCart) {
115
+ setCanOpenUpselling && setCanOpenUpselling(true)
116
+ } else {
117
+ handleUpsellingPage && handleUpsellingPage(cart)
118
+ }
119
+ }
120
+ }
121
+ }, [upsellingProducts.loading, upsellingProducts?.products.length])
124
122
 
125
- const UpsellingLayout = () => {
126
- return (
127
- <Container>
128
- <UpsellingContainer
129
- horizontal
130
- showsHorizontalScrollIndicator={false}
131
- contentContainerStyle={{ paddingHorizontal: Platform.OS === 'ios' ? 40 : 0 }}
132
- >
133
- {
134
- !upsellingProducts.loading && (
135
- <>
136
- {
137
- !upsellingProducts.error ? productsList.map((product: any, i: number) => (
138
- <Item key={`${product.id}_${i}`}>
139
- <View style={{ flexBasis: '57%' }}>
140
- <Details>
141
- <OText size={12} lineHeight={18} numberOfLines={1} ellipsizeMode='tail'>{product.name}</OText>
142
- <OText size={12} lineHeight={18} color={theme.colors.textNormal}>{parsePrice(product.price)}</OText>
143
- </Details>
144
- <AddButton onPress={() => handleFormProduct(product)}>
145
- <OText size={10} color={theme.colors.primary}>{t('ADD', 'Add')}</OText>
146
- </AddButton>
147
- </View>
148
- <View>
149
- <OIcon url={product?.images || theme?.images?.dummies?.product} style={styles.imageStyle} />
150
- </View>
151
- </Item>
152
- )) : (
153
- <OText>
154
- {upsellingProducts.message}
155
- </OText>
156
- )
157
- }
158
- </>
159
- )
160
- }
161
- </UpsellingContainer>
162
- </Container>
163
- )
164
- }
123
+ const handleFormProduct = (product: any) => {
124
+ onNavigationRedirect && onNavigationRedirect('ProductDetails', {
125
+ product: product,
126
+ businessId: product?.api?.businessId,
127
+ businessSlug: business.slug,
128
+ })
129
+ }
165
130
 
166
- const UpsellingContent = () => {
167
- return (
168
- <>
169
- <View style={{ ...styles.headerItem, flex: 1, marginTop: Platform.OS == 'ios' ? 35 : 70 }}>
170
- <OButton
171
- imgRightSrc={null}
172
- style={styles.btnBackArrow}
173
- onClick={() => onGoBack()}
174
- icon={AntDesignIcon}
175
- iconProps={{
176
- name: 'arrowleft',
177
- size: 26
178
- }}
179
- />
180
- </View>
181
- <ScrollView style={{ marginTop: 10, marginBottom: props.isPage ? 40 : bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
182
- {productsList.length > 0 &&
183
- <View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
184
- <OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
185
- <UpsellingLayout />
186
- </View>
187
- }
188
- <View style={{ paddingHorizontal: 40 }}>
189
- <OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
190
- <OrderSummary
191
- cart={cart}
192
- isCartPending={cart?.status === 2}
193
- onNavigationRedirect={onNavigationRedirect}
194
- />
195
- </View>
196
- </ScrollView>
197
- <View
198
- style={{
199
- alignItems: 'center',
200
- bottom: props.isPage ? Platform.OS === 'ios' ? 0 : 20 : Platform.OS === 'ios' ? bottom + 59 : bottom + 125
201
- }}
202
- >
203
- <OButton
204
- imgRightSrc=''
205
- text={t('CHECKOUT', 'Checkout')}
206
- style={{ ...styles.closeUpsellingButton }}
207
- textStyle={{ color: theme.colors.white, fontSize: 14 }}
208
- onClick={() => {
209
- handleUpsellingPage()
210
- setIsCheckout(true)
211
- }}
212
- />
213
- </View>
214
- </>
215
- )
216
- }
131
+ const UpsellingLayout = () => {
132
+ return (
133
+ <Container>
134
+ <UpsellingContainer
135
+ horizontal
136
+ showsHorizontalScrollIndicator={false}
137
+ contentContainerStyle={{ paddingHorizontal: Platform.OS === 'ios' ? 40 : 0 }}
138
+ >
139
+ {
140
+ !upsellingProducts.loading && (
141
+ <>
142
+ {
143
+ !upsellingProducts.error ? productsList.map((product: any, i: number) => (
144
+ <Item key={`${product.id}_${i}`}>
145
+ <View style={{ flexBasis: '57%' }}>
146
+ <Details>
147
+ <OText size={12} lineHeight={18} numberOfLines={1} ellipsizeMode='tail'>{product.name}</OText>
148
+ <OText size={12} lineHeight={18} color={theme.colors.textNormal}>{parsePrice(product.price)}</OText>
149
+ </Details>
150
+ <AddButton onPress={() => handleFormProduct(product)}>
151
+ <OText size={10} color={theme.colors.primary}>{t('ADD', 'Add')}</OText>
152
+ </AddButton>
153
+ </View>
154
+ <View>
155
+ <OIcon url={product?.images || theme?.images?.dummies?.product} style={styles.imageStyle} />
156
+ </View>
157
+ </Item>
158
+ )) : (
159
+ <OText>
160
+ {upsellingProducts.message}
161
+ </OText>
162
+ )
163
+ }
164
+ </>
165
+ )
166
+ }
167
+ </UpsellingContainer>
168
+ </Container>
169
+ )
170
+ }
217
171
 
218
- return (
219
- <>
220
- {isCustomMode ? (
221
- <UpsellingLayout />
222
- ) : (
223
- <>
224
- {props.isPage ? (
225
- <UpsellingContent />
226
- ) : (
227
- canOpenUpselling && !modalIsOpen && (
228
- <OBottomPopup
229
- title={''}
230
- open={openUpselling}
231
- onClose={() => handleUpsellingPage()}
232
- isStatusBar
233
- >
234
- <UpsellingContent />
235
- </OBottomPopup>
236
- )
237
- )}
238
- </>
239
- )}
240
- </>
241
- )
172
+ const UpsellingContent = () => {
173
+ return (
174
+ <>
175
+ <View style={{ ...styles.headerItem, flex: 1, marginTop: Platform.OS == 'ios' ? 35 : 14 }}>
176
+ <TouchableOpacity onPress={() => onGoBack()} style={styles.btnBackArrow}>
177
+ <OIcon src={theme.images.general.arrow_left} color={theme.colors.textNormal} />
178
+ </TouchableOpacity>
179
+ </View>
180
+ <ScrollView style={{ marginTop: 10, marginBottom: props.isPage ? 40 : bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
181
+ {productsList.length > 0 &&
182
+ <View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
183
+ <OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
184
+ <UpsellingLayout />
185
+ </View>
186
+ }
187
+ <View style={{ paddingHorizontal: 40 }}>
188
+ <OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
189
+ <OrderSummary
190
+ cart={cart}
191
+ commentDelayTime={commentDelayTime}
192
+ isCartPending={cart?.status === 2}
193
+ onNavigationRedirect={onNavigationRedirect}
194
+ />
195
+ </View>
196
+ {showCartList && cartList.map((cart: any, i: number) => (
197
+ <CartList key={i}>
198
+ <Cart
199
+ isFromUpselling
200
+ cart={cart}
201
+ cartuuid={cart.uuid}
202
+ hideUpselling
203
+ singleBusiness={props.singleBusiness}
204
+ isFranchiseApp={props.isFranchiseApp}
205
+ isCartsLoading={isCartsLoading}
206
+ setIsCartsLoading={setIsCartsLoading}
207
+ isMultiCheckout={isMultiCheckout}
208
+ onNavigationRedirect={props.onNavigationRedirect}
209
+ />
210
+ <CartDivider />
211
+ </CartList>
212
+ ))}
213
+ </ScrollView>
214
+ <View
215
+ style={{
216
+ alignItems: 'center',
217
+ bottom: props.isPage ? Platform.OS === 'ios' ? 0 : 20 : Platform.OS === 'ios' ? bottom + 59 : bottom + 125
218
+ }}
219
+ >
220
+ <OButton
221
+ imgRightSrc=''
222
+ text={t('CHECKOUT', 'Checkout')}
223
+ style={{ ...styles.closeUpsellingButton }}
224
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
225
+ onClick={() => handleUpsellingPage(cart)}
226
+ />
227
+ </View>
228
+ </>
229
+ )
230
+ }
231
+
232
+ return (
233
+ <>
234
+ {isCustomMode ? (
235
+ <UpsellingLayout />
236
+ ) : (
237
+ <>
238
+ {props.isPage ? (
239
+ <UpsellingContent />
240
+ ) : (
241
+ canOpenUpselling && (
242
+ <OBottomPopup
243
+ title={''}
244
+ open={openUpselling}
245
+ onClose={() => handleUpsellingPage(cart)}
246
+ isStatusBar
247
+ >
248
+ <UpsellingContent />
249
+ </OBottomPopup>
250
+ )
251
+ )}
252
+ </>
253
+ )}
254
+ </>
255
+ )
242
256
  }
243
257
 
244
258
  export const UpsellingProducts = (props: UpsellingProductsParams) => {
245
- const upsellingProductsProps = {
246
- ...props,
247
- UIComponent: UpsellingProductsUI
248
- }
249
- return (
250
- <UpsellingPageController {...upsellingProductsProps} />
251
- )
259
+ const upsellingProductsProps = {
260
+ ...props,
261
+ UIComponent: UpsellingProductsUI
262
+ }
263
+ return (
264
+ <UpsellingPageController {...upsellingProductsProps} />
265
+ )
252
266
  }