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