ordering-ui-react-native 0.21.50 → 0.21.51-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 (198) hide show
  1. package/package.json +8 -8
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessesListing/index.tsx +1 -1
  4. package/src/components/PaymentOptionsWebView/index.tsx +1 -0
  5. package/src/components/StripeMethodForm/index.tsx +6 -4
  6. package/src/components/VerifyPhone/styles.tsx +1 -2
  7. package/src/types/index.tsx +3 -1
  8. package/themes/business/index.tsx +4 -0
  9. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +4 -3
  10. package/themes/business/src/components/BusinessController/index.tsx +19 -17
  11. package/themes/business/src/components/BusinessProductList/ProductList.tsx +72 -27
  12. package/themes/business/src/components/BusinessProductList/index.tsx +57 -25
  13. package/themes/business/src/components/DriverMap/index.tsx +36 -23
  14. package/themes/business/src/components/GoogleMap/index.tsx +15 -8
  15. package/themes/business/src/components/Home/index.tsx +5 -1
  16. package/themes/business/src/components/LanguageSelector/index.tsx +1 -2
  17. package/themes/business/src/components/LanguageSelector/lang_country.json +515 -70
  18. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  19. package/themes/business/src/components/MapView/index.tsx +30 -15
  20. package/themes/business/src/components/NewOrderNotification/index.tsx +66 -26
  21. package/themes/business/src/components/OrderDetails/Business.tsx +52 -2
  22. package/themes/business/src/components/OrderDetails/Delivery.tsx +42 -23
  23. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +68 -61
  24. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +40 -20
  25. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +220 -0
  26. package/themes/business/src/components/OrderSummary/index.tsx +240 -76
  27. package/themes/business/src/components/OrdersOption/index.tsx +263 -135
  28. package/themes/business/src/components/PhoneInputNumber/index.tsx +8 -5
  29. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +37 -40
  30. package/themes/business/src/components/PreviousOrders/OrderList.tsx +1 -1
  31. package/themes/business/src/components/PreviousOrders/index.tsx +5 -3
  32. package/themes/business/src/components/PreviousOrders/styles.tsx +10 -0
  33. package/themes/business/src/components/PrinterEdition/index.tsx +363 -0
  34. package/themes/business/src/components/PrinterEdition/styles.tsx +61 -0
  35. package/themes/business/src/components/PrinterSettings/index.tsx +267 -0
  36. package/themes/business/src/components/PrinterSettings/styles.tsx +30 -0
  37. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  38. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  39. package/themes/business/src/components/SearchBar/index.tsx +2 -1
  40. package/themes/business/src/components/Sessions/index.tsx +187 -0
  41. package/themes/business/src/components/Sessions/styles.tsx +20 -0
  42. package/themes/business/src/components/StoresList/index.tsx +5 -3
  43. package/themes/business/src/components/UserFormDetails/index.tsx +111 -107
  44. package/themes/business/src/components/UserProfileForm/index.tsx +106 -54
  45. package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
  46. package/themes/business/src/components/shared/OInput.tsx +2 -0
  47. package/themes/business/src/components/shared/OTextarea.tsx +8 -9
  48. package/themes/business/src/hooks/useLocation.tsx +5 -4
  49. package/themes/business/src/types/index.tsx +23 -5
  50. package/themes/business/src/utils/index.tsx +5 -0
  51. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  52. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  53. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  54. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  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/shared/OButton.tsx +5 -18
  59. package/themes/original/index.tsx +6 -2
  60. package/themes/original/src/components/AddressDetails/index.tsx +20 -10
  61. package/themes/original/src/components/AddressForm/index.tsx +41 -15
  62. package/themes/original/src/components/AddressForm/styles.tsx +1 -1
  63. package/themes/original/src/components/AddressList/index.tsx +18 -4
  64. package/themes/original/src/components/AddressList/styles.tsx +4 -4
  65. package/themes/original/src/components/AnalyticsSegment/index.tsx +6 -6
  66. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  67. package/themes/original/src/components/BusinessBasicInformation/index.tsx +7 -10
  68. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +1 -1
  69. package/themes/original/src/components/BusinessController/index.tsx +18 -10
  70. package/themes/original/src/components/BusinessController/styles.tsx +8 -7
  71. package/themes/original/src/components/BusinessInformation/styles.tsx +2 -2
  72. package/themes/original/src/components/BusinessItemAccordion/index.tsx +4 -3
  73. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +317 -0
  74. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +96 -0
  75. package/themes/original/src/components/BusinessListingSearch/index.tsx +47 -358
  76. package/themes/original/src/components/BusinessListingSearch/styles.tsx +1 -1
  77. package/themes/original/src/components/BusinessPreorder/index.tsx +4 -3
  78. package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -1
  79. package/themes/original/src/components/BusinessProductsList/index.tsx +1 -1
  80. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  81. package/themes/original/src/components/BusinessProductsListing/index.tsx +30 -18
  82. package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -2
  83. package/themes/original/src/components/BusinessReviews/index.tsx +1 -1
  84. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  85. package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +5 -5
  86. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +1 -1
  87. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +7 -7
  88. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +2 -2
  89. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  90. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  91. package/themes/original/src/components/Cart/index.tsx +30 -9
  92. package/themes/original/src/components/CartContent/index.tsx +96 -58
  93. package/themes/original/src/components/CartStoresListing/styles.tsx +2 -2
  94. package/themes/original/src/components/Checkout/index.tsx +144 -62
  95. package/themes/original/src/components/Checkout/styles.tsx +17 -0
  96. package/themes/original/src/components/CitiesControl/styles.tsx +1 -1
  97. package/themes/original/src/components/DatePicker/index.tsx +18 -2
  98. package/themes/original/src/components/Favorite/index.tsx +9 -9
  99. package/themes/original/src/components/Favorite/styles.tsx +0 -2
  100. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  101. package/themes/original/src/components/ForgotPasswordForm/index.tsx +5 -0
  102. package/themes/original/src/components/GPSButton/index.tsx +1 -1
  103. package/themes/original/src/components/GiftCard/GiftCardOrdersList/index.tsx +64 -0
  104. package/themes/original/src/components/GiftCard/GiftCardOrdersList/styles.tsx +8 -0
  105. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +1 -1
  106. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +1 -1
  107. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +2 -2
  108. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +1 -1
  109. package/themes/original/src/components/GiftCard/SingleGiftCard/index.tsx +101 -0
  110. package/themes/original/src/components/GiftCard/SingleGiftCard/styles.tsx +4 -0
  111. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +83 -0
  112. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/styles.tsx +9 -0
  113. package/themes/original/src/components/GoogleMap/index.tsx +39 -18
  114. package/themes/original/src/components/Help/index.tsx +7 -0
  115. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +5 -0
  116. package/themes/original/src/components/HelpGuide/index.tsx +5 -0
  117. package/themes/original/src/components/HelpOrder/index.tsx +5 -0
  118. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +2 -2
  119. package/themes/original/src/components/HighestRatedBusinesses/styles.tsx +1 -1
  120. package/themes/original/src/components/Home/index.tsx +3 -8
  121. package/themes/original/src/components/LoginForm/Otp/index.tsx +4 -16
  122. package/themes/original/src/components/LoginForm/index.tsx +9 -3
  123. package/themes/original/src/components/MessageListing/index.tsx +6 -0
  124. package/themes/original/src/components/Messages/index.tsx +8 -7
  125. package/themes/original/src/components/Messages/styles.tsx +1 -1
  126. package/themes/original/src/components/MomentOption/index.tsx +19 -4
  127. package/themes/original/src/components/MultiCart/index.tsx +1 -1
  128. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +7 -3
  129. package/themes/original/src/components/MultiCheckout/index.tsx +126 -61
  130. package/themes/original/src/components/MultiCheckout/styles.tsx +17 -0
  131. package/themes/original/src/components/MultiOrdersDetails/index.tsx +20 -15
  132. package/themes/original/src/components/MyOrders/index.tsx +28 -28
  133. package/themes/original/src/components/NavBar/index.tsx +5 -0
  134. package/themes/original/src/components/NetworkError/index.tsx +2 -3
  135. package/themes/original/src/components/NetworkError/styles.tsx +2 -2
  136. package/themes/original/src/components/Notifications/index.tsx +9 -8
  137. package/themes/original/src/components/Notifications/styles.tsx +0 -1
  138. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +1 -1
  139. package/themes/original/src/components/OrderDetails/index.tsx +701 -662
  140. package/themes/original/src/components/OrderDetails/styles.tsx +24 -8
  141. package/themes/original/src/components/OrderProgress/index.tsx +22 -3
  142. package/themes/original/src/components/OrderProgress/styles.tsx +1 -1
  143. package/themes/original/src/components/OrderSummary/index.tsx +3 -1
  144. package/themes/original/src/components/OrderTypeSelector/index.tsx +10 -6
  145. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +1 -1
  146. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +1 -1
  147. package/themes/original/src/components/OrdersOption/index.tsx +3 -5
  148. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  149. package/themes/original/src/components/PaymentOptionCard/index.tsx +4 -2
  150. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  151. package/themes/original/src/components/PaymentOptions/index.tsx +47 -4
  152. package/themes/original/src/components/PreviousOrders/index.tsx +2 -0
  153. package/themes/original/src/components/ProductForm/ActionButton.tsx +122 -0
  154. package/themes/original/src/components/ProductForm/ExtraOptions.tsx +56 -0
  155. package/themes/original/src/components/ProductForm/index.tsx +170 -252
  156. package/themes/original/src/components/ProductItemAccordion/index.tsx +55 -44
  157. package/themes/original/src/components/ProductItemAccordion/styles.tsx +3 -4
  158. package/themes/original/src/components/ProductOptionSubOption/index.tsx +112 -91
  159. package/themes/original/src/components/ProfessionalProfile/styles.tsx +3 -3
  160. package/themes/original/src/components/Promotions/index.tsx +13 -11
  161. package/themes/original/src/components/Promotions/styles.tsx +0 -2
  162. package/themes/original/src/components/ReviewDriver/index.tsx +5 -0
  163. package/themes/original/src/components/ReviewDriver/styles.tsx +1 -1
  164. package/themes/original/src/components/ReviewOrder/index.tsx +5 -0
  165. package/themes/original/src/components/ReviewOrder/styles.tsx +1 -1
  166. package/themes/original/src/components/ReviewProducts/index.tsx +5 -0
  167. package/themes/original/src/components/ReviewProducts/styles.tsx +1 -1
  168. package/themes/original/src/components/ServiceForm/index.tsx +1 -1
  169. package/themes/original/src/components/ServiceForm/styles.tsx +4 -4
  170. package/themes/original/src/components/Sessions/index.tsx +5 -0
  171. package/themes/original/src/components/SignupForm/index.tsx +67 -59
  172. package/themes/original/src/components/SingleOrderCard/index.tsx +1 -1
  173. package/themes/original/src/components/SingleProductCard/index.tsx +4 -3
  174. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  175. package/themes/original/src/components/StripeCardsList/index.tsx +12 -35
  176. package/themes/original/src/components/StripeElementsForm/index.tsx +79 -59
  177. package/themes/original/src/components/StripeElementsForm/naked.tsx +48 -1
  178. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +170 -0
  179. package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +91 -0
  180. package/themes/original/src/components/UpsellingProducts/index.tsx +15 -199
  181. package/themes/original/src/components/UpsellingProducts/styles.tsx +19 -0
  182. package/themes/original/src/components/UserFormDetails/index.tsx +100 -86
  183. package/themes/original/src/components/UserFormDetails/styles.tsx +7 -0
  184. package/themes/original/src/components/UserProfile/index.tsx +3 -2
  185. package/themes/original/src/components/UserProfileForm/index.tsx +5 -0
  186. package/themes/original/src/components/WalletTransactions/styles.tsx +1 -0
  187. package/themes/original/src/components/Wallets/index.tsx +7 -4
  188. package/themes/original/src/components/Wallets/styles.tsx +2 -1
  189. package/themes/original/src/components/WebsocketStatus/index.tsx +172 -0
  190. package/themes/original/src/components/WebsocketStatus/styles.tsx +28 -0
  191. package/themes/original/src/components/shared/HeaderTitle.tsx +1 -1
  192. package/themes/original/src/components/shared/OButton.tsx +5 -5
  193. package/themes/original/src/components/shared/OInput.tsx +1 -4
  194. package/themes/original/src/components/shared/OModal.tsx +12 -14
  195. package/themes/original/src/layouts/Container.tsx +5 -3
  196. package/themes/original/src/types/index.tsx +6 -1
  197. package/themes/original/src/utils/index.tsx +12 -1
  198. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -109,7 +109,7 @@ const BusinessReviewsUI = (props: BusinessReviewsParams) => {
109
109
  return (
110
110
  <BusinessReviewsContainer>
111
111
  <BusinessReviewContent
112
- contentContainerStyle={{ paddingHorizontal: 40, paddingVertical: 27 }}>
112
+ contentContainerStyle={{ paddingHorizontal: 20, paddingVertical: 27 }}>
113
113
  {reviewsList.error ? (
114
114
  <OText size={16}>{t('ERROR_UNKNOWN', 'An error has ocurred')}</OText>
115
115
  ) : (
@@ -415,7 +415,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
415
415
  <ScrollView
416
416
  showsHorizontalScrollIndicator={false}
417
417
  nestedScrollEnabled
418
- horizontal contentContainerStyle={{ paddingHorizontal: 40 }}>
418
+ horizontal contentContainerStyle={{ paddingHorizontal: 20 }}>
419
419
  {featuredBusiness.map((bAry: any, idx) => (
420
420
  <View key={'f-listing_' + idx}>
421
421
  <BusinessFeaturedController
@@ -54,13 +54,13 @@ export const WrapMomentOption = styled.TouchableOpacity`
54
54
  export const HeaderWrapper = styled.ImageBackground`
55
55
  width: 100%;
56
56
  height: 370px;
57
- padding: 20px 40px;
57
+ padding: 20px;
58
58
  background-color: transparent;
59
59
  `;
60
60
 
61
61
  export const ListWrapper = styled.View`
62
62
  background-color: ${(props: any) => props.theme.colors.backgroundLight};
63
- padding-horizontal: 40px;
63
+ padding-horizontal: 20px;
64
64
  `;
65
65
 
66
66
  export const FeaturedWrapper = styled.View`
@@ -72,7 +72,7 @@ export const FeaturedWrapper = styled.View`
72
72
  export const OrderProgressWrapper = styled.View`
73
73
  margin-top: 37px;
74
74
  margin-bottom: 20px;
75
- padding-horizontal: 40px;
75
+ padding-horizontal: 20px;
76
76
  `
77
77
 
78
78
  export const FarAwayMessage = styled.View`
@@ -98,10 +98,10 @@ export const FilterWrapper = styled.View`
98
98
  `
99
99
 
100
100
  export const ServiceWrapper = styled.View`
101
- padding-horizontal: 40px;
101
+ padding-horizontal: 20px;
102
102
  `
103
103
 
104
104
  export const PriceWrapper = styled.View`
105
- padding-horizontal: 40px;
105
+ padding-horizontal: 20px;
106
106
  margin-top: 30px;
107
107
  `
@@ -11,7 +11,7 @@ export const FlatListBusinessListFooter = (props : any) => {
11
11
  } = props
12
12
  return (
13
13
  <>
14
- <ListWrapper style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}>
14
+ <ListWrapper style={{ paddingHorizontal: 20 }}>
15
15
  {(businessesList.loading || !businessesList?.fetched) && (
16
16
  <>
17
17
  {[
@@ -133,7 +133,7 @@ export const FlatListBusinessListHeader = (props: any) => {
133
133
  backgroundColor: theme.colors.white,
134
134
  borderColor: theme.colors.backgroundGray,
135
135
  borderRadius: 8,
136
- marginHorizontal: 40,
136
+ marginHorizontal: 20,
137
137
  minHeight: 45,
138
138
  paddingVertical: 5,
139
139
  paddingHorizontal: 20,
@@ -165,7 +165,7 @@ export const FlatListBusinessListHeader = (props: any) => {
165
165
  )}
166
166
  <View style={{
167
167
  height: !isPreOrderSetting && isChewLayout ? 150 : isChewLayout ? 200 : isFarAway ? 150 : 100,
168
- marginTop: isChewLayout ? 0 : Platform.OS == 'ios' ? 0 : 50,
168
+ marginTop: 0,
169
169
  backgroundColor: isChewLayout ? theme?.colors?.chew : theme.colors?.white
170
170
  }}
171
171
  >
@@ -276,7 +276,7 @@ export const FlatListBusinessListHeader = (props: any) => {
276
276
  bgHeaderHeight={bgHeaderHeight}
277
277
  >
278
278
  {!auth && (
279
- <TouchableOpacity onPress={() => navigation?.canGoBack() && navigation.goBack()} style={{ position: 'absolute', marginStart: 40, paddingVertical: 20 }}>
279
+ <TouchableOpacity onPress={() => navigation?.canGoBack() && navigation.goBack()} style={{ position: 'absolute', marginStart: 20, paddingVertical: 20 }}>
280
280
  <OIcon src={theme.images.general.arrow_left} color={theme.colors.textNormal} />
281
281
  </TouchableOpacity>
282
282
  )}
@@ -284,7 +284,7 @@ export const FlatListBusinessListHeader = (props: any) => {
284
284
  ) : (
285
285
  <>
286
286
  {!auth && (
287
- <TouchableOpacity onPress={() => navigation?.canGoBack() && navigation.goBack()} style={{ position: 'absolute', marginStart: 40, paddingVertical: 20 }}>
287
+ <TouchableOpacity onPress={() => navigation?.canGoBack() && navigation.goBack()} style={{ position: 'absolute', marginStart: 20, paddingVertical: 20 }}>
288
288
  <OIcon src={theme.images.general.arrow_left} color={theme.colors.textNormal} />
289
289
  </TouchableOpacity>
290
290
  )}
@@ -324,12 +324,12 @@ export const FlatListBusinessListHeader = (props: any) => {
324
324
  {
325
325
  !businessId && !props.franchiseId && featuredBusiness && featuredBusiness.length > 0 && (
326
326
  <FeaturedWrapper>
327
- <OText size={16} style={{ marginLeft: 40 }} weight={Platform.OS === 'ios' ? '600' : 'bold'}>{t('BUSINESS_FEATURE', 'Featured business')}</OText>
327
+ <OText size={16} style={{ marginLeft: 20 }} weight={Platform.OS === 'ios' ? '600' : 'bold'}>{t('BUSINESS_FEATURE', 'Featured business')}</OText>
328
328
  <ScrollView
329
329
  showsHorizontalScrollIndicator={false}
330
330
  nestedScrollEnabled
331
331
  horizontal
332
- contentContainerStyle={{ paddingHorizontal: 40 }}
332
+ contentContainerStyle={{ paddingHorizontal: 20 }}
333
333
  >
334
334
  {featuredBusiness.map((bAry: any, idx: number) => (
335
335
  <View key={'f-listing_' + idx}>
@@ -372,7 +372,7 @@ export const FlatListBusinessListHeader = (props: any) => {
372
372
  <PageBanner position='app_business_listing' navigation={navigation} />
373
373
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
374
374
 
375
- <ListWrapper style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}>
375
+ <ListWrapper style={{ paddingHorizontal: 20 }}>
376
376
  {!businessId && !isAllCategoriesHidden && (
377
377
  <BusinessTypeFilter
378
378
  images={props.images}
@@ -94,7 +94,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
94
94
  backgroundColor: theme.colors.white,
95
95
  borderColor: theme.colors.backgroundGray,
96
96
  borderRadius: 8,
97
- marginHorizontal: 40,
97
+ marginHorizontal: 20,
98
98
  minHeight: 45,
99
99
  paddingVertical: 5,
100
100
  paddingHorizontal: 20,
@@ -168,7 +168,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
168
168
  setFeaturedBusinesses(ary);
169
169
  }
170
170
  resetInactivityTimeout()
171
- }, [businessesList.loading])
171
+ }, [businessesList.loading, businessesList?.businesses])
172
172
 
173
173
  const handleOnRefresh = () => {
174
174
  if (!businessesList.loading) {
@@ -61,7 +61,7 @@ export const WrapMomentOption = styled.TouchableOpacity`
61
61
  export const HeaderWrapper = styled.ImageBackground`
62
62
  width: 100%;
63
63
  height: 270px;
64
- padding: 20px 40px;
64
+ padding: 20px;
65
65
  background-color: transparent;
66
66
  `;
67
67
 
@@ -1,4 +1,3 @@
1
-
2
1
  import React, { useState, useEffect } from 'react'
3
2
  import { useOrder, useSession, useLanguage, useConfig } from 'ordering-components/native';
4
3
 
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React, { useEffect, useState, useRef } from 'react';
2
2
  import {
3
3
  Cart as CartController,
4
4
  useOrder,
@@ -52,7 +52,11 @@ const CartUI = (props: any) => {
52
52
  preorderMaximumDays,
53
53
  preorderMinimumDays,
54
54
  cateringTypes,
55
- isFromUpselling
55
+ isFromUpselling,
56
+ cartsOpened,
57
+ setCartsOpened,
58
+ changeActiveState,
59
+ isActive
56
60
  } = props
57
61
 
58
62
  const theme = useTheme();
@@ -62,7 +66,7 @@ const CartUI = (props: any) => {
62
66
  const [{ configs }] = useConfig();
63
67
  const [{ parsePrice, parseNumber, parseDate }] = useUtils()
64
68
  const [validationFields] = useValidationFields()
65
-
69
+ const commentRef = useRef()
66
70
  const [openUpselling, setOpenUpselling] = useState(false)
67
71
  const [openChangeStore, setOpenChangeStore] = useState(false)
68
72
  const [canOpenUpselling, setCanOpenUpselling] = useState(false)
@@ -109,7 +113,7 @@ const CartUI = (props: any) => {
109
113
  }
110
114
  }
111
115
 
112
- const handleUpsellingPage = (individualCart : any) => {
116
+ const handleUpsellingPage = (individualCart: any) => {
113
117
  const isProductCartParam = !!individualCart?.products?.length
114
118
  setOpenUpselling(false)
115
119
  setCanOpenUpselling(false)
@@ -117,7 +121,7 @@ const CartUI = (props: any) => {
117
121
  const cartsAvailable: any = Object.values(orderState?.carts)
118
122
  ?.filter((_cart: any) => _cart?.valid && _cart?.status !== 2 && _cart?.products?.length)
119
123
  ?.filter((_c: any) => !isProductCartParam ? _c.uuid !== individualCart?.uuid : _c)
120
- if (cartsAvailable.length === 1 || !isMultiCheckout) {
124
+ if (cartsAvailable.length === 1 || !isMultiCheckout || !cart?.business_id) {
121
125
  const cart = isMultiCheckout ? cartsAvailable[0] : individualCart
122
126
  onNavigationRedirect('CheckoutNavigator', {
123
127
  screen: 'CheckoutPage',
@@ -192,6 +196,18 @@ const CartUI = (props: any) => {
192
196
  return acc = acc
193
197
  }, cart?.subtotal)
194
198
 
199
+ const handleClickCheckout = () => {
200
+ if (cart?.business_id) {
201
+ setOpenUpselling(true)
202
+ } else {
203
+ onNavigationRedirect('CheckoutNavigator', {
204
+ screen: 'CheckoutPage',
205
+ cartUuid: cart?.uuid,
206
+ cartTotal: cart?.total
207
+ }, true)
208
+ }
209
+ }
210
+
195
211
  useEffect(() => {
196
212
  const limitDays = parseInt(preorderMaximumDays ?? configs?.max_days_preorder?.value, 10)
197
213
  const currentDate = new Date()
@@ -207,7 +223,7 @@ const CartUI = (props: any) => {
207
223
 
208
224
  return (
209
225
  <CContainer>
210
- {openUpselling && (
226
+ {!!openUpselling && (
211
227
  <UpsellingProducts
212
228
  handleUpsellingPage={handleUpsellingPage}
213
229
  openUpselling={openUpselling}
@@ -228,10 +244,14 @@ const CartUI = (props: any) => {
228
244
  handleCartOpen={handleCartOpen}
229
245
  onNavigationRedirect={props.onNavigationRedirect}
230
246
  handleChangeStore={() => setOpenChangeStore(true)}
231
- handleClickCheckout={() => setOpenUpselling(true)}
247
+ handleClickCheckout={() => handleClickCheckout()}
232
248
  checkoutButtonDisabled={(openUpselling && !canOpenUpselling) || subtotalWithTaxes < cart?.minimum || !cart?.valid_address}
233
249
  isMultiCheckout={isMultiCheckout}
234
250
  isFromUpselling={isFromUpselling}
251
+ cartsOpened={cartsOpened}
252
+ setCartsOpened={setCartsOpened}
253
+ changeActiveState={changeActiveState}
254
+ isActive={isActive}
235
255
  isGiftCart={!cart?.business_id}
236
256
  >
237
257
  {cart?.products?.length > 0 && cart?.products.map((product: any, i: number) => (
@@ -491,6 +511,7 @@ const CartUI = (props: any) => {
491
511
  marginTop: 10,
492
512
  borderRadius: 7.6
493
513
  }}
514
+ forwardRef={commentRef}
494
515
  multiline
495
516
  />
496
517
  {commentState?.loading && (
@@ -523,7 +544,7 @@ const CartUI = (props: any) => {
523
544
  />
524
545
  </View>
525
546
  )}
526
- {!isMultiCheckout && (
547
+ {(!isMultiCheckout || !cart?.business_id) && (
527
548
  <>
528
549
  {cart?.valid_products ? (
529
550
  <CheckoutAction>
@@ -540,7 +561,7 @@ const CartUI = (props: any) => {
540
561
  borderColor={theme.colors.primary}
541
562
  imgRightSrc={null}
542
563
  textStyle={{ color: '#fff', textAlign: 'center', flex: 1 }}
543
- onClick={() => setOpenUpselling(true)}
564
+ onClick={() => handleClickCheckout()}
544
565
  style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
545
566
  />
546
567
  </CheckoutAction>
@@ -1,6 +1,6 @@
1
- import React, { useState } from 'react';
1
+ import React, { useCallback, useEffect, useState } from 'react';
2
2
  import { View } from 'react-native';
3
- import { useLanguage, useConfig, useUtils } from 'ordering-components/native';
3
+ import { useLanguage, useConfig, useUtils, useOrder } from 'ordering-components/native';
4
4
  import { useTheme } from 'styled-components/native';
5
5
  import { CCContainer, CCNotCarts, CCList, CheckoutAction, ChCartsTotal } from './styles';
6
6
 
@@ -11,10 +11,10 @@ import { NotFoundSource } from '../NotFoundSource';
11
11
 
12
12
  export const CartContent = (props: any) => {
13
13
  const {
14
- carts,
15
- isOrderStateCarts,
16
14
  onNavigationRedirect,
17
- singleBusiness
15
+ singleBusiness,
16
+ businessSlug,
17
+ navigation
18
18
  } = props
19
19
 
20
20
  const theme = useTheme();
@@ -22,16 +22,22 @@ export const CartContent = (props: any) => {
22
22
  const [{ configs }] = useConfig()
23
23
  const [{ parsePrice }] = useUtils();
24
24
  const [isCartsLoading, setIsCartsLoading] = useState(false)
25
-
26
- const isChewLayout = theme?.header?.components?.layout?.type === 'chew'
25
+ const [cartsOpened, setCartsOpened] = useState([])
26
+ const [{ carts: cartsContext }, { confirmCart }] = useOrder();
27
+ const cartsList =
28
+ (cartsContext &&
29
+ Object.values(cartsContext).filter((cart: any) => cart.products.length > 0)) ??
30
+ [];
31
+ const carts = businessSlug
32
+ ? cartsList.filter((cart: any) => cart?.business?.slug === businessSlug || parseInt(businessSlug) === cart?.business_id)
33
+ : cartsList
34
+ const isOrderStateCarts = !!carts
27
35
  const isMultiCheckout = configs?.checkout_multi_business_enabled?.value === '1'
28
- const cartsAvailable: any = Object.values(carts)?.filter((cart: any) => cart?.valid && cart?.status !== 2)
29
-
36
+ const cartsAvailable: any = Object.values(carts || {})?.filter((cart: any) => cart?.valid && cart?.status !== 2 && cart?.business_id)
30
37
  const totalCartsPrice = cartsAvailable?.length && cartsAvailable.reduce((total: any, cart: any) => { return total + cart?.total }, 0)
31
38
  const totalCartsFee = cartsAvailable?.length && cartsAvailable
32
39
  ?.filter((cart: any) => cart?.status !== 1 && cart?.valid && cart?.products?.length)
33
40
  ?.reduce((total: any, cart: any) => { return total + (cart?.delivery_price_with_discount) }, 0)
34
-
35
41
  const handleCheckoutRedirect = () => {
36
42
  if (cartsAvailable.length === 1) {
37
43
  onNavigationRedirect('CheckoutNavigator', {
@@ -66,9 +72,35 @@ export const CartContent = (props: any) => {
66
72
  }
67
73
  }
68
74
 
75
+ const changeActiveState = useCallback((isClosed: boolean, uuid: string) => {
76
+ const isActive = cartsOpened?.includes?.(uuid) || !!singleBusiness
77
+ if (isActive || !isClosed) {
78
+ setCartsOpened(cartsOpened?.filter?.((_uuid) => _uuid !== uuid))
79
+ } else {
80
+ setCartsOpened([
81
+ ...cartsOpened,
82
+ uuid
83
+ ])
84
+ }
85
+ }, [cartsOpened])
86
+
87
+ useEffect(() => {
88
+ const unsuscribe = navigation.addListener('focus', () => {
89
+ const cartsListBlockedByPaypal = carts?.filter((cart: any) => cart?.status === 2 && cart?.paymethod_data?.gateway === 'paypal')
90
+ if (cartsListBlockedByPaypal?.length > 0) {
91
+ cartsListBlockedByPaypal.map(async (cart: any) => {
92
+ await confirmCart(cart?.uuid)
93
+ })
94
+ }
95
+ })
96
+ return () => {
97
+ return unsuscribe()
98
+ }
99
+ }, [carts, navigation])
100
+
69
101
  return (
70
102
  <CCContainer
71
- style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}
103
+ style={{ paddingHorizontal: 20 }}
72
104
  >
73
105
  {isOrderStateCarts && carts?.length > 0 && (
74
106
  <>
@@ -88,8 +120,12 @@ export const CartContent = (props: any) => {
88
120
  hideUpselling
89
121
  businessConfigs={cart?.business?.configs}
90
122
  hideCouponInput={configs?.multi_business_checkout_coupon_input_style?.value === 'group'}
91
- hideDeliveryFee={configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1'}
123
+ hideDeliveryFee={configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1'}
92
124
  hideDriverTip={configs?.multi_business_checkout_show_combined_driver_tip?.value === '1'}
125
+ cartsOpened={cartsOpened}
126
+ setCartsOpened={setCartsOpened}
127
+ changeActiveState={changeActiveState}
128
+ isActive={cartsOpened?.includes?.(cart?.uuid) || !!singleBusiness}
93
129
  />
94
130
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40, marginTop: 20 }} />
95
131
  </>
@@ -99,53 +135,55 @@ export const CartContent = (props: any) => {
99
135
  {isMultiCheckout && (
100
136
  <>
101
137
  {!!cartsAvailable.length && (
102
- <ChCartsTotal>
103
- {!!totalCartsFee && configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1' && (
104
- <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
105
- <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
106
- {t('TOTAL_DELIVERY_FEE', 'Total delivery fee')}
107
- </OText>
108
- <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
109
- {parsePrice(totalCartsFee)}
110
- </OText>
111
- </View>
112
- )}
113
- {cartsAvailable.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0) > 0 &&
114
- configs?.multi_business_checkout_show_combined_driver_tip?.value === '1' && (
115
- <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
116
- <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
117
- {t('DRIVER_TIP', 'Driver tip')}
118
- </OText>
119
- <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
120
- {parsePrice(cartsAvailable.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0))}
121
- </OText>
122
- </View>
123
- )}
124
- <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
125
- <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>
126
- {t('TOTAL_FOR_ALL_CARTS', 'Total for all Carts')}
127
- </OText>
128
- <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>{parsePrice(totalCartsPrice)}</OText>
129
- </View>
130
- <View style={{ flexDirection: 'row', justifyContent: 'center', marginVertical: 20 }}>
131
- <OText size={14} color={theme.colors.textNormal} weight={'300'} style={{ textAlign: 'center' }}>
132
- {t('CART_GROUP_MESSAGE_ALERT', 'Discounts may be applied at the time of payment for this group.')}
133
- </OText>
134
- </View>
135
- </ChCartsTotal>
138
+ <>
139
+ <ChCartsTotal>
140
+ {!!totalCartsFee && configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1' && (
141
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
142
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
143
+ {t('TOTAL_DELIVERY_FEE', 'Total delivery fee')}
144
+ </OText>
145
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
146
+ {parsePrice(totalCartsFee)}
147
+ </OText>
148
+ </View>
149
+ )}
150
+ {cartsAvailable.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0) > 0 &&
151
+ configs?.multi_business_checkout_show_combined_driver_tip?.value === '1' && (
152
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
153
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
154
+ {t('DRIVER_TIP', 'Driver tip')}
155
+ </OText>
156
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
157
+ {parsePrice(cartsAvailable.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0))}
158
+ </OText>
159
+ </View>
160
+ )}
161
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
162
+ <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>
163
+ {t('TOTAL_FOR_ALL_CARTS', 'Total for all Carts')}
164
+ </OText>
165
+ <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>{parsePrice(totalCartsPrice)}</OText>
166
+ </View>
167
+ <View style={{ flexDirection: 'row', justifyContent: 'center', marginVertical: 20 }}>
168
+ <OText size={14} color={theme.colors.textNormal} weight={'300'} style={{ textAlign: 'center' }}>
169
+ {t('CART_GROUP_MESSAGE_ALERT', 'Discounts may be applied at the time of payment for this group.')}
170
+ </OText>
171
+ </View>
172
+ </ChCartsTotal>
173
+ <CheckoutAction style={{ marginTop: 0 }}>
174
+ <OButton
175
+ text={t('CHECKOUT', 'Checkout')}
176
+ bgColor={!cartsAvailable.length ? theme.colors.secundary : theme.colors.primary}
177
+ isDisabled={!cartsAvailable.length}
178
+ borderColor={theme.colors.primary}
179
+ imgRightSrc={null}
180
+ textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
181
+ onClick={() => handleCheckoutRedirect()}
182
+ style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
183
+ />
184
+ </CheckoutAction>
185
+ </>
136
186
  )}
137
- <CheckoutAction style={{ marginTop: 0 }}>
138
- <OButton
139
- text={t('CHECKOUT', 'Checkout')}
140
- bgColor={!cartsAvailable.length ? theme.colors.secundary : theme.colors.primary}
141
- isDisabled={!cartsAvailable.length}
142
- borderColor={theme.colors.primary}
143
- imgRightSrc={null}
144
- textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
145
- onClick={() => handleCheckoutRedirect()}
146
- style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
147
- />
148
- </CheckoutAction>
149
187
  </>
150
188
  )}
151
189
  </>
@@ -9,7 +9,7 @@ export const Container = styled.View`
9
9
  `
10
10
 
11
11
  export const ItemListing = styled.ScrollView`
12
- padding: 0 40px;
12
+ padding: 0 20px;
13
13
  margin: 0 0 140px;
14
14
  `
15
15
 
@@ -19,7 +19,7 @@ export const TopHeader = styled.View`
19
19
  align-items: center;
20
20
  justify-content: space-between;
21
21
  z-index: 1;
22
- padding: 0 40px;
22
+ padding: 0 20px;
23
23
  `
24
24
 
25
25
  export const HeaderItem = styled.TouchableOpacity`