ordering-ui-react-native 0.18.0 → 0.18.1-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 (263) hide show
  1. package/package.json +9 -7
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessInformation/index.tsx +10 -9
  4. package/src/components/BusinessesListing/index.tsx +1 -1
  5. package/src/components/OrderCreating/index.tsx +0 -20
  6. package/src/components/PaymentOptionsWebView/index.tsx +29 -8
  7. package/src/components/PhoneInputNumber/index.tsx +6 -2
  8. package/src/components/StripeMethodForm/index.tsx +136 -102
  9. package/src/components/VerifyPhone/styles.tsx +1 -2
  10. package/src/components/shared/OToast.tsx +3 -2
  11. package/src/types/index.tsx +5 -0
  12. package/src/utils/index.tsx +7 -2
  13. package/themes/business/index.tsx +4 -0
  14. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +36 -26
  15. package/themes/business/src/components/BusinessController/index.tsx +19 -17
  16. package/themes/business/src/components/BusinessProductList/AccordionDropdown.tsx +63 -0
  17. package/themes/business/src/components/BusinessProductList/IterateCategories.tsx +108 -0
  18. package/themes/business/src/components/BusinessProductList/ProductList.tsx +196 -0
  19. package/themes/business/src/components/BusinessProductList/index.tsx +196 -0
  20. package/themes/business/src/components/BusinessProductList/styles.tsx +10 -0
  21. package/themes/business/src/components/Chat/index.tsx +163 -123
  22. package/themes/business/src/components/DriverMap/index.tsx +17 -6
  23. package/themes/business/src/components/DriverSchedule/index.tsx +45 -8
  24. package/themes/business/src/components/FloatingButton/index.tsx +34 -31
  25. package/themes/business/src/components/GoogleMap/index.tsx +58 -57
  26. package/themes/business/src/components/LoginForm/index.tsx +5 -2
  27. package/themes/business/src/components/MapView/index.tsx +14 -10
  28. package/themes/business/src/components/MessagesOption/index.tsx +22 -94
  29. package/themes/business/src/components/NewOrderNotification/index.tsx +123 -96
  30. package/themes/business/src/components/NotFoundSource/index.tsx +2 -2
  31. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  32. package/themes/business/src/components/OrderDetails/Delivery.tsx +205 -12
  33. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +91 -43
  34. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +87 -66
  35. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +200 -0
  36. package/themes/business/src/components/OrderDetailsLogistic/styles.tsx +5 -0
  37. package/themes/business/src/components/OrderMessage/index.tsx +19 -18
  38. package/themes/business/src/components/OrderSummary/index.tsx +114 -123
  39. package/themes/business/src/components/OrdersListManager/index.tsx +7 -2
  40. package/themes/business/src/components/OrdersListManager/utils.tsx +1 -1
  41. package/themes/business/src/components/OrdersOption/index.tsx +60 -47
  42. package/themes/business/src/components/PreviousMessages/FooterMessageComponent.tsx +103 -0
  43. package/themes/business/src/components/PreviousMessages/index.tsx +97 -55
  44. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +21 -29
  45. package/themes/business/src/components/PreviousOrders/OrderList.tsx +93 -0
  46. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +1 -1
  47. package/themes/business/src/components/PreviousOrders/index.tsx +198 -221
  48. package/themes/business/src/components/PreviousOrders/styles.tsx +10 -0
  49. package/themes/business/src/components/ProductItemAccordion/index.tsx +7 -1
  50. package/themes/business/src/components/ReviewCustomer/index.tsx +18 -13
  51. package/themes/business/src/components/SearchBar/index.tsx +2 -1
  52. package/themes/business/src/components/StoresList/index.tsx +6 -5
  53. package/themes/business/src/components/UserProfileForm/index.tsx +14 -15
  54. package/themes/business/src/components/WebsocketStatus/index.tsx +171 -0
  55. package/themes/business/src/components/WebsocketStatus/styles.tsx +28 -0
  56. package/themes/business/src/components/shared/OModal.tsx +16 -9
  57. package/themes/business/src/types/index.tsx +25 -10
  58. package/themes/business/src/utils/index.tsx +29 -2
  59. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  60. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  61. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  62. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  63. package/themes/kiosk/src/components/Intro/index.tsx +16 -1
  64. package/themes/kiosk/src/components/LoginForm/index.tsx +7 -5
  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/PhoneInputNumber/index.tsx +2 -2
  69. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  70. package/themes/original/index.tsx +7 -3
  71. package/themes/original/src/components/AddressDetails/index.tsx +19 -3
  72. package/themes/original/src/components/AddressForm/index.tsx +33 -15
  73. package/themes/original/src/components/AddressForm/styles.tsx +1 -1
  74. package/themes/original/src/components/AddressList/index.tsx +5 -8
  75. package/themes/original/src/components/AddressList/styles.tsx +4 -4
  76. package/themes/original/src/components/AnalyticsSegment/index.tsx +193 -10
  77. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  78. package/themes/original/src/components/AppleLogin/styles.tsx +3 -1
  79. package/themes/original/src/components/BusinessBasicInformation/index.tsx +74 -38
  80. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +11 -13
  81. package/themes/original/src/components/BusinessController/index.tsx +35 -44
  82. package/themes/original/src/components/BusinessController/styles.tsx +12 -5
  83. package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
  84. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
  85. package/themes/original/src/components/BusinessInformation/index.tsx +140 -85
  86. package/themes/original/src/components/BusinessInformation/styles.tsx +2 -2
  87. package/themes/original/src/components/BusinessItemAccordion/index.tsx +25 -26
  88. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +1 -1
  89. package/themes/original/src/components/BusinessListingSearch/index.tsx +346 -341
  90. package/themes/original/src/components/BusinessListingSearch/styles.tsx +1 -19
  91. package/themes/original/src/components/BusinessPreorder/index.tsx +105 -22
  92. package/themes/original/src/components/BusinessPreorder/styles.tsx +14 -0
  93. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -3
  94. package/themes/original/src/components/BusinessProductsList/index.tsx +15 -7
  95. package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
  96. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +1 -1
  97. package/themes/original/src/components/BusinessProductsListing/index.tsx +162 -39
  98. package/themes/original/src/components/BusinessProductsListing/styles.tsx +4 -5
  99. package/themes/original/src/components/BusinessReviews/index.tsx +4 -2
  100. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  101. package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +5 -5
  102. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +69 -0
  103. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +406 -0
  104. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListing.tsx +76 -0
  105. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +37 -404
  106. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  107. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  108. package/themes/original/src/components/Cart/index.tsx +49 -47
  109. package/themes/original/src/components/CartContent/index.tsx +99 -38
  110. package/themes/original/src/components/CartContent/styles.tsx +6 -6
  111. package/themes/original/src/components/CartStoresListing/styles.tsx +2 -2
  112. package/themes/original/src/components/Checkout/index.tsx +324 -43
  113. package/themes/original/src/components/Checkout/styles.tsx +17 -0
  114. package/themes/original/src/components/CitiesControl/index.tsx +1 -1
  115. package/themes/original/src/components/CitiesControl/styles.tsx +1 -1
  116. package/themes/original/src/components/CouponControl/index.tsx +10 -3
  117. package/themes/original/src/components/DatePicker/index.tsx +17 -0
  118. package/themes/original/src/components/DatePicker/styles.tsx +20 -0
  119. package/themes/original/src/components/DriverTips/index.tsx +12 -4
  120. package/themes/original/src/components/FacebookLogin/styles.tsx +3 -1
  121. package/themes/original/src/components/Favorite/index.tsx +4 -9
  122. package/themes/original/src/components/Favorite/styles.tsx +0 -2
  123. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  124. package/themes/original/src/components/GPSButton/index.tsx +7 -5
  125. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +8 -3
  126. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +42 -5
  127. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +3 -1
  128. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +84 -8
  129. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +1 -1
  130. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +1 -1
  131. package/themes/original/src/components/GoogleLogin/styles.tsx +1 -1
  132. package/themes/original/src/components/GoogleMap/index.tsx +63 -7
  133. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
  134. package/themes/original/src/components/HighestRatedBusinesses/styles.tsx +1 -1
  135. package/themes/original/src/components/Home/index.tsx +14 -5
  136. package/themes/original/src/components/LastOrder/index.tsx +2 -1
  137. package/themes/original/src/components/LastOrders/index.tsx +2 -1
  138. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -25
  139. package/themes/original/src/components/LoginForm/index.tsx +64 -34
  140. package/themes/original/src/components/LottieAnimation/index.tsx +88 -63
  141. package/themes/original/src/components/MessageListing/index.tsx +9 -2
  142. package/themes/original/src/components/Messages/index.tsx +15 -4
  143. package/themes/original/src/components/Messages/styles.tsx +1 -1
  144. package/themes/original/src/components/MomentOption/index.tsx +43 -38
  145. package/themes/original/src/components/MomentSelector/index.tsx +1 -1
  146. package/themes/original/src/components/MultiCart/index.tsx +1 -1
  147. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +161 -49
  148. package/themes/original/src/components/MultiCheckout/index.tsx +348 -70
  149. package/themes/original/src/components/MultiCheckout/styles.tsx +3 -1
  150. package/themes/original/src/components/MultiOrdersDetails/index.tsx +2 -2
  151. package/themes/original/src/components/MyOrders/index.tsx +16 -5
  152. package/themes/original/src/components/NavBar/index.tsx +20 -13
  153. package/themes/original/src/components/NetworkError/styles.tsx +2 -2
  154. package/themes/original/src/components/NotFoundSource/index.tsx +14 -10
  155. package/themes/original/src/components/Notifications/index.tsx +2 -4
  156. package/themes/original/src/components/Notifications/styles.tsx +0 -1
  157. package/themes/original/src/components/OrderDetails/OrderEta.tsx +76 -0
  158. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +22 -6
  159. package/themes/original/src/components/OrderDetails/index.tsx +721 -670
  160. package/themes/original/src/components/OrderDetails/styles.tsx +24 -8
  161. package/themes/original/src/components/OrderItAgain/index.tsx +3 -1
  162. package/themes/original/src/components/OrderProgress/index.tsx +34 -25
  163. package/themes/original/src/components/OrderProgress/styles.tsx +1 -1
  164. package/themes/original/src/components/OrderSummary/index.tsx +62 -57
  165. package/themes/original/src/components/OrderTypeSelector/index.tsx +5 -6
  166. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +1 -1
  167. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +13 -13
  168. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +1 -1
  169. package/themes/original/src/components/OrdersOption/index.tsx +44 -21
  170. package/themes/original/src/components/OrdersOption/styles.tsx +2 -2
  171. package/themes/original/src/components/PageBanner/index.tsx +65 -29
  172. package/themes/original/src/components/PageBanner/styles.tsx +0 -3
  173. package/themes/original/src/components/PaymentOptionCard/index.tsx +180 -0
  174. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +3 -0
  175. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  176. package/themes/original/src/components/PaymentOptions/index.tsx +100 -34
  177. package/themes/original/src/components/PhoneInputNumber/index.tsx +18 -4
  178. package/themes/original/src/components/ProductForm/ActionButton.tsx +120 -0
  179. package/themes/original/src/components/ProductForm/ExtraOptions.tsx +56 -0
  180. package/themes/original/src/components/ProductForm/index.tsx +106 -170
  181. package/themes/original/src/components/ProductForm/styles.tsx +3 -3
  182. package/themes/original/src/components/ProductItemAccordion/index.tsx +13 -6
  183. package/themes/original/src/components/ProductOptionSubOption/index.tsx +49 -20
  184. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +10 -9
  185. package/themes/original/src/components/ProfessionalProfile/index.tsx +35 -6
  186. package/themes/original/src/components/ProfessionalProfile/styles.tsx +3 -3
  187. package/themes/original/src/components/Promotions/index.tsx +6 -6
  188. package/themes/original/src/components/Promotions/styles.tsx +3 -3
  189. package/themes/original/src/components/ReviewDriver/styles.tsx +1 -1
  190. package/themes/original/src/components/ReviewOrder/styles.tsx +1 -1
  191. package/themes/original/src/components/ReviewProducts/index.tsx +16 -7
  192. package/themes/original/src/components/ReviewProducts/styles.tsx +1 -1
  193. package/themes/original/src/components/ScheduleAccordion/index.tsx +3 -3
  194. package/themes/original/src/components/ServiceForm/index.tsx +36 -24
  195. package/themes/original/src/components/ServiceForm/styles.tsx +4 -4
  196. package/themes/original/src/components/SignupForm/index.tsx +27 -16
  197. package/themes/original/src/components/SingleOrderCard/index.tsx +44 -20
  198. package/themes/original/src/components/SingleOrderCard/styles.tsx +1 -1
  199. package/themes/original/src/components/SingleProductCard/index.tsx +13 -10
  200. package/themes/original/src/components/SingleProductCard/styles.tsx +8 -3
  201. package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
  202. package/themes/original/src/components/StripeCardsList/index.tsx +61 -5
  203. package/themes/original/src/components/StripeElementsForm/index.tsx +48 -34
  204. package/themes/original/src/components/StripeElementsForm/naked.tsx +12 -1
  205. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +170 -0
  206. package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +86 -0
  207. package/themes/original/src/components/UpsellingProducts/index.tsx +16 -205
  208. package/themes/original/src/components/UpsellingProducts/styles.tsx +19 -0
  209. package/themes/original/src/components/UserDetails/index.tsx +3 -1
  210. package/themes/original/src/components/UserFormDetails/index.tsx +100 -22
  211. package/themes/original/src/components/UserFormDetails/styles.tsx +1 -1
  212. package/themes/original/src/components/UserProfile/index.tsx +8 -26
  213. package/themes/original/src/components/UserProfileForm/index.tsx +30 -31
  214. package/themes/original/src/components/UserVerification/index.tsx +55 -50
  215. package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
  216. package/themes/original/src/components/WalletTransactions/index.tsx +3 -3
  217. package/themes/original/src/components/WalletTransactions/styles.tsx +1 -0
  218. package/themes/original/src/components/Wallets/index.tsx +48 -60
  219. package/themes/original/src/components/Wallets/styles.tsx +3 -4
  220. package/themes/original/src/components/shared/HeaderTitle.tsx +1 -1
  221. package/themes/original/src/components/shared/OButton.tsx +3 -3
  222. package/themes/original/src/components/shared/OInput.tsx +4 -5
  223. package/themes/original/src/components/shared/OModal.tsx +15 -17
  224. package/themes/original/src/layouts/Container.tsx +1 -1
  225. package/themes/original/src/types/index.tsx +28 -6
  226. package/themes/original/src/utils/index.tsx +180 -13
  227. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  228. package/src/navigators/BottomNavigator.tsx +0 -117
  229. package/src/navigators/CheckoutNavigator.tsx +0 -66
  230. package/src/navigators/HomeNavigator.tsx +0 -202
  231. package/src/navigators/NavigationRef.tsx +0 -7
  232. package/src/navigators/RootNavigator.tsx +0 -269
  233. package/src/pages/Account.tsx +0 -34
  234. package/src/pages/AddressForm.tsx +0 -62
  235. package/src/pages/AddressList.tsx +0 -24
  236. package/src/pages/BusinessProductsList.tsx +0 -81
  237. package/src/pages/BusinessesListing.tsx +0 -43
  238. package/src/pages/CartList.tsx +0 -49
  239. package/src/pages/Checkout.tsx +0 -101
  240. package/src/pages/ForgotPassword.tsx +0 -24
  241. package/src/pages/Help.tsx +0 -23
  242. package/src/pages/HelpAccountAndPayment.tsx +0 -23
  243. package/src/pages/HelpGuide.tsx +0 -23
  244. package/src/pages/HelpOrder.tsx +0 -23
  245. package/src/pages/Home.tsx +0 -36
  246. package/src/pages/IntroductoryTutorial.tsx +0 -170
  247. package/src/pages/Login.tsx +0 -47
  248. package/src/pages/MomentOption.tsx +0 -30
  249. package/src/pages/MultiCheckout.tsx +0 -31
  250. package/src/pages/MultiOrdersDetails.tsx +0 -27
  251. package/src/pages/MyOrders.tsx +0 -40
  252. package/src/pages/NetworkError.tsx +0 -24
  253. package/src/pages/NotFound.tsx +0 -22
  254. package/src/pages/OrderDetails.tsx +0 -25
  255. package/src/pages/ProductDetails.tsx +0 -55
  256. package/src/pages/Profile.tsx +0 -36
  257. package/src/pages/ReviewDriver.tsx +0 -30
  258. package/src/pages/ReviewOrder.tsx +0 -32
  259. package/src/pages/ReviewProducts.tsx +0 -30
  260. package/src/pages/Sessions.tsx +0 -22
  261. package/src/pages/Signup.tsx +0 -53
  262. package/src/pages/SpinnerLoader.tsx +0 -10
  263. package/src/pages/Splash.tsx +0 -21
@@ -1,8 +1,10 @@
1
- import React, { useState } from 'react'
1
+ import React, { useEffect, useState } from 'react'
2
2
  import {
3
3
  useLanguage,
4
4
  useConfig,
5
5
  useUtils,
6
+ useToast,
7
+ ToastType,
6
8
  MultiCartsPaymethodsAndWallets as MultiCartsPaymethodsAndWalletsController
7
9
  } from 'ordering-components/native'
8
10
  import { useTheme } from 'styled-components/native'
@@ -13,6 +15,7 @@ import { getIconCard, flatArray } from '../../utils'
13
15
  import { StripeElementsForm } from '../StripeElementsForm'
14
16
  import { StripeCardsList } from '../StripeCardsList'
15
17
  import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
18
+ import { useApplePay } from '@stripe/stripe-react-native';
16
19
 
17
20
  import {
18
21
  PMContainer,
@@ -25,16 +28,27 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
25
28
  businessIds,
26
29
  paymethodsAndWallets,
27
30
  walletsState,
31
+ walletsPaymethod,
28
32
  paymethodSelected,
29
33
  handleSelectPaymethod,
30
34
  handleSelectWallet,
31
- handlePaymethodDataChange
35
+ handlePaymethodDataChange,
36
+ setMethodPaySupported,
37
+ placeByMethodPay,
38
+ methodPaySupported,
39
+ setPlaceByMethodPay,
40
+ openCarts,
41
+ cartTotal,
42
+ handlePlaceOrder,
43
+ merchantId
32
44
  } = props
33
45
 
34
46
  const theme = useTheme()
35
47
  const [, t] = useLanguage()
36
48
  const [{ configs }] = useConfig()
37
49
  const [{ parsePrice }] = useUtils()
50
+ const [, { showToast }] = useToast();
51
+ const { confirmApplePayPayment } = useApplePay()
38
52
 
39
53
  const [addCardOpen, setAddCardOpen] = useState({ stripe: false, stripeConnect: false });
40
54
 
@@ -52,6 +66,10 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
52
66
  }
53
67
  }
54
68
 
69
+ const creditBalance: any = (wallet: any) => ` = ${parsePrice(wallet.balance / wallet.redemption_rate, { isTruncable: true })}`
70
+ const filterMethodsPay = (gateway: string) => Platform.OS === 'ios' ? gateway !== 'global_google_pay' : gateway !== 'global_apple_pay'
71
+ const methodsPay = ['global_google_pay', 'global_apple_pay']
72
+
55
73
  const getPayIcon = (method: string) => {
56
74
  switch (method) {
57
75
  case 'cash':
@@ -68,35 +86,81 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
68
86
  return theme.images.general.stripes
69
87
  case 'stripe_redirect':
70
88
  return theme.images.general.stripesb
89
+ case 'global_apple_pay':
90
+ return theme.images.general.applePayMark
91
+ case 'global_google_pay':
92
+ return theme.images.general.googlePayMark
71
93
  default:
72
94
  return theme.images.general.creditCard
73
95
  }
74
96
  }
75
97
 
98
+ useEffect(() => {
99
+ if (methodsPay.includes(paymethodSelected?.gateway)) {
100
+ if (typeof paymethodSelected?.paymethod_data === 'string') {
101
+ const sourceId = JSON.parse(paymethodSelected?.paymethod_data)?.source_id
102
+ sourceId && handlePlaceOrder(confirmApplePayPayment)
103
+ }
104
+ }
105
+ }, [JSON.stringify(paymethodSelected)])
106
+
107
+ useEffect(() => {
108
+ if (cartTotal === 0) {
109
+ handlePaymethodDataChange(null)
110
+ handleSelectPaymethod(null)
111
+ }
112
+ }, [cartTotal])
113
+
114
+ const handleChangePaymethod = (paymethod: any) => {
115
+ if (cartTotal > 0) {
116
+ handleSelectPaymethod(paymethod)
117
+ return
118
+ }
119
+ showToast(
120
+ ToastType.Error,
121
+ t('CART_BALANCE_ZERO', 'Sorry, the amount to pay is equal to zero and it is not necessary to select a payment method'))
122
+ ;
123
+ }
124
+
76
125
  const renderPaymethods = ({ item }: any) => {
77
126
  return (
78
- <TouchableOpacity
79
- onPress={() => handleSelectPaymethod({ ...item, paymethod: { gateway: item.gateway }, paymethod_id: item?.id })}
80
- >
81
- <PMItem
82
- key={item.id}
83
- isActive={paymethodSelected?.id === item.id}
84
- >
85
- <OIcon
86
- src={getPayIcon(item?.gateway ?? item.paymethod?.gateway)}
87
- width={20}
88
- height={20}
89
- color={paymethodSelected?.id === item.id ? theme.colors.white : theme.colors.backgroundDark}
90
- />
91
- <OText
92
- size={10}
93
- style={{ margin: 0, marginTop: 4 }}
94
- color={paymethodSelected?.id === item.id ? theme.colors.white : '#000'}
127
+ <>
128
+ {methodsPay.includes(item?.gateway) ? (
129
+ <TouchableOpacity
130
+ onPress={() => handleChangePaymethod({ ...item, paymethod: { gateway: item.gateway }, paymethod_id: item?.id })}
95
131
  >
96
- {t(item?.gateway.toUpperCase(), item?.name)}
97
- </OText>
98
- </PMItem>
99
- </TouchableOpacity>
132
+ <OIcon
133
+ src={getPayIcon(item.gateway)}
134
+ width={70}
135
+ height={70}
136
+ style={{ marginRight: 10 }}
137
+ />
138
+ </TouchableOpacity>
139
+ ) : (
140
+ <TouchableOpacity
141
+ onPress={() => handleChangePaymethod({ ...item, paymethod: { gateway: item.gateway }, paymethod_id: item?.id })}
142
+ >
143
+ <PMItem
144
+ key={item.id}
145
+ isActive={paymethodSelected?.id === item.id}
146
+ >
147
+ <OIcon
148
+ src={getPayIcon(item?.gateway ?? item.paymethod?.gateway)}
149
+ width={20}
150
+ height={20}
151
+ color={item?.gateway === 'global_apple_pay' ? '' : paymethodSelected?.id === item.id ? theme.colors.white : theme.colors.backgroundDark}
152
+ />
153
+ <OText
154
+ size={10}
155
+ style={{ margin: 0, marginTop: 4 }}
156
+ color={paymethodSelected?.id === item.id ? theme.colors.white : '#000'}
157
+ >
158
+ {t(item?.gateway.toUpperCase(), item?.name)}
159
+ </OText>
160
+ </PMItem>
161
+ </TouchableOpacity>
162
+ )}
163
+ </>
100
164
  )
101
165
  }
102
166
 
@@ -123,7 +187,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
123
187
  <FlatList
124
188
  horizontal
125
189
  showsHorizontalScrollIndicator={false}
126
- data={paymethodsAndWallets.paymethods}
190
+ data={paymethodsAndWallets.paymethods.filter((p: any) => filterMethodsPay(p.gateway))}
127
191
  renderItem={renderPaymethods}
128
192
  keyExtractor={(paymethod: any) => paymethod?.id?.toString?.()}
129
193
  />
@@ -152,10 +216,38 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
152
216
  publicKey={paymethodSelected?.data?.publishable}
153
217
  payType={paymethodSelected?.paymethod?.name}
154
218
  onSelectCard={handlePaymethodDataChange}
219
+ addCardOpen={addCardOpen}
220
+ setAddCardOpen={setAddCardOpen}
221
+ openCarts={openCarts}
222
+ toSave
223
+ handlePaymethodDataChange={handlePaymethodDataChange}
224
+ clientSecret={props.clientSecret}
225
+ onPaymentChange={handlePaymethodDataChange}
155
226
  />
156
227
  </View>
157
228
  )}
158
229
 
230
+ {/* Google pay, Apple pay */}
231
+ {methodsPay.includes(paymethodSelected?.paymethod?.gateway) && (
232
+ <StripeElementsForm
233
+ toSave
234
+ businessId={businessIds[0]}
235
+ businessIds={businessIds}
236
+ publicKey={paymethodSelected?.data?.publishable}
237
+ requirements={props.clientSecret}
238
+ handleSource={handlePaymethodDataChange}
239
+ onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
240
+ setMethodPaySupported={setMethodPaySupported}
241
+ methodPaySupported={methodPaySupported}
242
+ placeByMethodPay={placeByMethodPay}
243
+ setPlaceByMethodPay={setPlaceByMethodPay}
244
+ methodsPay={methodsPay}
245
+ paymethod={paymethodSelected?.paymethod?.gateway}
246
+ cartTotal={cartTotal}
247
+ merchantId={merchantId}
248
+ />
249
+ )}
250
+
159
251
  {(paymethodsAndWallets.loading || walletsState.loading) ? (
160
252
  <>
161
253
  {[...Array(2).keys()].map(i => (
@@ -169,33 +261,52 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
169
261
  </>
170
262
  ) : (
171
263
  <>
172
- {walletsState?.result?.filter((wallet: any) => paymethodsAndWallets.wallets.find((item: any) => item.type === wallet.type)).map((wallet: any, idx: any) => walletName[wallet.type]?.isActive && (
173
- <WalletItem
174
- key={wallet.type}
175
- isBottomBorder={idx === paymethodsAndWallets.wallets?.length - 1}
176
- onPress={() => handleSelectWallet(paymethodSelected.wallet_id === wallet.id ? false : true, wallet)}
177
- >
178
- {paymethodSelected.wallet_id === wallet.id ? (
179
- <MaterialCommunityIcons
180
- name="checkbox-marked"
181
- size={25}
182
- color={theme.colors.primary}
183
- />
184
- ) : (
185
- <MaterialCommunityIcons
186
- name="checkbox-blank-outline"
187
- size={25}
188
- color={theme.colors.disabled}
189
- />
190
- )}
191
- <OText size={12} style={{ flex: 1, marginLeft: 15 }}>{walletName[wallet.type]?.name}</OText>
192
- <OText size={12}>{parsePrice(wallet.balance)}</OText>
193
- </WalletItem>
194
- ))}
264
+ {walletsState?.result?.filter((wallet: any) =>
265
+ paymethodsAndWallets.wallets.find((item: any) => item.type === wallet.type))
266
+ .map((wallet: any, idx: any) => walletName[wallet.type]?.isActive &&
267
+ (
268
+ <WalletItem
269
+ key={wallet.type}
270
+ isBottomBorder={idx === paymethodsAndWallets.wallets?.length - 1}
271
+ onPress={() => handleSelectWallet(!!!walletsPaymethod?.find((walletPay: any) => walletPay.wallet_id === wallet.id)?.id, wallet)}
272
+ >
273
+ {!!walletsPaymethod?.find((walletPay: any) => walletPay.wallet_id === wallet.id)?.id ? (
274
+ <MaterialCommunityIcons
275
+ name="checkbox-marked"
276
+ size={25}
277
+ color={theme.colors.primary}
278
+ />
279
+ ) : (
280
+ <MaterialCommunityIcons
281
+ name="checkbox-blank-outline"
282
+ size={25}
283
+ color={theme.colors.disabled}
284
+ />
285
+ )}
286
+ <OText size={12} style={{ flex: 1, marginLeft: 15 }}>{walletName[wallet.type]?.name}</OText>
287
+ {wallet.type === 'cash' && (
288
+ <OText>
289
+ {parsePrice(wallet?.balance, { isTruncable: true })}
290
+ </OText>
291
+ )}
292
+ {wallet.type === 'credit_point' && (
293
+ <OText>
294
+ <OText color={theme.colors.primary} weight='bold'>
295
+ {`${wallet?.balance} ${t('POINTS', 'Points')}`}
296
+ </OText>
297
+ <OText>
298
+ {wallet?.balance > 0
299
+ ? creditBalance(wallet)
300
+ : null}
301
+ </OText>
302
+ </OText>
303
+ )}
304
+ </WalletItem>
305
+ ))}
195
306
  </>
196
307
  )}
197
308
 
198
- <OModal
309
+ {/* <OModal
199
310
  entireModal
200
311
  title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
201
312
  open={addCardOpen.stripe}
@@ -208,6 +319,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
208
319
  enabled={Platform.OS === 'ios' ? true : false}
209
320
  >
210
321
  <StripeElementsForm
322
+ openCarts={openCarts}
211
323
  toSave
212
324
  businessId={businessIds[0]}
213
325
  businessIds={businessIds}
@@ -217,7 +329,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
217
329
  onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
218
330
  />
219
331
  </KeyboardAvoidingView>
220
- </OModal>
332
+ </OModal> */}
221
333
  </PMContainer>
222
334
  )
223
335
  }