ordering-ui-react-native 0.16.67 → 0.16.68-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 (206) hide show
  1. package/package.json +6 -5
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/ActiveOrders/index.tsx +61 -63
  4. package/src/components/ActiveOrders/styles.tsx +8 -14
  5. package/src/components/BusinessInformation/index.tsx +19 -4
  6. package/src/components/BusinessInformation/styles.tsx +2 -2
  7. package/src/components/BusinessProductsList/index.tsx +10 -10
  8. package/src/components/BusinessesListing/index.tsx +1 -1
  9. package/src/components/Checkout/index.tsx +2 -1
  10. package/src/components/LanguageSelector/index.tsx +21 -16
  11. package/src/components/Messages/index.tsx +2 -2
  12. package/src/components/NotificationSetting/index.tsx +85 -0
  13. package/src/components/OrdersOption/index.tsx +54 -56
  14. package/src/components/PaymentOptions/index.tsx +298 -345
  15. package/src/components/PaymentOptionsWebView/index.tsx +119 -120
  16. package/src/components/SingleProductReview/index.tsx +7 -4
  17. package/src/components/StripeElementsForm/index.tsx +25 -16
  18. package/src/components/VerifyPhone/styles.tsx +1 -2
  19. package/src/components/shared/OBottomPopup.tsx +6 -2
  20. package/src/components/shared/OToast.tsx +4 -4
  21. package/src/index.tsx +2 -0
  22. package/src/types/@fatnlazycat/react-native-recaptcha-v3/index.d.ts +1 -0
  23. package/src/utils/index.tsx +2 -1
  24. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +260 -238
  25. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
  26. package/themes/business/src/components/BusinessController/index.tsx +2 -2
  27. package/themes/business/src/components/Chat/index.tsx +31 -31
  28. package/themes/business/src/components/DriverMap/index.tsx +7 -5
  29. package/themes/business/src/components/LoginForm/index.tsx +111 -74
  30. package/themes/business/src/components/MapView/index.tsx +14 -3
  31. package/themes/business/src/components/MessagesOption/index.tsx +11 -1
  32. package/themes/business/src/components/NewOrderNotification/index.tsx +31 -41
  33. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +70 -43
  34. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +3 -3
  35. package/themes/business/src/components/OrdersListManager/index.tsx +10 -3
  36. package/themes/business/src/components/OrdersOption/index.tsx +74 -76
  37. package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
  38. package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
  39. package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
  40. package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
  41. package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
  42. package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
  43. package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
  44. package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
  45. package/themes/business/src/components/PreviousMessages/index.tsx +17 -18
  46. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +250 -0
  47. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
  48. package/themes/business/src/components/PreviousOrders/index.tsx +440 -245
  49. package/themes/business/src/components/PreviousOrders/styles.tsx +31 -3
  50. package/themes/business/src/components/ProductItemAccordion/index.tsx +3 -2
  51. package/themes/business/src/components/ReviewCustomer/index.tsx +39 -15
  52. package/themes/business/src/components/shared/ODropDown.tsx +42 -8
  53. package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
  54. package/themes/business/src/components/shared/OLink.tsx +33 -13
  55. package/themes/business/src/components/shared/OText.tsx +8 -2
  56. package/themes/business/src/types/index.tsx +22 -10
  57. package/themes/business/src/utils/index.tsx +10 -0
  58. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  59. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  60. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  61. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -1
  62. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  63. package/themes/kiosk/src/components/LoginForm/index.tsx +121 -10
  64. package/themes/kiosk/src/components/LoginForm/styles.tsx +5 -0
  65. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  66. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  67. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  68. package/themes/kiosk/src/components/ProductForm/index.tsx +1 -14
  69. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  70. package/themes/kiosk/src/types/index.d.ts +2 -0
  71. package/themes/original/index.tsx +8 -0
  72. package/themes/original/src/components/AddressDetails/index.tsx +10 -8
  73. package/themes/original/src/components/AddressForm/index.tsx +153 -137
  74. package/themes/original/src/components/AddressList/index.tsx +18 -18
  75. package/themes/original/src/components/AddressList/styles.tsx +4 -2
  76. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  77. package/themes/original/src/components/BusinessBasicInformation/index.tsx +49 -33
  78. package/themes/original/src/components/BusinessController/index.tsx +101 -70
  79. package/themes/original/src/components/BusinessController/styles.tsx +14 -9
  80. package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
  81. package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -6
  82. package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
  83. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
  84. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
  85. package/themes/original/src/components/BusinessListingSearch/index.tsx +87 -142
  86. package/themes/original/src/components/BusinessListingSearch/styles.tsx +10 -12
  87. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
  88. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
  89. package/themes/original/src/components/BusinessProductsList/index.tsx +54 -60
  90. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  91. package/themes/original/src/components/BusinessProductsListing/index.tsx +561 -477
  92. package/themes/original/src/components/BusinessProductsListing/styles.tsx +13 -12
  93. package/themes/original/src/components/BusinessTypeFilter/index.tsx +3 -2
  94. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
  95. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +93 -98
  96. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -9
  97. package/themes/original/src/components/BusinessesListing/index.tsx +13 -8
  98. package/themes/original/src/components/Cart/index.tsx +63 -38
  99. package/themes/original/src/components/CartContent/index.tsx +80 -18
  100. package/themes/original/src/components/CartContent/styles.tsx +11 -1
  101. package/themes/original/src/components/Checkout/index.tsx +110 -114
  102. package/themes/original/src/components/Checkout/styles.tsx +4 -3
  103. package/themes/original/src/components/CitiesControl/index.tsx +89 -0
  104. package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
  105. package/themes/original/src/components/DriverTips/index.tsx +47 -37
  106. package/themes/original/src/components/DriverTips/styles.tsx +2 -1
  107. package/themes/original/src/components/Favorite/index.tsx +7 -4
  108. package/themes/original/src/components/Favorite/styles.tsx +1 -1
  109. package/themes/original/src/components/FavoriteList/index.tsx +69 -45
  110. package/themes/original/src/components/FloatingButton/index.tsx +1 -2
  111. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  112. package/themes/original/src/components/GPSButton/index.tsx +20 -19
  113. package/themes/original/src/components/GPSButton/styles.ts +3 -3
  114. package/themes/original/src/components/GoogleMap/index.tsx +10 -1
  115. package/themes/original/src/components/Help/index.tsx +7 -7
  116. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +14 -20
  117. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +6 -0
  118. package/themes/original/src/components/HelpGuide/index.tsx +12 -11
  119. package/themes/original/src/components/HelpGuide/styles.tsx +5 -0
  120. package/themes/original/src/components/HelpOrder/index.tsx +12 -20
  121. package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
  122. package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
  123. package/themes/original/src/components/LoginForm/Otp/index.tsx +89 -73
  124. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  125. package/themes/original/src/components/LoginForm/index.tsx +98 -41
  126. package/themes/original/src/components/LottieAnimation/index.tsx +78 -0
  127. package/themes/original/src/components/MessageListing/index.tsx +7 -7
  128. package/themes/original/src/components/Messages/index.tsx +35 -20
  129. package/themes/original/src/components/MomentOption/index.tsx +17 -11
  130. package/themes/original/src/components/MultiCart/index.tsx +50 -0
  131. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +92 -93
  132. package/themes/original/src/components/MultiCheckout/index.tsx +158 -77
  133. package/themes/original/src/components/MultiOrdersDetails/index.tsx +60 -33
  134. package/themes/original/src/components/MyOrders/index.tsx +86 -20
  135. package/themes/original/src/components/NavBar/index.tsx +7 -6
  136. package/themes/original/src/components/NetworkError/index.tsx +5 -3
  137. package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
  138. package/themes/original/src/components/Notifications/index.tsx +144 -0
  139. package/themes/original/src/components/Notifications/styles.tsx +20 -0
  140. package/themes/original/src/components/OrderDetails/index.tsx +114 -15
  141. package/themes/original/src/components/OrderDetails/styles.tsx +15 -2
  142. package/themes/original/src/components/OrderItAgain/index.tsx +75 -0
  143. package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
  144. package/themes/original/src/components/OrderProgress/index.tsx +77 -66
  145. package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
  146. package/themes/original/src/components/OrderSummary/index.tsx +3 -36
  147. package/themes/original/src/components/OrderTypeSelector/index.tsx +13 -6
  148. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +94 -98
  149. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +3 -0
  150. package/themes/original/src/components/OrdersOption/index.tsx +97 -55
  151. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
  152. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  153. package/themes/original/src/components/PaymentOptions/index.tsx +1 -2
  154. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  155. package/themes/original/src/components/PlaceSpot/index.tsx +249 -47
  156. package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
  157. package/themes/original/src/components/PreviousOrders/index.tsx +3 -2
  158. package/themes/original/src/components/ProductForm/index.tsx +212 -253
  159. package/themes/original/src/components/ProductForm/styles.tsx +5 -8
  160. package/themes/original/src/components/ProductItemAccordion/index.tsx +199 -128
  161. package/themes/original/src/components/ProductOptionSubOption/index.tsx +17 -9
  162. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +0 -1
  163. package/themes/original/src/components/ProfessionalFilter/index.tsx +2 -1
  164. package/themes/original/src/components/ProfessionalProfile/index.tsx +19 -8
  165. package/themes/original/src/components/Promotions/index.tsx +234 -220
  166. package/themes/original/src/components/Promotions/styles.tsx +7 -2
  167. package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
  168. package/themes/original/src/components/ReviewOrder/index.tsx +43 -11
  169. package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
  170. package/themes/original/src/components/ReviewProducts/index.tsx +8 -5
  171. package/themes/original/src/components/ReviewTrigger/index.tsx +27 -9
  172. package/themes/original/src/components/ReviewTrigger/styles.tsx +8 -1
  173. package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
  174. package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
  175. package/themes/original/src/components/ServiceForm/index.tsx +328 -264
  176. package/themes/original/src/components/SignupForm/index.tsx +134 -89
  177. package/themes/original/src/components/SingleOrderCard/index.tsx +129 -54
  178. package/themes/original/src/components/SingleOrderCard/styles.tsx +10 -8
  179. package/themes/original/src/components/SingleProductCard/index.tsx +101 -85
  180. package/themes/original/src/components/SingleProductCard/styles.tsx +2 -9
  181. package/themes/original/src/components/SingleProductReview/index.tsx +38 -5
  182. package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
  183. package/themes/original/src/components/StripeCardsList/index.tsx +1 -1
  184. package/themes/original/src/components/StripeElementsForm/index.tsx +13 -2
  185. package/themes/original/src/components/UpsellingProducts/index.tsx +244 -215
  186. package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
  187. package/themes/original/src/components/UserDetails/index.tsx +5 -3
  188. package/themes/original/src/components/UserFormDetails/index.tsx +6 -48
  189. package/themes/original/src/components/UserProfile/index.tsx +58 -35
  190. package/themes/original/src/components/UserProfile/styles.ts +17 -0
  191. package/themes/original/src/components/UserProfileForm/index.tsx +19 -28
  192. package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
  193. package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
  194. package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
  195. package/themes/original/src/components/Wallets/index.tsx +176 -164
  196. package/themes/original/src/components/Wallets/styles.tsx +12 -8
  197. package/themes/original/src/components/shared/CardAnimation.tsx +47 -0
  198. package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
  199. package/themes/original/src/components/shared/OBottomPopup.tsx +6 -4
  200. package/themes/original/src/components/shared/OButton.tsx +9 -4
  201. package/themes/original/src/components/shared/OIcon.tsx +8 -1
  202. package/themes/original/src/components/shared/OInput.tsx +10 -1
  203. package/themes/original/src/layouts/Container.tsx +13 -9
  204. package/themes/original/src/types/index.tsx +55 -5
  205. package/themes/original/src/utils/index.tsx +103 -58
  206. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,136 +1,129 @@
1
- import React, { useEffect, useState, useRef } from 'react';
2
- import { FlatList, TouchableOpacity, View, StyleSheet, KeyboardAvoidingView, Platform, ActivityIndicator } from 'react-native';
3
- import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
1
+ import React, { useEffect, useState } from 'react';
2
+ import { useTheme } from 'styled-components/native';
3
+ import { useApplePay } from '@stripe/stripe-react-native';
4
+ import { FlatList, TouchableOpacity, View, StyleSheet, KeyboardAvoidingView, Platform } from 'react-native';
4
5
  import {
5
- Placeholder,
6
- PlaceholderLine,
7
- Fade
6
+ Placeholder,
7
+ PlaceholderLine,
8
+ Fade
8
9
  } from "rn-placeholder";
9
10
 
10
11
  import {
11
- PaymentOptions as PaymentOptionsController,
12
- useLanguage,
13
- useSession,
14
- useApi,
15
- useOrder,
16
- ToastType,
17
- useToast
12
+ PaymentOptions as PaymentOptionsController,
13
+ useLanguage,
14
+ ToastType,
15
+ useToast,
18
16
  } from 'ordering-components/native';
19
17
 
18
+ import { getIconCard } from '../../utils';
20
19
  import { PaymentOptionCash } from '../PaymentOptionCash';
21
20
  import { StripeElementsForm } from '../StripeElementsForm';
22
21
  import { StripeCardsList } from '../StripeCardsList';
23
- // import { PaymentOptionStripe } from '../PaymentOptionStripe';
24
- // import { StripeRedirectForm } from '../StripeRedirectForm';
25
- // import { PaymentOptionPaypal } from '../PaymentOptionPaypal'
26
- // import { NotFoundSource } from '../NotFoundSource'
27
-
28
22
  import { OText, OIcon, OModal, OButton } from '../shared';
29
23
 
30
24
  import {
31
- PMContainer,
32
- PMItem,
33
- PMCardSelected,
34
- PMCardItemContent
25
+ PMContainer,
26
+ PMItem,
27
+ PMCardSelected,
28
+ PMCardItemContent
35
29
  } from './styles'
36
- import { getIconCard } from '../../utils';
37
- import { WebView } from 'react-native-webview';
38
- import { useTheme } from 'styled-components/native';
39
30
 
40
31
  const stripeOptions: any = ['stripe_direct', 'stripe', 'stripe_connect']
41
- // const stripeRedirectOptions = [
42
- // { name: 'Bancontact', value: 'bancontact' },
43
- // { name: 'Alipay', value: 'alipay' },
44
- // { name: 'Giropay', value: 'giropay' },
45
- // { name: 'iDEAL', value: 'ideal' }
46
- // ]
47
-
32
+ const methodsPay = ['google_pay', 'apple_pay']
33
+ const stripeDirectMethods = ['stripe_direct', ...methodsPay]
48
34
  const webViewPaymentGateway: any = ['paypal', 'square']
49
35
 
50
36
  const PaymentOptionsUI = (props: any) => {
51
- const {
52
- cart,
53
- errorCash,
54
- isLoading,
55
- isDisabled,
56
- paymethodData,
57
- paymethodsList,
58
- setPaymethodData,
59
- onNavigationRedirect,
60
- handlePaymethodClick,
61
- handlePaymethodDataChange,
62
- handlePaymentMethodClickCustom,
63
- isOpenMethod,
64
- setCardData,
65
- handlePlaceOrder
66
- } = props
37
+ const {
38
+ cart,
39
+ errorCash,
40
+ isLoading,
41
+ isDisabled,
42
+ paymethodData,
43
+ paymethodsList,
44
+ setPaymethodData,
45
+ onNavigationRedirect,
46
+ handlePaymethodClick,
47
+ handlePaymethodDataChange,
48
+ isOpenMethod,
49
+ handlePaymentMethodClickCustom,
50
+ handlePlaceOrder,
51
+ merchantId
52
+ } = props
67
53
 
68
- const theme = useTheme();
54
+ const theme = useTheme();
69
55
  const [, t] = useLanguage();
70
- const methodsPay = ['google_pay']
71
- const stripeDirectMethods = ['stripe_direct', ...methodsPay]
56
+ const [, { showToast }] = useToast();
57
+ const { confirmApplePayPayment } = useApplePay()
72
58
 
73
59
  const [addCardOpen, setAddCardOpen] = useState({ stripe: false, stripeConnect: false });
74
- let paymethodSelected = props.paySelected || props.paymethodSelected || isOpenMethod?.paymethod
60
+ const paymethodSelected = props.paySelected || props.paymethodSelected || isOpenMethod?.paymethod
75
61
 
76
- const getPayIcon = (method: string) => {
77
- switch (method) {
78
- case 'cash':
79
- return theme.images.general.cash
80
- case 'card_delivery':
81
- return theme.images.general.carddelivery
82
- case 'paypal':
83
- return theme.images.general.paypal
84
- case 'stripe':
85
- return theme.images.general.stripe
86
- case 'stripe_direct':
87
- return theme.images.general.stripecc
88
- case 'stripe_connect':
89
- return theme.images.general.stripes
90
- case 'stripe_redirect':
91
- return theme.images.general.stripesb
92
- case 'apple_pay':
93
- return theme.images.general.applePayMark
94
- default:
95
- return theme.images.general.creditCard
96
- }
97
- }
62
+ const getPayIcon = (method: string) => {
63
+ switch (method) {
64
+ case 'cash':
65
+ return theme.images.general.cash
66
+ case 'card_delivery':
67
+ return theme.images.general.carddelivery
68
+ case 'paypal':
69
+ return theme.images.general.paypal
70
+ case 'stripe':
71
+ return theme.images.general.stripe
72
+ case 'stripe_direct':
73
+ return theme.images.general.stripecc
74
+ case 'stripe_connect':
75
+ return theme.images.general.stripes
76
+ case 'stripe_redirect':
77
+ return theme.images.general.stripesb
78
+ case 'apple_pay':
79
+ return theme.images.general.applePayMark
80
+ default:
81
+ return theme.images.general.creditCard
82
+ }
83
+ }
98
84
 
99
- const handlePaymentMethodClick = (paymethod: any) => {
100
- const isPopupMethod = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect', 'paypal', 'square'].includes(paymethod?.gateway)
101
- handlePaymethodClick(paymethod, isPopupMethod)
102
- if (webViewPaymentGateway.includes(paymethod?.gateway)) {
103
- handlePaymentMethodClickCustom(paymethod)
104
- }
105
- setCardData(paymethodData)
106
- }
85
+ const handlePaymentMethodClick = (paymethod: any) => {
86
+ if (cart?.balance > 0) {
87
+ const isPopupMethod = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect', 'paypal'].includes(paymethod?.gateway)
88
+ if (webViewPaymentGateway.includes(paymethod?.gateway)) {
89
+ handlePaymentMethodClickCustom(paymethod)
90
+ }
91
+ handlePaymethodClick(paymethod, isPopupMethod)
92
+ return
93
+ }
94
+ showToast(
95
+ ToastType.Error,
96
+ t('CART_BALANCE_ZERO', 'Sorry, the amount to pay is equal to zero and it is not necessary to select a payment method'))
97
+ ;
98
+ }
107
99
 
108
- useEffect(() => {
109
- if (paymethodsList.paymethods.length === 1) {
110
- handlePaymethodClick && handlePaymethodClick(paymethodsList.paymethods[0])
111
- }
112
- }, [paymethodsList.paymethods])
100
+ useEffect(() => {
101
+ if (paymethodsList.paymethods.length === 1) {
102
+ handlePaymethodClick && handlePaymethodClick(paymethodsList.paymethods[0])
103
+ }
104
+ }, [paymethodsList.paymethods])
113
105
 
114
- useEffect(() => {
115
- if (paymethodSelected?.gateway !== 'cash' && errorCash) {
116
- props.setErrorCash(false)
117
- }
118
- }, [paymethodSelected])
106
+ useEffect(() => {
107
+ if (paymethodSelected?.gateway !== 'cash' && errorCash) {
108
+ props.setErrorCash(false)
109
+ }
110
+ }, [paymethodSelected])
119
111
 
120
- useEffect(() => {
121
- if (props.paySelected && props.paySelected?.data) {
122
- setPaymethodData && setPaymethodData(props.paySelected?.data)
123
- }
124
- }, [props.paySelected])
112
+ useEffect(() => {
113
+ if (props.paySelected && props.paySelected?.data) {
114
+ requestAnimationFrame(() => {
115
+ setPaymethodData && setPaymethodData(props.paySelected?.data)
116
+ })
117
+ }
118
+ }, [props.paySelected])
125
119
 
126
- useEffect(() => {
127
- setCardData && setCardData(paymethodData)
128
- if (methodsPay.includes(paymethodSelected?.gateway) && paymethodData?.id && paymethodSelected?.data?.card) {
129
- handlePlaceOrder()
130
- }
131
- }, [paymethodData, paymethodSelected])
120
+ useEffect(() => {
121
+ if (methodsPay.includes(paymethodSelected?.gateway) && paymethodData?.id && paymethodSelected?.data?.card) {
122
+ handlePlaceOrder(confirmApplePayPayment)
123
+ }
124
+ }, [paymethodData, paymethodSelected])
132
125
 
133
- const renderPaymethods = ({ item }: any) => {
126
+ const renderPaymethods = ({ item }: any) => {
134
127
  return (
135
128
  <>
136
129
  {item?.gateway === 'apple_pay' ? (
@@ -173,251 +166,211 @@ const PaymentOptionsUI = (props: any) => {
173
166
  )
174
167
  }
175
168
 
176
- const excludeGateway: any = ['stripe_connect', 'stripe_redirect', 'apple_pay']; //exclude connect & redirect & apple pay
169
+ const excludeIds: any = [32];
177
170
 
178
- return (
179
- <PMContainer>
180
- {paymethodsList.paymethods.length > 0 && (
181
- <FlatList
182
- horizontal
183
- showsHorizontalScrollIndicator={false}
184
- // data={paymethodsList.paymethods.sort((a: any, b: any) => a.id - b.id)}
185
- data={paymethodsList.paymethods.sort((a: any, b: any) => a.id - b.id).filter((p: any) => !excludeGateway.includes(p.gateway))}
186
- renderItem={renderPaymethods}
187
- keyExtractor={(paymethod: any) => paymethod?.id?.toString?.()}
188
- />
189
- )}
190
- {(paymethodsList.loading || isLoading) && (
191
- <Placeholder style={{ marginTop: 10 }} Animation={Fade}>
192
- <View style={{ display: 'flex', flexDirection: 'row' }}>
193
- {[...Array(3)].map((_, i) => (
194
- <PlaceholderLine
195
- key={i}
196
- width={37}
197
- height={80}
198
- noMargin
199
- style={{ borderRadius: 10, marginRight: 10 }}
200
- />
201
- ))}
202
- </View>
203
- </Placeholder>
204
- )}
171
+ return (
172
+ <PMContainer>
173
+ {paymethodsList.paymethods.length > 0 && (
174
+ <FlatList
175
+ horizontal
176
+ showsHorizontalScrollIndicator={false}
177
+ data={paymethodsList.paymethods.sort((a: any, b: any) => a.id - b.id).filter((p: any) => !excludeIds.includes(p.id))}
178
+ renderItem={renderPaymethods}
179
+ keyExtractor={(paymethod: any) => paymethod?.id?.toString?.()}
180
+ />
181
+ )}
205
182
 
206
- {paymethodsList.error && paymethodsList.error.length > 0 && (
207
- <OText size={12} style={{ margin: 0 }}>
208
- {paymethodsList?.error[0]?.message || paymethodsList?.error[0]}
209
- </OText>
210
- )}
183
+ {(paymethodsList.loading || isLoading) && (
184
+ <Placeholder style={{ marginTop: 10 }} Animation={Fade}>
185
+ <View style={{ display: 'flex', flexDirection: 'row' }}>
186
+ {[...Array(3)].map((_, i) => (
187
+ <PlaceholderLine
188
+ key={i}
189
+ width={37}
190
+ height={80}
191
+ noMargin
192
+ style={{ borderRadius: 10, marginRight: 10 }}
193
+ />
194
+ ))}
195
+ </View>
196
+ </Placeholder>
197
+ )}
211
198
 
212
- {!(paymethodsList.loading || isLoading) &&
213
- !paymethodsList.error &&
214
- (!paymethodsList?.paymethods || paymethodsList.paymethods.length === 0) &&
215
- (
216
- <OText size={12} style={{ margin: 0 }}>
217
- {t('NO_PAYMENT_METHODS', 'No payment methods!')}
218
- </OText>
219
- )}
199
+ {paymethodsList.error && paymethodsList.error.length > 0 && (
200
+ <OText size={12} style={{ margin: 0 }}>
201
+ {paymethodsList?.error[0]?.message || paymethodsList?.error[0]}
202
+ </OText>
203
+ )}
220
204
 
221
- {paymethodSelected?.gateway === 'cash' && (
222
- <PaymentOptionCash
223
- orderTotal={cart.total}
224
- defaultValue={paymethodSelected?.data?.cash}
225
- onChangeData={handlePaymethodDataChange}
226
- setErrorCash={props.setErrorCash}
227
- />
228
- )}
205
+ {!(paymethodsList.loading || isLoading) &&
206
+ !paymethodsList.error &&
207
+ (!paymethodsList?.paymethods || paymethodsList.paymethods.length === 0) &&
208
+ (
209
+ <OText size={12} style={{ margin: 0 }}>
210
+ {t('NO_PAYMENT_METHODS', 'No payment methods!')}
211
+ </OText>
212
+ )}
229
213
 
230
- {stripeOptions.includes(paymethodSelected?.gateway) &&
231
- (paymethodData?.brand || paymethodData?.card?.brand) &&
232
- (paymethodData?.last4 || paymethodData?.card?.last4) &&
233
- (
234
- <PMCardSelected>
235
- <PMCardItemContent>
236
- <View style={styles.viewStyle}>
237
- <MaterialCommunityIcons
238
- name='radiobox-marked'
239
- size={24}
240
- color={theme.colors.primary}
241
- />
242
- </View>
243
- <View style={styles.viewStyle}>
244
- <OText>
245
- {getIconCard((paymethodData?.brand || paymethodData?.card?.brand), 26)}
246
- </OText>
247
- </View>
248
- <View style={styles.viewStyle}>
249
- <OText
250
- size={20}
251
- >
252
- XXXX-XXXX-XXXX-{(paymethodData?.last4 || paymethodData?.card?.last4)}
253
- </OText>
254
- </View>
255
- </PMCardItemContent>
256
- </PMCardSelected>
257
- )}
214
+ {paymethodSelected?.gateway === 'cash' && (
215
+ <PaymentOptionCash
216
+ orderTotal={cart.balance ?? cart.total}
217
+ defaultValue={paymethodSelected?.data?.cash}
218
+ onChangeData={handlePaymethodDataChange}
219
+ setErrorCash={props.setErrorCash}
220
+ />
221
+ )}
258
222
 
259
- {/* Stripe */}
260
- {isOpenMethod?.paymethod?.gateway === 'stripe' && !paymethodData?.id && (
261
- <View style={{ width: '100%' }}>
262
- <OButton
263
- text={t('ADD_PAYMENT_CARD', 'Add New Payment Card')}
264
- bgColor={theme.colors.primary}
265
- borderColor={theme.colors.primary}
266
- style={styles.btnAddStyle}
267
- textStyle={{ color: 'white' }}
268
- imgRightSrc={null}
269
- onClick={() => setAddCardOpen({ ...addCardOpen, stripe: true })}
270
- />
271
- <StripeCardsList
272
- paymethod={isOpenMethod?.paymethod}
273
- businessId={props.businessId}
274
- publicKey={isOpenMethod?.paymethod?.credentials.publishable}
275
- payType={paymethodsList?.name}
276
- onSelectCard={handlePaymethodDataChange}
277
- onNavigationRedirect={onNavigationRedirect}
278
- onCancel={() => handlePaymethodClick(null)}
279
- />
280
- </View>
281
- )}
223
+ {stripeOptions.includes(paymethodSelected?.gateway) &&
224
+ (paymethodData?.brand || paymethodData?.card?.brand) &&
225
+ (paymethodData?.last4 || paymethodData?.card?.last4) &&
226
+ (
227
+ <PMCardSelected>
228
+ <PMCardItemContent>
229
+ <View style={styles.viewStyle}>
230
+ <OIcon
231
+ src={theme.images.general.radio_act}
232
+ width={16}
233
+ color={theme.colors.primary}
234
+ />
235
+ </View>
236
+ <View style={styles.viewStyle}>
237
+ <OText>
238
+ {getIconCard((paymethodData?.brand || paymethodData?.card?.brand), 20)}
239
+ </OText>
240
+ </View>
241
+ <View style={styles.viewStyle}>
242
+ <OText
243
+ size={12}
244
+ lineHeight={18}
245
+ color={theme.colors.textNormal}
246
+ >
247
+ XXXX-XXXX-XXXX-{(paymethodData?.last4 || paymethodData?.card?.last4)}
248
+ </OText>
249
+ </View>
250
+ </PMCardItemContent>
251
+ </PMCardSelected>
252
+ )}
282
253
 
283
- <OModal
284
- entireModal
285
- title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
286
- open={addCardOpen.stripe}
287
- onClose={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
288
- >
289
- <KeyboardAvoidingView
290
- behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
291
- keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
292
- enabled={Platform.OS === 'ios' ? true : false}
293
- >
294
- <StripeElementsForm
295
- toSave
296
- businessId={props.businessId}
297
- publicKey={isOpenMethod?.paymethod?.credentials?.publishable}
298
- requirements={props.clientSecret}
299
- onSelectCard={handlePaymethodDataChange}
300
- onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
301
- />
302
- </KeyboardAvoidingView>
303
- </OModal>
254
+ {/* Stripe */}
255
+ {isOpenMethod?.paymethod?.gateway === 'stripe' && !paymethodData?.id && (
256
+ <View>
257
+ <OButton
258
+ text={t('ADD_PAYMENT_CARD', 'Add New Payment Card')}
259
+ bgColor={theme.colors.white}
260
+ borderColor={theme.colors.primary}
261
+ style={styles.btnAddStyle}
262
+ textStyle={{ color: theme.colors.primary, fontSize: 12 }}
263
+ imgRightSrc={null}
264
+ onClick={() => setAddCardOpen({ ...addCardOpen, stripe: true })}
265
+ />
266
+ <StripeCardsList
267
+ paymethod={isOpenMethod?.paymethod}
268
+ businessId={props.businessId}
269
+ publicKey={isOpenMethod?.paymethod?.credentials.publishable}
270
+ payType={paymethodsList?.name}
271
+ onSelectCard={handlePaymethodDataChange}
272
+ onNavigationRedirect={onNavigationRedirect}
273
+ onCancel={() => handlePaymethodClick(null)}
274
+ />
275
+ </View>
276
+ )}
304
277
 
305
- {/* Stripe direct, Google pay, Apple pay */}
306
- <OModal
307
- entireModal
308
- title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
309
- open={stripeDirectMethods?.includes(isOpenMethod?.paymethod?.gateway) && !paymethodData.id}
310
- onClose={() => handlePaymethodClick(null)}
311
- >
312
- <KeyboardAvoidingView
313
- behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
314
- keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
315
- enabled={Platform.OS === 'ios' ? true : false}
316
- >
317
- <StripeElementsForm
318
- cart={cart}
319
- paymethod={isOpenMethod?.paymethod?.gateway}
320
- methodsPay={methodsPay}
321
- businessId={props.businessId}
322
- publicKey={isOpenMethod?.paymethod?.credentials?.publishable || isOpenMethod?.paymethod?.credentials?.publishable_key}
323
- handleSource={handlePaymethodDataChange}
324
- onCancel={() => handlePaymethodClick(null)}
325
- />
326
- </KeyboardAvoidingView>
327
- </OModal>
278
+ <OModal
279
+ entireModal
280
+ title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
281
+ open={addCardOpen.stripe}
282
+ onClose={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
283
+ style={{ backgroundColor: 'red' }}
284
+ >
285
+ <KeyboardAvoidingView
286
+ behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
287
+ keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
288
+ enabled={Platform.OS === 'ios' ? true : false}
289
+ >
290
+ <StripeElementsForm
291
+ toSave
292
+ businessId={props.businessId}
293
+ publicKey={isOpenMethod?.paymethod?.credentials?.publishable}
294
+ requirements={props.clientSecret}
295
+ onSelectCard={handlePaymethodDataChange}
296
+ onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
297
+ />
298
+ </KeyboardAvoidingView>
299
+ </OModal>
328
300
 
329
- {/* Stripe Connect */}
330
- {isOpenMethod?.paymethod?.gateway === 'stripe_connect' && !paymethodData?.id && (
331
- <View>
332
- <OButton
333
- text={t('ADD_PAYMENT_CARD', 'Add New Payment Card')}
334
- bgColor={theme.colors.primary}
335
- borderColor={theme.colors.primary}
336
- style={styles.btnAddStyle}
337
- textStyle={{ color: 'white' }}
338
- imgRightSrc={null}
339
- onClick={() => setAddCardOpen({ ...addCardOpen, stripeConnect: true })}
340
- />
341
- <StripeCardsList
342
- paymethod={isOpenMethod?.paymethod}
343
- businessId={props.businessId}
344
- publicKey={isOpenMethod?.paymethod?.credentials.publishable}
345
- payType={paymethodsList?.name}
346
- onSelectCard={handlePaymethodDataChange}
347
- onNavigationRedirect={onNavigationRedirect}
348
- onCancel={() => handlePaymethodClick(null)}
349
- />
350
- </View>
351
- )}
301
+ {/* Stripe direct, Google pay, Apple pay */}
302
+ <OModal
303
+ entireModal
304
+ title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
305
+ open={stripeDirectMethods?.includes(isOpenMethod?.paymethod?.gateway) && !paymethodData.id}
306
+ onClose={() => handlePaymethodClick(null)}
307
+ >
308
+ <KeyboardAvoidingView
309
+ behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
310
+ keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
311
+ enabled={Platform.OS === 'ios' ? true : false}
312
+ >
313
+ <StripeElementsForm
314
+ cart={cart}
315
+ paymethod={isOpenMethod?.paymethod?.gateway}
316
+ methodsPay={methodsPay}
317
+ businessId={props.businessId}
318
+ publicKey={isOpenMethod?.paymethod?.credentials?.publishable || isOpenMethod?.paymethod?.credentials?.publishable_key}
319
+ handleSource={handlePaymethodDataChange}
320
+ onCancel={() => handlePaymethodClick(null)}
321
+ merchantId={merchantId}
322
+ />
323
+ </KeyboardAvoidingView>
324
+ </OModal>
352
325
 
353
- <OModal
354
- entireModal
355
- title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
356
- open={addCardOpen.stripeConnect}
357
- onClose={() => setAddCardOpen({ ...addCardOpen, stripeConnect: false })}
358
- >
359
- <KeyboardAvoidingView
360
- behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
361
- keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
362
- enabled={Platform.OS === 'ios' ? true : false}
363
- >
364
- <StripeElementsForm
365
- toSave
366
- businessId={props.businessId}
367
- publicKey={isOpenMethod?.paymethod?.credentials?.stripe?.publishable}
368
- requirements={isOpenMethod?.paymethod?.credentials?.publishable}
369
- accountId={isOpenMethod?.paymethod?.credentials?.user}
370
- onSelectCard={handlePaymethodDataChange}
371
- onCancel={() => setAddCardOpen({ ...addCardOpen, stripeConnect: false })}
372
- />
373
- </KeyboardAvoidingView>
374
- </OModal>
326
+ {/* Stripe Connect */}
327
+ {isOpenMethod?.paymethod?.gateway === 'stripe_connect' && !paymethodData?.id && (
328
+ <View>
329
+ <OButton
330
+ text={t('ADD_PAYMENT_CARD', 'Add New Payment Card')}
331
+ bgColor={theme.colors.white}
332
+ borderColor={theme.colors.primary}
333
+ style={styles.btnAddStyle}
334
+ textStyle={{ color: theme.colors.primary, fontSize: 12 }}
335
+ imgRightSrc={null}
336
+ onClick={() => setAddCardOpen({ ...addCardOpen, stripeConnect: true })}
337
+ />
338
+ <StripeCardsList
339
+ paymethod={isOpenMethod?.paymethod}
340
+ businessId={props.businessId}
341
+ publicKey={isOpenMethod?.paymethod?.credentials.publishable}
342
+ payType={paymethodsList?.name}
343
+ onSelectCard={handlePaymethodDataChange}
344
+ onNavigationRedirect={onNavigationRedirect}
345
+ onCancel={() => handlePaymethodClick(null)}
346
+ />
347
+ </View>
348
+ )}
375
349
 
376
- {/* Stripe Redirect */}
377
- {/* <OModal
378
- isNotDecoration
379
- open={['stripe_redirect'].includes(paymethodSelected?.gateway) && !paymethodData.type}
380
- title={t('STRIPE_REDIRECT', 'Stripe Redirect')}
381
- onClose={() => handlePaymethodClick(null)}
382
- >
383
- <StripeRedirectForm
384
- businessId={props.businessId}
385
- currency={props.currency}
386
- // paymethods={flatArray([stripeRedirectValues, stripeRedirectOptions])}
387
- publicKey={paymethodSelected?.credentials?.publishable}
388
- paymethods={stripeRedirectOptions}
389
- handleStripeRedirect={handlePaymethodDataChange}
390
- />
391
- </OModal> */}
392
-
393
- {/* Paypal */}
394
- {/* <Modal
395
- className='modal-info'
396
- open={paymethodSelected?.gateway === 'paypal' && !paymethodData?.id}
397
- onClose={() => handlePaymethodClick(null)}
398
- title={t('PAY_WITH_PAYPAL', 'Pay with PayPal')}
399
- >
400
- {paymethodSelected?.gateway === 'paypal' && (
401
- <PaymentOptionPaypal
402
- clientId={paymethodSelected?.credentials?.client_id}
403
- body={{
404
- paymethod_id: paymethodSelected.id,
405
- amount: cart.total,
406
- delivery_zone_id: cart.delivery_zone_id,
407
- cartUuid: cart.uuid
408
- }}
409
- btnStyle={paypalBtnStyle}
410
- noAuthMessage={
411
- !token
412
- ? t('NEED_LOGIN_TO_USE', 'Sorry, you need to login to use this method')
413
- : null
414
- }
415
- handlerChangePaypal={(uuid) => onNavigationRedirect && onNavigationRedirect('OrderDetails', { orderId: uuid })}
416
- />
417
- )}
418
- </Modal> */}
419
- </PMContainer>
420
- )
350
+ <OModal
351
+ entireModal
352
+ title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
353
+ open={addCardOpen.stripeConnect}
354
+ onClose={() => setAddCardOpen({ ...addCardOpen, stripeConnect: false })}
355
+ >
356
+ <KeyboardAvoidingView
357
+ behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
358
+ keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
359
+ enabled={Platform.OS === 'ios' ? true : false}
360
+ >
361
+ <StripeElementsForm
362
+ toSave
363
+ businessId={props.businessId}
364
+ publicKey={isOpenMethod?.paymethod?.credentials?.stripe?.publishable}
365
+ requirements={isOpenMethod?.paymethod?.credentials?.publishable}
366
+ accountId={isOpenMethod?.paymethod?.credentials?.user}
367
+ onSelectCard={handlePaymethodDataChange}
368
+ onCancel={() => setAddCardOpen({ ...addCardOpen, stripeConnect: false })}
369
+ />
370
+ </KeyboardAvoidingView>
371
+ </OModal>
372
+ </PMContainer>
373
+ )
421
374
  }
422
375
 
423
376
  const styles = StyleSheet.create({
@@ -452,11 +405,11 @@ const styles = StyleSheet.create({
452
405
  })
453
406
 
454
407
  export const PaymentOptions = (props: any) => {
455
- const paymentOptions = {
456
- ...props,
457
- UIComponent: PaymentOptionsUI
458
- }
459
- return (
460
- <PaymentOptionsController {...paymentOptions} />
461
- )
408
+ const paymentOptions = {
409
+ ...props,
410
+ UIComponent: PaymentOptionsUI
411
+ }
412
+ return (
413
+ <PaymentOptionsController {...paymentOptions} />
414
+ )
462
415
  }