ordering-ui-react-native 0.21.63 → 0.21.64-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 (163) hide show
  1. package/package.json +6 -7
  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 +9 -6
  10. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
  11. package/themes/business/src/components/Chat/index.tsx +3 -1
  12. package/themes/business/src/components/DriverMap/index.tsx +36 -23
  13. package/themes/business/src/components/GoogleMap/index.tsx +15 -8
  14. package/themes/business/src/components/Home/index.tsx +5 -1
  15. package/themes/business/src/components/LanguageSelector/index.tsx +1 -2
  16. package/themes/business/src/components/LanguageSelector/lang_country.json +515 -70
  17. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  18. package/themes/business/src/components/MapView/index.tsx +30 -15
  19. package/themes/business/src/components/NewOrderNotification/index.tsx +76 -26
  20. package/themes/business/src/components/OrderDetails/Business.tsx +63 -7
  21. package/themes/business/src/components/OrderDetails/Delivery.tsx +36 -21
  22. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +107 -56
  23. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +61 -35
  24. package/themes/business/src/components/OrderDetails/styles.tsx +29 -3
  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/OrdersListManager/index.tsx +9 -1
  28. package/themes/business/src/components/OrdersOption/index.tsx +249 -126
  29. package/themes/business/src/components/PhoneInputNumber/index.tsx +8 -5
  30. package/themes/business/src/components/PreviousMessages/index.tsx +12 -0
  31. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +29 -19
  32. package/themes/business/src/components/PreviousOrders/index.tsx +5 -3
  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/Sessions/index.tsx +187 -0
  40. package/themes/business/src/components/Sessions/styles.tsx +20 -0
  41. package/themes/business/src/components/StoresList/index.tsx +2 -2
  42. package/themes/business/src/components/UserFormDetails/index.tsx +111 -107
  43. package/themes/business/src/components/UserProfileForm/index.tsx +106 -54
  44. package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
  45. package/themes/business/src/components/shared/OInput.tsx +2 -0
  46. package/themes/business/src/components/shared/OTextarea.tsx +8 -9
  47. package/themes/business/src/hooks/useLocation.tsx +5 -4
  48. package/themes/business/src/types/index.tsx +23 -5
  49. package/themes/business/src/utils/index.tsx +19 -1
  50. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  51. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  52. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  53. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  54. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  55. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  56. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  57. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  58. package/themes/original/index.tsx +13 -1
  59. package/themes/original/src/components/AddressDetails/index.tsx +20 -10
  60. package/themes/original/src/components/AddressForm/index.tsx +32 -17
  61. package/themes/original/src/components/AddressList/index.tsx +8 -7
  62. package/themes/original/src/components/AnalyticsSegment/index.tsx +6 -6
  63. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  64. package/themes/original/src/components/BusinessBasicInformation/index.tsx +6 -9
  65. package/themes/original/src/components/BusinessController/index.tsx +14 -9
  66. package/themes/original/src/components/BusinessController/styles.tsx +8 -7
  67. package/themes/original/src/components/BusinessItemAccordion/index.tsx +15 -7
  68. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +2 -3
  69. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +1 -3
  70. package/themes/original/src/components/BusinessListingSearch/index.tsx +1 -2
  71. package/themes/original/src/components/BusinessPreorder/index.tsx +20 -15
  72. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +5 -5
  73. package/themes/original/src/components/BusinessProductsList/index.tsx +3 -3
  74. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  75. package/themes/original/src/components/BusinessProductsListing/index.tsx +28 -13
  76. package/themes/original/src/components/BusinessTypeFilter/index.tsx +9 -8
  77. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
  78. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +1 -1
  79. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  80. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  81. package/themes/original/src/components/Cart/index.tsx +26 -9
  82. package/themes/original/src/components/CartContent/index.tsx +60 -45
  83. package/themes/original/src/components/Checkout/index.tsx +94 -62
  84. package/themes/original/src/components/CitiesControl/index.tsx +0 -3
  85. package/themes/original/src/components/CouponControl/index.tsx +1 -3
  86. package/themes/original/src/components/DriverTips/index.tsx +1 -3
  87. package/themes/original/src/components/Favorite/index.tsx +1 -5
  88. package/themes/original/src/components/FavoriteList/index.tsx +0 -1
  89. package/themes/original/src/components/ForgotPasswordForm/index.tsx +5 -7
  90. package/themes/original/src/components/GiftCard/GiftCardOrdersList/index.tsx +64 -0
  91. package/themes/original/src/components/GiftCard/GiftCardOrdersList/styles.tsx +8 -0
  92. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +15 -17
  93. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +3 -7
  94. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +24 -32
  95. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +9 -11
  96. package/themes/original/src/components/GiftCard/SingleGiftCard/index.tsx +101 -0
  97. package/themes/original/src/components/GiftCard/SingleGiftCard/styles.tsx +4 -0
  98. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +82 -0
  99. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/styles.tsx +9 -0
  100. package/themes/original/src/components/GoogleMap/index.tsx +39 -18
  101. package/themes/original/src/components/Help/index.tsx +2 -0
  102. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +2 -2
  103. package/themes/original/src/components/Home/index.tsx +2 -10
  104. package/themes/original/src/components/LoginForm/Otp/index.tsx +4 -19
  105. package/themes/original/src/components/LoginForm/index.tsx +4 -7
  106. package/themes/original/src/components/MessageListing/index.tsx +1 -0
  107. package/themes/original/src/components/Messages/index.tsx +8 -7
  108. package/themes/original/src/components/MomentOption/index.tsx +13 -2
  109. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +7 -3
  110. package/themes/original/src/components/MultiCheckout/index.tsx +123 -62
  111. package/themes/original/src/components/MultiCheckout/styles.tsx +17 -0
  112. package/themes/original/src/components/MultiOrdersDetails/index.tsx +20 -14
  113. package/themes/original/src/components/MyOrders/index.tsx +21 -26
  114. package/themes/original/src/components/NavBar/index.tsx +4 -2
  115. package/themes/original/src/components/NetworkError/index.tsx +0 -5
  116. package/themes/original/src/components/NotFoundSource/index.tsx +0 -3
  117. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +5 -7
  118. package/themes/original/src/components/OrderDetails/index.tsx +5 -7
  119. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  120. package/themes/original/src/components/OrderProgress/index.tsx +22 -3
  121. package/themes/original/src/components/OrderTypeSelector/index.tsx +7 -6
  122. package/themes/original/src/components/OrdersOption/index.tsx +2 -4
  123. package/themes/original/src/components/PaymentOptionCard/index.tsx +4 -2
  124. package/themes/original/src/components/PaymentOptionStripe/index.tsx +0 -5
  125. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  126. package/themes/original/src/components/PaymentOptions/index.tsx +47 -6
  127. package/themes/original/src/components/PlaceSpot/index.tsx +1 -3
  128. package/themes/original/src/components/PreviousOrders/index.tsx +1 -2
  129. package/themes/original/src/components/ProductForm/ActionButton.tsx +16 -19
  130. package/themes/original/src/components/ProductForm/index.tsx +120 -109
  131. package/themes/original/src/components/ProductItemAccordion/index.tsx +55 -49
  132. package/themes/original/src/components/ProductItemAccordion/styles.tsx +3 -4
  133. package/themes/original/src/components/ProductOptionSubOption/index.tsx +112 -91
  134. package/themes/original/src/components/ProfessionalProfile/index.tsx +4 -5
  135. package/themes/original/src/components/Promotions/index.tsx +6 -9
  136. package/themes/original/src/components/ReviewDriver/index.tsx +1 -1
  137. package/themes/original/src/components/ReviewOrder/index.tsx +2 -2
  138. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  139. package/themes/original/src/components/ReviewTrigger/index.tsx +2 -2
  140. package/themes/original/src/components/ServiceForm/index.tsx +52 -54
  141. package/themes/original/src/components/Sessions/index.tsx +3 -3
  142. package/themes/original/src/components/SignupForm/index.tsx +65 -67
  143. package/themes/original/src/components/SingleOrderCard/index.tsx +1 -2
  144. package/themes/original/src/components/SingleProductCard/index.tsx +5 -6
  145. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  146. package/themes/original/src/components/StripeCardForm/index.tsx +0 -3
  147. package/themes/original/src/components/StripeCardsList/index.tsx +12 -36
  148. package/themes/original/src/components/StripeElementsForm/index.tsx +78 -59
  149. package/themes/original/src/components/StripeElementsForm/naked.tsx +48 -1
  150. package/themes/original/src/components/StripeRedirectForm/index.tsx +0 -3
  151. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +10 -7
  152. package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +8 -3
  153. package/themes/original/src/components/UserFormDetails/index.tsx +83 -84
  154. package/themes/original/src/components/UserProfile/index.tsx +11 -2
  155. package/themes/original/src/components/Wallets/index.tsx +7 -4
  156. package/themes/original/src/components/WebsocketStatus/index.tsx +169 -0
  157. package/themes/original/src/components/WebsocketStatus/styles.tsx +28 -0
  158. package/themes/original/src/components/shared/OAlert.tsx +2 -1
  159. package/themes/original/src/components/shared/OButton.tsx +8 -7
  160. package/themes/original/src/components/shared/OInput.tsx +1 -4
  161. package/themes/original/src/types/index.tsx +5 -1
  162. package/themes/original/src/utils/index.tsx +12 -1
  163. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -26,9 +26,9 @@ import { BusinessTypeFilterParams } from '../../types';
26
26
  const windowWidth = Dimensions.get('window').width;
27
27
 
28
28
  export const BusinessTypeFilterUI = (props: BusinessTypeFilterParams) => {
29
- const {
30
- typesState,
31
- currentTypeSelected,
29
+ const {
30
+ typesState,
31
+ currentTypeSelected,
32
32
  handleChangeBusinessType,
33
33
  setBusinessTypes,
34
34
  isAppoint
@@ -38,13 +38,13 @@ export const BusinessTypeFilterUI = (props: BusinessTypeFilterParams) => {
38
38
 
39
39
  const theme = useTheme();
40
40
  const [isOpenAllCategories, setIsOpenAllCategories] = useState(false)
41
- const defaultImage = (name : string) => theme.images?.categories?.[name.toLowerCase().replace(' ', '')]
41
+ const defaultImage = (name: string) => theme.images?.categories?.[name.toLowerCase().replace(' ', '')]
42
42
 
43
43
  useEffect(() => {
44
- if(typesState?.types?.length > 0){
45
- setBusinessTypes && setBusinessTypes(typesState?.types)
44
+ if (typesState?.types?.length > 0) {
45
+ setBusinessTypes && setBusinessTypes(typesState?.types)
46
46
  }
47
- }, [typesState])
47
+ }, [typesState])
48
48
 
49
49
  const handleChangeServiceType = (serviceId: any) => {
50
50
  if (serviceId === currentTypeSelected) {
@@ -119,10 +119,11 @@ export const BusinessTypeFilterUI = (props: BusinessTypeFilterParams) => {
119
119
  <OButton
120
120
  key={i}
121
121
  bgColor={(currentTypeSelected === businessType?.id) ? theme.colors.primary : theme.colors.backgroundGray200}
122
+ borderColor={(currentTypeSelected === businessType?.id) ? theme.colors.primary : theme.colors.backgroundGray200}
122
123
  onClick={() => handleChangeServiceType(businessType?.id)}
123
124
  text={`${businessType?.name} ${(currentTypeSelected === businessType?.id) ? ' X' : ''}`}
124
125
  style={styles.businessType}
125
- textStyle={{ fontSize: 10, color: (currentTypeSelected === businessType?.id) ? theme.colors.backgroundLight : theme.colors.textNormal }}
126
+ textStyle={{ fontSize: 10, color: (currentTypeSelected === businessType?.id) ? theme.colors.white : theme.colors.textNormal }}
126
127
  />
127
128
  ))}
128
129
  </ServiceWrapper>
@@ -392,10 +392,11 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
392
392
  <OButton
393
393
  key={i}
394
394
  bgColor={(priceLevelSelected === price?.level) ? theme.colors.primary : theme.colors.backgroundGray200}
395
+ borderColor={(priceLevelSelected === price?.level) ? theme.colors.primary : theme.colors.backgroundGray200}
395
396
  onClick={() => handleChangePriceLevel(price?.level)}
396
397
  text={`${price.content} ${(priceLevelSelected === price?.level) ? ' X' : ''}`}
397
398
  style={styles.priceLevel}
398
- textStyle={{ fontSize: 10, color: (priceLevelSelected === price?.level) ? theme.colors.backgroundLight : theme.colors.textNormal }}
399
+ textStyle={{ fontSize: 10, color: (priceLevelSelected === price?.level) ? theme.colors.backgroundLight : theme.colors.black }}
399
400
  />
400
401
  ))}
401
402
  </ScrollView>
@@ -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) {
@@ -60,7 +60,7 @@ export const WrapMomentOption = styled.TouchableOpacity`
60
60
 
61
61
  export const HeaderWrapper = styled.ImageBackground`
62
62
  width: 100%;
63
- height: ${({ bgHeaderHeight } : any) => bgHeaderHeight || '270px'};
63
+ height: 270px;
64
64
  padding: 20px;
65
65
  background-color: transparent;
66
66
  `;
@@ -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
 
@@ -19,7 +19,7 @@ import { CouponControl } from '../CouponControl';
19
19
  import { OButton, OInput, OModal, OText } from '../shared';
20
20
  import { UpsellingProducts } from '../UpsellingProducts';
21
21
  import { verifyDecimals } from '../../utils';
22
- import { ActivityIndicator, TouchableOpacity, View } from 'react-native';
22
+ import { ActivityIndicator, TouchableOpacity, View, Vibration } from 'react-native';
23
23
  import AntIcon from 'react-native-vector-icons/AntDesign'
24
24
  import { TaxInformation } from '../TaxInformation';
25
25
  import { CartStoresListing } from '../CartStoresListing';
@@ -114,6 +114,7 @@ const CartUI = (props: any) => {
114
114
  }
115
115
 
116
116
  const handleUpsellingPage = (individualCart: any) => {
117
+ Vibration.vibrate(100)
117
118
  const isProductCartParam = !!individualCart?.products?.length
118
119
  setOpenUpselling(false)
119
120
  setCanOpenUpselling(false)
@@ -121,7 +122,7 @@ const CartUI = (props: any) => {
121
122
  const cartsAvailable: any = Object.values(orderState?.carts)
122
123
  ?.filter((_cart: any) => _cart?.valid && _cart?.status !== 2 && _cart?.products?.length)
123
124
  ?.filter((_c: any) => !isProductCartParam ? _c.uuid !== individualCart?.uuid : _c)
124
- if (cartsAvailable.length === 1 || !isMultiCheckout) {
125
+ if (cartsAvailable.length === 1 || !isMultiCheckout || !cart?.business_id) {
125
126
  const cart = isMultiCheckout ? cartsAvailable[0] : individualCart
126
127
  onNavigationRedirect('CheckoutNavigator', {
127
128
  screen: 'CheckoutPage',
@@ -196,6 +197,19 @@ const CartUI = (props: any) => {
196
197
  return acc = acc
197
198
  }, cart?.subtotal)
198
199
 
200
+ const handleClickCheckout = () => {
201
+ Vibration.vibrate(100)
202
+ if (cart?.business_id) {
203
+ setOpenUpselling(true)
204
+ } else {
205
+ onNavigationRedirect('CheckoutNavigator', {
206
+ screen: 'CheckoutPage',
207
+ cartUuid: cart?.uuid,
208
+ cartTotal: cart?.total
209
+ }, true)
210
+ }
211
+ }
212
+
199
213
  useEffect(() => {
200
214
  const limitDays = parseInt(preorderMaximumDays ?? configs?.max_days_preorder?.value, 10)
201
215
  const currentDate = new Date()
@@ -211,7 +225,7 @@ const CartUI = (props: any) => {
211
225
 
212
226
  return (
213
227
  <CContainer>
214
- {openUpselling && (
228
+ {!!openUpselling && (
215
229
  <UpsellingProducts
216
230
  handleUpsellingPage={handleUpsellingPage}
217
231
  openUpselling={openUpselling}
@@ -231,8 +245,11 @@ const CartUI = (props: any) => {
231
245
  handleClearProducts={handleClearProducts}
232
246
  handleCartOpen={handleCartOpen}
233
247
  onNavigationRedirect={props.onNavigationRedirect}
234
- handleChangeStore={() => setOpenChangeStore(true)}
235
- handleClickCheckout={() => setOpenUpselling(true)}
248
+ handleChangeStore={() => {
249
+ Vibration.vibrate(100)
250
+ setOpenChangeStore(true)
251
+ }}
252
+ handleClickCheckout={() => handleClickCheckout()}
236
253
  checkoutButtonDisabled={(openUpselling && !canOpenUpselling) || subtotalWithTaxes < cart?.minimum || !cart?.valid_address}
237
254
  isMultiCheckout={isMultiCheckout}
238
255
  isFromUpselling={isFromUpselling}
@@ -532,7 +549,7 @@ const CartUI = (props: any) => {
532
549
  />
533
550
  </View>
534
551
  )}
535
- {!isMultiCheckout && (
552
+ {(!isMultiCheckout || !cart?.business_id) && (
536
553
  <>
537
554
  {cart?.valid_products ? (
538
555
  <CheckoutAction>
@@ -545,11 +562,11 @@ const CartUI = (props: any) => {
545
562
  `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`
546
563
  )}
547
564
  bgColor={(subtotalWithTaxes < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
565
+ borderColor={(subtotalWithTaxes < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
548
566
  isDisabled={(openUpselling && !canOpenUpselling) || subtotalWithTaxes < cart?.minimum || !cart?.valid_address}
549
- borderColor={theme.colors.primary}
550
567
  imgRightSrc={null}
551
- textStyle={{ color: '#fff', textAlign: 'center', flex: 1 }}
552
- onClick={() => setOpenUpselling(true)}
568
+ textStyle={{ textAlign: 'center', flex: 1 }}
569
+ onClick={() => handleClickCheckout()}
553
570
  style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
554
571
  />
555
572
  </CheckoutAction>
@@ -1,5 +1,5 @@
1
- import React, { useCallback, useState } from 'react';
2
- import { View } from 'react-native';
1
+ import React, { useCallback, useEffect, useState } from 'react';
2
+ import { Vibration, View } from 'react-native';
3
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';
@@ -13,7 +13,8 @@ export const CartContent = (props: any) => {
13
13
  const {
14
14
  onNavigationRedirect,
15
15
  singleBusiness,
16
- businessSlug
16
+ businessSlug,
17
+ navigation
17
18
  } = props
18
19
 
19
20
  const theme = useTheme();
@@ -22,7 +23,7 @@ export const CartContent = (props: any) => {
22
23
  const [{ parsePrice }] = useUtils();
23
24
  const [isCartsLoading, setIsCartsLoading] = useState(false)
24
25
  const [cartsOpened, setCartsOpened] = useState([])
25
- const [{ carts: cartsContext }] = useOrder();
26
+ const [{ carts: cartsContext }, { confirmCart }] = useOrder();
26
27
  const cartsList =
27
28
  (cartsContext &&
28
29
  Object.values(cartsContext).filter((cart: any) => cart.products.length > 0)) ??
@@ -32,12 +33,13 @@ export const CartContent = (props: any) => {
32
33
  : cartsList
33
34
  const isOrderStateCarts = !!carts
34
35
  const isMultiCheckout = configs?.checkout_multi_business_enabled?.value === '1'
35
- const cartsAvailable: any = Object.values(carts || {})?.filter((cart: any) => cart?.valid && cart?.status !== 2)
36
+ const cartsAvailable: any = Object.values(carts || {})?.filter((cart: any) => cart?.valid && cart?.status !== 2 && cart?.business_id)
36
37
  const totalCartsPrice = cartsAvailable?.length && cartsAvailable.reduce((total: any, cart: any) => { return total + cart?.total }, 0)
37
38
  const totalCartsFee = cartsAvailable?.length && cartsAvailable
38
39
  ?.filter((cart: any) => cart?.status !== 1 && cart?.valid && cart?.products?.length)
39
40
  ?.reduce((total: any, cart: any) => { return total + (cart?.delivery_price_with_discount) }, 0)
40
41
  const handleCheckoutRedirect = () => {
42
+ Vibration.vibrate(100)
41
43
  if (cartsAvailable.length === 1) {
42
44
  onNavigationRedirect('CheckoutNavigator', {
43
45
  screen: 'CheckoutPage',
@@ -71,7 +73,7 @@ export const CartContent = (props: any) => {
71
73
  }
72
74
  }
73
75
 
74
- const changeActiveState = useCallback((isClosed : boolean, uuid : string) => {
76
+ const changeActiveState = useCallback((isClosed: boolean, uuid: string) => {
75
77
  const isActive = cartsOpened?.includes?.(uuid) || !!singleBusiness
76
78
  if (isActive || !isClosed) {
77
79
  setCartsOpened(cartsOpened?.filter?.((_uuid) => _uuid !== uuid))
@@ -83,6 +85,20 @@ export const CartContent = (props: any) => {
83
85
  }
84
86
  }, [cartsOpened])
85
87
 
88
+ useEffect(() => {
89
+ const unsuscribe = navigation.addListener('focus', () => {
90
+ const cartsListBlockedByPaypal = carts?.filter((cart: any) => cart?.status === 2 && cart?.paymethod_data?.gateway === 'paypal')
91
+ if (cartsListBlockedByPaypal?.length > 0) {
92
+ cartsListBlockedByPaypal.map(async (cart: any) => {
93
+ await confirmCart(cart?.uuid)
94
+ })
95
+ }
96
+ })
97
+ return () => {
98
+ return unsuscribe()
99
+ }
100
+ }, [carts, navigation])
101
+
86
102
  return (
87
103
  <CCContainer
88
104
  style={{ paddingHorizontal: 20 }}
@@ -120,53 +136,52 @@ export const CartContent = (props: any) => {
120
136
  {isMultiCheckout && (
121
137
  <>
122
138
  {!!cartsAvailable.length && (
123
- <ChCartsTotal>
124
- {!!totalCartsFee && configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1' && (
125
- <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
126
- <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
127
- {t('TOTAL_DELIVERY_FEE', 'Total delivery fee')}
128
- </OText>
129
- <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
130
- {parsePrice(totalCartsFee)}
131
- </OText>
132
- </View>
133
- )}
134
- {cartsAvailable.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0) > 0 &&
135
- configs?.multi_business_checkout_show_combined_driver_tip?.value === '1' && (
139
+ <>
140
+ <ChCartsTotal>
141
+ {!!totalCartsFee && configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1' && (
136
142
  <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
137
143
  <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
138
- {t('DRIVER_TIP', 'Driver tip')}
144
+ {t('TOTAL_DELIVERY_FEE', 'Total delivery fee')}
139
145
  </OText>
140
146
  <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
141
- {parsePrice(cartsAvailable.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0))}
147
+ {parsePrice(totalCartsFee)}
142
148
  </OText>
143
149
  </View>
144
150
  )}
145
- <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
146
- <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>
147
- {t('TOTAL_FOR_ALL_CARTS', 'Total for all Carts')}
148
- </OText>
149
- <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>{parsePrice(totalCartsPrice)}</OText>
150
- </View>
151
- <View style={{ flexDirection: 'row', justifyContent: 'center', marginVertical: 20 }}>
152
- <OText size={14} color={theme.colors.textNormal} weight={'300'} style={{ textAlign: 'center' }}>
153
- {t('CART_GROUP_MESSAGE_ALERT', 'Discounts may be applied at the time of payment for this group.')}
154
- </OText>
155
- </View>
156
- </ChCartsTotal>
151
+ {cartsAvailable.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0) > 0 &&
152
+ configs?.multi_business_checkout_show_combined_driver_tip?.value === '1' && (
153
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
154
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
155
+ {t('DRIVER_TIP', 'Driver tip')}
156
+ </OText>
157
+ <OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
158
+ {parsePrice(cartsAvailable.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0))}
159
+ </OText>
160
+ </View>
161
+ )}
162
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
163
+ <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>
164
+ {t('TOTAL_FOR_ALL_CARTS', 'Total for all Carts')}
165
+ </OText>
166
+ <OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>{parsePrice(totalCartsPrice)}</OText>
167
+ </View>
168
+ <View style={{ flexDirection: 'row', justifyContent: 'center', marginVertical: 20 }}>
169
+ <OText size={14} color={theme.colors.textNormal} weight={'300'} style={{ textAlign: 'center' }}>
170
+ {t('CART_GROUP_MESSAGE_ALERT', 'Discounts may be applied at the time of payment for this group.')}
171
+ </OText>
172
+ </View>
173
+ </ChCartsTotal>
174
+ <CheckoutAction style={{ marginTop: 0 }}>
175
+ <OButton
176
+ text={t('CHECKOUT', 'Checkout')}
177
+ isDisabled={!cartsAvailable.length}
178
+ imgRightSrc={null}
179
+ onClick={() => handleCheckoutRedirect()}
180
+ style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
181
+ />
182
+ </CheckoutAction>
183
+ </>
157
184
  )}
158
- <CheckoutAction style={{ marginTop: 0 }}>
159
- <OButton
160
- text={t('CHECKOUT', 'Checkout')}
161
- bgColor={!cartsAvailable.length ? theme.colors.secundary : theme.colors.primary}
162
- isDisabled={!cartsAvailable.length}
163
- borderColor={theme.colors.primary}
164
- imgRightSrc={null}
165
- textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
166
- onClick={() => handleCheckoutRedirect()}
167
- style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
168
- />
169
- </CheckoutAction>
170
185
  </>
171
186
  )}
172
187
  </>
@@ -1,10 +1,11 @@
1
1
  import React, { useState, useEffect, useCallback, useRef } from 'react';
2
- import { View, StyleSheet, TouchableOpacity, Platform, I18nManager, ScrollView, Keyboard } from 'react-native';
2
+ import { View, StyleSheet, TouchableOpacity, Platform, I18nManager, ScrollView, Keyboard, BackHandler, SafeAreaView } from 'react-native';
3
3
  import { initStripe, useConfirmPayment } from '@stripe/stripe-react-native';
4
4
  import NativeStripeSdk from '@stripe/stripe-react-native/src/NativeStripeSdk'
5
5
  import Picker from 'react-native-country-picker-modal';
6
6
  import MaterialIcons from 'react-native-vector-icons/MaterialIcons'
7
7
  import IconAntDesign from 'react-native-vector-icons/AntDesign';
8
+ import { useIsFocused } from '@react-navigation/native';
8
9
 
9
10
  import ReactNativeHapticFeedback from "react-native-haptic-feedback";
10
11
  import {
@@ -100,10 +101,13 @@ const CheckoutUI = (props: any) => {
100
101
  currency,
101
102
  merchantId,
102
103
  setPlaceSpotNumber,
103
- maxDate
104
+ maxDate,
105
+ androidAppId,
106
+ urlscheme
104
107
  } = props
105
108
 
106
109
  const theme = useTheme();
110
+ const isFocused = useIsFocused();
107
111
 
108
112
  const styles = StyleSheet.create({
109
113
  btnBackArrow: {
@@ -159,7 +163,7 @@ const CheckoutUI = (props: any) => {
159
163
  const [phoneUpdate, setPhoneUpdate] = useState(false);
160
164
  const [openChangeStore, setOpenChangeStore] = useState(false)
161
165
  const [isDeliveryOptionModalVisible, setIsDeliveryOptionModalVisible] = useState(false)
162
- const [showGateway, setShowGateway] = useState<any>({ closedByUsed: false, open: false });
166
+ const [showGateway, setShowGateway] = useState<any>({ closedByUser: false, open: false });
163
167
  const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
164
168
  const [isOpen, setIsOpen] = useState(false)
165
169
  const [requiredFields, setRequiredFields] = useState<any>([])
@@ -170,12 +174,12 @@ const CheckoutUI = (props: any) => {
170
174
  const [paymethodClicked, setPaymethodClicked] = useState<any>(null)
171
175
  const [showTitle, setShowTitle] = useState(false)
172
176
  const [cardList, setCardList] = useState<any>({ cards: [], loading: false, error: null })
177
+ const [isGiftCardCart, setIsGiftCardCart] = useState(!cart?.business_id)
173
178
  const containerRef = useRef<any>()
174
179
  const cardsMethods = ['credomatic']
175
180
  const stripePaymethods: any = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect']
176
181
  const placeSpotTypes = [3, 4, 5]
177
182
  const placeSpotsEnabled = placeSpotTypes.includes(options?.type)
178
- const isGiftCardCart = !cart?.business_id
179
183
  const businessConfigs = businessDetails?.business?.configs ?? []
180
184
  const isWalletCashEnabled = businessConfigs.find((config: any) => config.key === 'wallet_cash_enabled')?.value === '1'
181
185
  const isWalletCreditPointsEnabled = businessConfigs.find((config: any) => config.key === 'wallet_credit_point_enabled')?.value === '1'
@@ -208,7 +212,7 @@ const CheckoutUI = (props: any) => {
208
212
  const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) ||
209
213
  placing || errorCash || subtotalWithTaxes < cart?.minimum ||
210
214
  (cardsMethods.includes(paymethodSelected?.gateway) && cardList?.cards?.length === 0) ||
211
- (options.type === 1 &&
215
+ (options.type === 1 && !isGiftCardCart &&
212
216
  validationFields?.fields?.checkout?.driver_tip?.enabled &&
213
217
  validationFields?.fields?.checkout?.driver_tip?.required &&
214
218
  (Number(cart?.driver_tip) <= 0)) ||
@@ -359,11 +363,21 @@ const CheckoutUI = (props: any) => {
359
363
  if (cart?.products?.length === 0) {
360
364
  if (cart?.business_id !== null) {
361
365
  onNavigationRedirect('Business', { store: cart?.business?.slug, header: null, logo: null, fromMulti: props.fromMulti })
362
- } else {
366
+ } else if (isGiftCardCart) {
363
367
  onNavigationRedirect('Wallets')
364
368
  }
365
369
  }
366
- }, [cart?.products])
370
+ }, [cart?.products?.length])
371
+
372
+ useEffect(() => {
373
+ if (cart?.products?.length > 0) {
374
+ if (cart?.uuid && cart?.business_id === null) {
375
+ setIsGiftCardCart(true)
376
+ } else {
377
+ setIsGiftCardCart(false)
378
+ }
379
+ }
380
+ }, [cart?.uuid, cart?.products?.length])
367
381
 
368
382
  useEffect(() => {
369
383
  onFailPaypal()
@@ -403,6 +417,7 @@ const CheckoutUI = (props: any) => {
403
417
  }, [])
404
418
 
405
419
  useEffect(() => {
420
+ if (!isFocused) return
406
421
  if (!cartState?.loading && (cartState?.error || typeof cartState?.cart === 'string')) {
407
422
  const error = cartState?.error || typeof cartState.cart === 'string' && cartState.cart
408
423
  if (error) {
@@ -410,7 +425,7 @@ const CheckoutUI = (props: any) => {
410
425
  navigation.navigate('BusinessList')
411
426
  }
412
427
  }
413
- }, [cartState?.error, cartState?.cart, cartState?.loading])
428
+ }, [cartState?.error, cartState?.cart, cartState?.loading, isFocused])
414
429
 
415
430
  useEffect(() => {
416
431
  const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {
@@ -421,11 +436,26 @@ const CheckoutUI = (props: any) => {
421
436
  }
422
437
  }, [])
423
438
 
439
+ useEffect(() => {
440
+ const onBackFunction = () => {
441
+ if (webviewPaymethod?.gateway === 'paypal' && showGateway.open) {
442
+ setShowGateway({ open: false, closedByUser: true })
443
+ return true
444
+ } else {
445
+ return false
446
+ }
447
+ }
448
+ BackHandler.addEventListener('hardwareBackPress', onBackFunction)
449
+ return () => {
450
+ BackHandler.removeEventListener('hardwareBackPress', onBackFunction)
451
+ }
452
+ }, [BackHandler, webviewPaymethod?.gateway, showGateway.open])
453
+
424
454
  return (
425
455
  <>
426
- <View style={styles.wrapperNavbar}>
427
- <TopHeader>
428
- <>
456
+ <SafeAreaView style={{ backgroundColor: theme.colors.backgroundPage }}>
457
+ <View style={styles.wrapperNavbar}>
458
+ <TopHeader>
429
459
  <TopActions onPress={() => onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)}>
430
460
  <IconAntDesign
431
461
  name='arrowleft'
@@ -443,10 +473,10 @@ const CheckoutUI = (props: any) => {
443
473
  {t('CHECKOUT', 'Checkout')}
444
474
  </OText>
445
475
  )}
446
- </>
447
- </TopHeader>
448
- </View>
449
- <Container forwardRef={containerRef} noPadding onScroll={handleScroll}>
476
+ </TopHeader>
477
+ </View>
478
+ </SafeAreaView>
479
+ <Container pt={0} forwardRef={containerRef} showsVerticalScrollIndicator={false} noPadding onScroll={handleScroll}>
450
480
  <View style={styles.wrapperNavbar}>
451
481
  <NavBar
452
482
  hideArrowLeft
@@ -461,44 +491,46 @@ const CheckoutUI = (props: any) => {
461
491
  />
462
492
  </View>
463
493
  <ChContainer style={styles.pagePadding}>
464
- <ChSection style={{ paddingTop: 0 }}>
465
- <ChHeader>
466
- <CHMomentWrapper isCustomColor={isChewLayout} onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes })}>
467
- <OText
468
- size={12}
469
- numberOfLines={1}
470
- ellipsizeMode={'tail'}
471
- color={theme.colors?.[isChewLayout ? 'white' : 'textSecondary']}
472
- >
473
- {t(getTypesText(options?.type || 1), 'Delivery')}
474
- </OText>
475
- <OIcon
476
- src={theme.images.general.arrow_down}
477
- width={10}
478
- style={{ marginStart: 8 }}
479
- {...(isChewLayout && { color: 'white' })}
480
- />
481
- </CHMomentWrapper>
482
- <CHMomentWrapper
483
- onPress={() => handleMomentClick()}
484
- disabled={loading}
485
- >
486
- <OText size={12} numberOfLines={1} ellipsizeMode='tail' color={theme.colors.textSecondary}>
487
- {options?.moment
488
- ? parseDate(options?.moment, { outputFormat: configs?.dates_moment_format?.value })
489
- : t('ASAP_ABBREVIATION', 'ASAP')}
490
- </OText>
491
- {isPreOrder && (
494
+ {!isGiftCardCart && (
495
+ <ChSection style={{ paddingTop: 0 }}>
496
+ <ChHeader>
497
+ <CHMomentWrapper isCustomColor={isChewLayout} onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes })}>
498
+ <OText
499
+ size={12}
500
+ numberOfLines={1}
501
+ ellipsizeMode={'tail'}
502
+ color={theme.colors?.[isChewLayout ? 'white' : 'textSecondary']}
503
+ >
504
+ {t(getTypesText(options?.type || 1), 'Delivery')}
505
+ </OText>
492
506
  <OIcon
493
507
  src={theme.images.general.arrow_down}
494
508
  width={10}
495
509
  style={{ marginStart: 8 }}
510
+ {...(isChewLayout && { color: 'white' })}
496
511
  />
497
- )}
498
- </CHMomentWrapper>
499
- </ChHeader>
500
- <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 18, marginHorizontal: -40 }} />
501
- </ChSection>
512
+ </CHMomentWrapper>
513
+ <CHMomentWrapper
514
+ onPress={() => handleMomentClick()}
515
+ disabled={loading}
516
+ >
517
+ <OText size={12} numberOfLines={1} ellipsizeMode='tail' color={theme.colors.textSecondary}>
518
+ {options?.moment
519
+ ? parseDate(options?.moment, { outputFormat: configs?.dates_moment_format?.value })
520
+ : t('ASAP_ABBREVIATION', 'ASAP')}
521
+ </OText>
522
+ {isPreOrder && (
523
+ <OIcon
524
+ src={theme.images.general.arrow_down}
525
+ width={10}
526
+ style={{ marginStart: 8 }}
527
+ />
528
+ )}
529
+ </CHMomentWrapper>
530
+ </ChHeader>
531
+ <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 18, marginHorizontal: -40 }} />
532
+ </ChSection>
533
+ )}
502
534
 
503
535
  {!isGiftCardCart && !hideBusinessDetails && (
504
536
  <ChSection>
@@ -587,15 +619,11 @@ const CheckoutUI = (props: any) => {
587
619
  <HeaderTitle text={t('CUSTOMER_DETAILS', 'Customer details')} />
588
620
  <OButton
589
621
  text={t('SIGN_UP', 'Sign up')}
590
- textStyle={{ color: theme.colors.white }}
591
622
  style={{ borderRadius: 7.6, marginTop: 20 }}
592
623
  onClick={() => setOpenModal({ ...openModal, signup: true })}
593
624
  />
594
625
  <OButton
595
626
  text={t('LOGIN', 'Login')}
596
- textStyle={{ color: theme.colors.primary }}
597
- bgColor={theme.colors.white}
598
- borderColor={theme.colors.primary}
599
627
  style={{ borderRadius: 7.6, marginTop: 20 }}
600
628
  onClick={() => setOpenModal({ ...openModal, login: true })}
601
629
  />
@@ -739,7 +767,7 @@ const CheckoutUI = (props: any) => {
739
767
  cart?.status !== 2 &&
740
768
  validationFields?.fields?.checkout?.driver_tip?.enabled &&
741
769
  driverTipsOptions && driverTipsOptions?.length > 0 &&
742
- !isGiftCardCart &&
770
+ cart?.business_id &&
743
771
  (
744
772
  <ChSection>
745
773
  <ChDriverTips>
@@ -787,6 +815,8 @@ const CheckoutUI = (props: any) => {
787
815
  handlePaymentMethodClickCustom={handlePaymentMethodClick}
788
816
  handlePlaceOrder={handlePlaceOrder}
789
817
  merchantId={merchantId}
818
+ urlscheme={urlscheme}
819
+ androidAppId={androidAppId}
790
820
  setMethodPaySupported={setMethodPaySupported}
791
821
  methodPaySupported={methodPaySupported}
792
822
  placeByMethodPay={placeByMethodPay}
@@ -832,7 +862,7 @@ const CheckoutUI = (props: any) => {
832
862
  {!cartState.loading && cart && (
833
863
  <ChSection>
834
864
  <ChCart>
835
- {cartsWithProducts && cart?.products?.length === 0 ? (
865
+ {cartsWithProducts?.length > 0 && cart?.products?.length === 0 ? (
836
866
  <NotFoundSource
837
867
  content={t('NOT_FOUND_CARTS', 'Sorry, You don\'t seem to have any carts.')}
838
868
  btnTitle={t('SEARCH_REDIRECT', 'Go to Businesses')}
@@ -910,13 +940,15 @@ const CheckoutUI = (props: any) => {
910
940
  </OText>
911
941
  )}
912
942
 
913
- {!cart?.valid_products && cart?.status !== 2 && (
914
- <OText
915
- color={theme.colors.error}
916
- size={12}
917
- >
918
- {t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
919
- </OText>
943
+ {!cart?.valid_products && cart?.status !== 2 && cart?.total !== 0 && (
944
+ <>
945
+ <OText
946
+ color={theme.colors.error}
947
+ size={12}
948
+ >
949
+ {t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
950
+ </OText>
951
+ </>
920
952
  )}
921
953
  {cart?.valid_preorder !== undefined && !cart?.valid_preorder && (
922
954
  <OText
@@ -926,7 +958,7 @@ const CheckoutUI = (props: any) => {
926
958
  {t('INVALID_CART_MOMENT', 'Selected schedule time is invalid, please select a schedule into the business schedule interval.')}
927
959
  </OText>
928
960
  )}
929
- {options.type === 1 &&
961
+ {options.type === 1 && !isGiftCardCart &&
930
962
  validationFields?.fields?.checkout?.driver_tip?.enabled &&
931
963
  validationFields?.fields?.checkout?.driver_tip?.required &&
932
964
  (Number(cart?.driver_tip) <= 0) && (
@@ -69,10 +69,7 @@ export const CitiesControl = (props: any) => {
69
69
  </View>
70
70
  <OButton
71
71
  text={t('CONTINUE', 'Continue')}
72
- bgColor={theme.colors.primary}
73
- borderColor={theme.colors.primary}
74
72
  style={styles.btnStyle}
75
- textStyle={{ color: 'white' }}
76
73
  onClick={() => handleClick()}
77
74
  />
78
75
  </Container>
@@ -102,9 +102,7 @@ const CouponControlUI = (props: any) => {
102
102
  />
103
103
  <OButton
104
104
  onClick={() => onButtonApplyClick()}
105
- bgColor={theme.colors.primary}
106
- borderColor={theme.colors.primary}
107
- textStyle={{ color: 'white', fontSize: 12 }}
105
+ textStyle={{ fontSize: 12 }}
108
106
  imgRightSrc={null}
109
107
  text={t('APPLY', 'Apply')}
110
108
  isDisabled={!couponInput}