ordering-ui-react-native 0.17.89 → 0.17.90-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 (216) hide show
  1. package/package.json +8 -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 +1 -21
  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 +5 -0
  13. package/themes/business/index.tsx +2 -0
  14. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +37 -27
  15. package/themes/business/src/components/BusinessController/index.tsx +0 -1
  16. package/themes/business/src/components/Chat/index.tsx +163 -123
  17. package/themes/business/src/components/DriverMap/index.tsx +17 -6
  18. package/themes/business/src/components/DriverSchedule/index.tsx +45 -8
  19. package/themes/business/src/components/FloatingButton/index.tsx +34 -31
  20. package/themes/business/src/components/GoogleMap/index.tsx +58 -57
  21. package/themes/business/src/components/LoginForm/Otp/index.tsx +31 -3
  22. package/themes/business/src/components/LoginForm/index.tsx +15 -22
  23. package/themes/business/src/components/MapView/index.tsx +14 -10
  24. package/themes/business/src/components/MessagesOption/index.tsx +20 -93
  25. package/themes/business/src/components/NewOrderNotification/index.tsx +123 -96
  26. package/themes/business/src/components/NotFoundSource/index.tsx +2 -2
  27. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  28. package/themes/business/src/components/OrderDetails/Delivery.tsx +202 -12
  29. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +84 -37
  30. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +81 -66
  31. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +200 -0
  32. package/themes/business/src/components/OrderDetailsLogistic/styles.tsx +5 -0
  33. package/themes/business/src/components/OrderMessage/index.tsx +19 -18
  34. package/themes/business/src/components/OrderSummary/index.tsx +114 -123
  35. package/themes/business/src/components/OrdersOption/index.tsx +22 -22
  36. package/themes/business/src/components/PreviousMessages/FooterMessageComponent.tsx +103 -0
  37. package/themes/business/src/components/PreviousMessages/index.tsx +97 -55
  38. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +17 -12
  39. package/themes/business/src/components/PreviousOrders/OrderList.tsx +93 -0
  40. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +1 -1
  41. package/themes/business/src/components/PreviousOrders/index.tsx +198 -221
  42. package/themes/business/src/components/ProductItemAccordion/index.tsx +7 -1
  43. package/themes/business/src/components/ReviewCustomer/index.tsx +18 -13
  44. package/themes/business/src/components/StoresList/index.tsx +3 -4
  45. package/themes/business/src/components/UserProfileForm/index.tsx +14 -15
  46. package/themes/business/src/components/shared/OModal.tsx +16 -9
  47. package/themes/business/src/types/index.tsx +25 -10
  48. package/themes/business/src/utils/index.tsx +29 -2
  49. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  50. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  51. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  52. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  53. package/themes/kiosk/src/components/Intro/index.tsx +16 -1
  54. package/themes/kiosk/src/components/LoginForm/index.tsx +7 -9
  55. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  56. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  57. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  58. package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +2 -2
  59. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  60. package/themes/original/index.tsx +1 -1
  61. package/themes/original/src/components/AddressDetails/index.tsx +19 -3
  62. package/themes/original/src/components/AddressForm/index.tsx +35 -17
  63. package/themes/original/src/components/AddressList/index.tsx +5 -8
  64. package/themes/original/src/components/AnalyticsSegment/index.tsx +193 -10
  65. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  66. package/themes/original/src/components/AppleLogin/styles.tsx +3 -1
  67. package/themes/original/src/components/BusinessBasicInformation/index.tsx +73 -37
  68. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +10 -12
  69. package/themes/original/src/components/BusinessController/index.tsx +35 -44
  70. package/themes/original/src/components/BusinessController/styles.tsx +12 -5
  71. package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
  72. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
  73. package/themes/original/src/components/BusinessInformation/index.tsx +140 -85
  74. package/themes/original/src/components/BusinessItemAccordion/index.tsx +15 -20
  75. package/themes/original/src/components/BusinessListingSearch/index.tsx +347 -336
  76. package/themes/original/src/components/BusinessListingSearch/styles.tsx +0 -18
  77. package/themes/original/src/components/BusinessPreorder/index.tsx +103 -19
  78. package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -2
  79. package/themes/original/src/components/BusinessProductsList/index.tsx +15 -7
  80. package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
  81. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +1 -1
  82. package/themes/original/src/components/BusinessProductsListing/index.tsx +663 -556
  83. package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -3
  84. package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
  85. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +69 -0
  86. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +406 -0
  87. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListing.tsx +76 -0
  88. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +38 -405
  89. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  90. package/themes/original/src/components/Cart/index.tsx +60 -51
  91. package/themes/original/src/components/CartContent/index.tsx +102 -58
  92. package/themes/original/src/components/CartContent/styles.tsx +6 -6
  93. package/themes/original/src/components/Checkout/index.tsx +280 -35
  94. package/themes/original/src/components/CitiesControl/index.tsx +1 -1
  95. package/themes/original/src/components/CouponControl/index.tsx +10 -3
  96. package/themes/original/src/components/DriverTips/index.tsx +52 -34
  97. package/themes/original/src/components/FacebookLogin/styles.tsx +3 -1
  98. package/themes/original/src/components/Favorite/index.tsx +1 -5
  99. package/themes/original/src/components/GPSButton/index.tsx +6 -4
  100. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +8 -3
  101. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +42 -5
  102. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +2 -0
  103. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +86 -10
  104. package/themes/original/src/components/GoogleLogin/styles.tsx +1 -1
  105. package/themes/original/src/components/GoogleMap/index.tsx +63 -7
  106. package/themes/original/src/components/Home/index.tsx +13 -4
  107. package/themes/original/src/components/LastOrder/index.tsx +2 -1
  108. package/themes/original/src/components/LastOrders/index.tsx +2 -1
  109. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -25
  110. package/themes/original/src/components/LoginForm/index.tsx +64 -34
  111. package/themes/original/src/components/LottieAnimation/index.tsx +88 -63
  112. package/themes/original/src/components/MessageListing/index.tsx +9 -2
  113. package/themes/original/src/components/Messages/index.tsx +15 -4
  114. package/themes/original/src/components/MomentOption/index.tsx +193 -92
  115. package/themes/original/src/components/MomentSelector/index.tsx +1 -1
  116. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +162 -50
  117. package/themes/original/src/components/MultiCheckout/index.tsx +385 -46
  118. package/themes/original/src/components/MultiCheckout/styles.tsx +3 -1
  119. package/themes/original/src/components/MultiOrdersDetails/index.tsx +23 -19
  120. package/themes/original/src/components/MyOrders/index.tsx +25 -16
  121. package/themes/original/src/components/NavBar/index.tsx +20 -13
  122. package/themes/original/src/components/NotFoundSource/index.tsx +14 -10
  123. package/themes/original/src/components/OrderDetails/OrderEta.tsx +76 -0
  124. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +21 -5
  125. package/themes/original/src/components/OrderDetails/index.tsx +50 -38
  126. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  127. package/themes/original/src/components/OrderItAgain/index.tsx +3 -1
  128. package/themes/original/src/components/OrderProgress/index.tsx +34 -25
  129. package/themes/original/src/components/OrderSummary/index.tsx +83 -57
  130. package/themes/original/src/components/OrderTypeSelector/index.tsx +5 -6
  131. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +14 -14
  132. package/themes/original/src/components/OrdersOption/index.tsx +59 -48
  133. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  134. package/themes/original/src/components/PageBanner/index.tsx +65 -29
  135. package/themes/original/src/components/PageBanner/styles.tsx +0 -3
  136. package/themes/original/src/components/PaymentOptionCard/index.tsx +180 -0
  137. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +3 -0
  138. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  139. package/themes/original/src/components/PaymentOptions/index.tsx +100 -34
  140. package/themes/original/src/components/PhoneInputNumber/index.tsx +18 -4
  141. package/themes/original/src/components/ProductForm/index.tsx +87 -31
  142. package/themes/original/src/components/ProductForm/styles.tsx +3 -3
  143. package/themes/original/src/components/ProductItemAccordion/index.tsx +8 -6
  144. package/themes/original/src/components/ProductOptionSubOption/index.tsx +49 -20
  145. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +10 -9
  146. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  147. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -50
  148. package/themes/original/src/components/ProfessionalProfile/index.tsx +36 -7
  149. package/themes/original/src/components/Promotions/index.tsx +2 -2
  150. package/themes/original/src/components/Promotions/styles.tsx +3 -1
  151. package/themes/original/src/components/ReviewProducts/index.tsx +16 -7
  152. package/themes/original/src/components/ScheduleAccordion/index.tsx +3 -3
  153. package/themes/original/src/components/ServiceForm/index.tsx +63 -20
  154. package/themes/original/src/components/Sessions/styles.tsx +1 -0
  155. package/themes/original/src/components/SignupForm/index.tsx +43 -27
  156. package/themes/original/src/components/SingleOrderCard/index.tsx +42 -19
  157. package/themes/original/src/components/SingleOrderCard/styles.tsx +1 -1
  158. package/themes/original/src/components/SingleProductCard/index.tsx +14 -11
  159. package/themes/original/src/components/SingleProductCard/styles.tsx +8 -3
  160. package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
  161. package/themes/original/src/components/StripeCardsList/index.tsx +61 -5
  162. package/themes/original/src/components/StripeElementsForm/index.tsx +48 -34
  163. package/themes/original/src/components/StripeElementsForm/naked.tsx +12 -1
  164. package/themes/original/src/components/UpsellingProducts/index.tsx +5 -10
  165. package/themes/original/src/components/UserDetails/index.tsx +3 -1
  166. package/themes/original/src/components/UserFormDetails/index.tsx +78 -9
  167. package/themes/original/src/components/UserFormDetails/styles.tsx +1 -1
  168. package/themes/original/src/components/UserProfile/index.tsx +8 -26
  169. package/themes/original/src/components/UserProfileForm/index.tsx +30 -31
  170. package/themes/original/src/components/UserVerification/index.tsx +55 -50
  171. package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
  172. package/themes/original/src/components/WalletTransactions/index.tsx +3 -3
  173. package/themes/original/src/components/Wallets/index.tsx +52 -62
  174. package/themes/original/src/components/Wallets/styles.tsx +2 -4
  175. package/themes/original/src/components/shared/OButton.tsx +3 -3
  176. package/themes/original/src/components/shared/OInput.tsx +4 -5
  177. package/themes/original/src/components/shared/OModal.tsx +3 -3
  178. package/themes/original/src/types/index.tsx +37 -10
  179. package/themes/original/src/utils/index.tsx +185 -13
  180. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  181. package/src/navigators/BottomNavigator.tsx +0 -117
  182. package/src/navigators/CheckoutNavigator.tsx +0 -66
  183. package/src/navigators/HomeNavigator.tsx +0 -202
  184. package/src/navigators/NavigationRef.tsx +0 -7
  185. package/src/navigators/RootNavigator.tsx +0 -269
  186. package/src/pages/Account.tsx +0 -34
  187. package/src/pages/AddressForm.tsx +0 -62
  188. package/src/pages/AddressList.tsx +0 -24
  189. package/src/pages/BusinessProductsList.tsx +0 -81
  190. package/src/pages/BusinessesListing.tsx +0 -43
  191. package/src/pages/CartList.tsx +0 -49
  192. package/src/pages/Checkout.tsx +0 -101
  193. package/src/pages/ForgotPassword.tsx +0 -24
  194. package/src/pages/Help.tsx +0 -23
  195. package/src/pages/HelpAccountAndPayment.tsx +0 -23
  196. package/src/pages/HelpGuide.tsx +0 -23
  197. package/src/pages/HelpOrder.tsx +0 -23
  198. package/src/pages/Home.tsx +0 -36
  199. package/src/pages/IntroductoryTutorial.tsx +0 -170
  200. package/src/pages/Login.tsx +0 -47
  201. package/src/pages/MomentOption.tsx +0 -30
  202. package/src/pages/MultiCheckout.tsx +0 -31
  203. package/src/pages/MultiOrdersDetails.tsx +0 -27
  204. package/src/pages/MyOrders.tsx +0 -40
  205. package/src/pages/NetworkError.tsx +0 -24
  206. package/src/pages/NotFound.tsx +0 -22
  207. package/src/pages/OrderDetails.tsx +0 -25
  208. package/src/pages/ProductDetails.tsx +0 -55
  209. package/src/pages/Profile.tsx +0 -36
  210. package/src/pages/ReviewDriver.tsx +0 -30
  211. package/src/pages/ReviewOrder.tsx +0 -32
  212. package/src/pages/ReviewProducts.tsx +0 -30
  213. package/src/pages/Sessions.tsx +0 -22
  214. package/src/pages/Signup.tsx +0 -53
  215. package/src/pages/SpinnerLoader.tsx +0 -10
  216. package/src/pages/Splash.tsx +0 -21
@@ -1,5 +1,5 @@
1
- import React, { useRef } from 'react'
2
- import { useUtils, PageBanner as PageBannerController } from 'ordering-components/native'
1
+ import React, { useEffect, useState, useRef } from 'react'
2
+ import { useUtils, useEvent, PageBanner as PageBannerController } from 'ordering-components/native'
3
3
  import { View, StyleSheet, Dimensions, TouchableOpacity } from 'react-native'
4
4
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
5
5
  import Carousel from 'react-native-snap-carousel'
@@ -16,7 +16,10 @@ const PageBannerUI = (props: any) => {
16
16
 
17
17
  const theme = useTheme();
18
18
  const [{ optimizeImage }] = useUtils();
19
- const carouselRef = useRef(null)
19
+ const [events] = useEvent()
20
+ const carouselRef = useRef<any>(null)
21
+ const [currentIndex, setCurrentIndex] = useState(0)
22
+ const [viewedBanner, setViewedBanner] = useState<any>(null)
20
23
 
21
24
  const windowWidth = Dimensions.get('window').width;
22
25
 
@@ -41,10 +44,11 @@ const PageBannerUI = (props: any) => {
41
44
  })
42
45
 
43
46
  const onRedirect = (route: string, params?: any) => {
44
- navigation.navigate(route, params)
47
+ navigation.push(route, params)
45
48
  }
46
49
 
47
- const handleGoToPage = (action: any) => {
50
+ const handleGoToPage = (item: any) => {
51
+ const action = item.action
48
52
  if (!action?.url) return
49
53
  let slug
50
54
  if (action.type === 'business') {
@@ -59,15 +63,22 @@ const PageBannerUI = (props: any) => {
59
63
  businessSlug: slug,
60
64
  businessId: action.business_id,
61
65
  categoryId: action.category_id,
62
- productId: action.product_id
66
+ productId: action.product_id,
67
+ isRedirect: 'business',
68
+ business: {
69
+ store: slug
70
+ }
63
71
  })
64
72
  }
73
+ const clickedBanner = pageBannerState.result.find(banner => banner.id === item?.banner_id)
74
+ events.emit('promotion_clicked', clickedBanner)
65
75
  }
66
76
 
67
77
  const renderItem = ({ item, index }) => {
68
78
  return (
69
79
  <TouchableOpacity
70
- onPress={() => handleGoToPage(item.action)}
80
+ activeOpacity={1}
81
+ onPress={() => handleGoToPage(item)}
71
82
  >
72
83
  <View style={styles.sliderWrapper}>
73
84
  <FastImage
@@ -80,6 +91,24 @@ const PageBannerUI = (props: any) => {
80
91
  )
81
92
  }
82
93
 
94
+ const updateIndex = () => {
95
+ setCurrentIndex(carouselRef?.current?.currentIndex)
96
+ }
97
+
98
+ useEffect(() => {
99
+ if (pageBannerState.loading) return
100
+ if (pageBannerState.banner?.items && pageBannerState.banner?.items.length > 0) {
101
+ const bannerId = pageBannerState.banner.items[currentIndex]?.banner_id
102
+ if (pageBannerState.result && bannerId) {
103
+ const _viewedBanner = pageBannerState.result.find(banner => banner.id === bannerId)
104
+ if (_viewedBanner?.id !== viewedBanner?.id) {
105
+ setViewedBanner(_viewedBanner)
106
+ events.emit('promotion_viewed', _viewedBanner)
107
+ }
108
+ }
109
+ }
110
+ }, [pageBannerState.loading, currentIndex, viewedBanner])
111
+
83
112
  return (
84
113
  <>
85
114
  {pageBannerState.loading ? (
@@ -97,37 +126,44 @@ const PageBannerUI = (props: any) => {
97
126
  <>
98
127
  {pageBannerState.banner?.items && pageBannerState.banner?.items.length > 0 && (
99
128
  <PageBannerWrapper>
100
- <TouchableOpacity
101
- style={[styles.swiperButton, { left: 25 }]}
102
- onPress={() => carouselRef.current.snapToPrev()}
103
- >
104
- <IconAntDesign
105
- name="caretleft"
106
- color={theme.colors.white}
107
- size={13}
108
- />
109
- </TouchableOpacity>
110
- <TouchableOpacity
111
- style={[styles.swiperButton, { right: 25 }]}
112
- onPress={() => carouselRef.current.snapToNext()}
113
- >
114
- <IconAntDesign
115
- name="caretright"
116
- color={theme.colors.white}
117
- size={13}
118
- />
119
- </TouchableOpacity>
129
+ {pageBannerState.banner?.items.length > 1 && (
130
+ <>
131
+ <TouchableOpacity
132
+ activeOpacity={1}
133
+ style={[styles.swiperButton, { left: 25 }]}
134
+ onPress={() => carouselRef.current.snapToPrev()}
135
+ >
136
+ <IconAntDesign
137
+ name="caretleft"
138
+ color={theme.colors.white}
139
+ size={13}
140
+ />
141
+ </TouchableOpacity>
142
+ <TouchableOpacity
143
+ activeOpacity={1}
144
+ style={[styles.swiperButton, { right: 25 }]}
145
+ onPress={() => carouselRef.current.snapToNext()}
146
+ >
147
+ <IconAntDesign
148
+ name="caretright"
149
+ color={theme.colors.white}
150
+ size={13}
151
+ />
152
+ </TouchableOpacity>
153
+ </>
154
+ )}
120
155
  <Carousel
121
156
  ref={carouselRef}
122
157
  loop={pageBannerState.banner?.items.length > 1}
123
158
  data={pageBannerState.banner?.items}
124
159
  renderItem={renderItem}
125
- sliderWidth={windowWidth - 80}
126
- itemWidth={windowWidth - 80}
160
+ sliderWidth={windowWidth}
161
+ itemWidth={windowWidth}
127
162
  inactiveSlideScale={1}
128
163
  pagingEnabled
129
164
  removeClippedSubviews={false}
130
165
  inactiveSlideOpacity={1}
166
+ onSnapToItem={updateIndex}
131
167
  />
132
168
  </PageBannerWrapper>
133
169
  )}
@@ -1,10 +1,7 @@
1
1
  import styled from 'styled-components/native'
2
2
 
3
3
  export const PageBannerWrapper = styled.View`
4
- margin-horizontal: 40px;
5
- border-radius: 8px;
6
4
  overflow: hidden;
7
- margin-vertical: 30px;
8
5
  position: relative;
9
6
  flex-direction: row;
10
7
  align-items: center;
@@ -0,0 +1,180 @@
1
+ import React, { useEffect, useRef, useState } from 'react'
2
+ import { View, Modal, TouchableOpacity, StyleSheet, SafeAreaView, KeyboardAvoidingView, Platform, ScrollView } from 'react-native'
3
+ import { OButton, OIcon, OInput, OModal, OText } from '../shared'
4
+ import { PaymentOptionStripe, useLanguage, useSession } from 'ordering-components/native'
5
+ import { StripeCardsListUI } from '../StripeCardsList'
6
+ import { useTheme } from 'styled-components/native';
7
+ import { CreditCardInput } from "react-native-credit-card-input-plus";
8
+ import Alert from '../../providers/AlertProvider'
9
+
10
+ const PaymentOptionCardUI = (props: any) => {
11
+ const {
12
+ cardSelected,
13
+ deleteCard,
14
+ onSelectCard,
15
+ handleCardClick,
16
+ cardsList,
17
+ addCardOpen,
18
+ setAddCardOpen,
19
+ gateway,
20
+ handleNewCard,
21
+ paymethodsWithoutSaveCards
22
+ } = props
23
+ const [, t] = useLanguage()
24
+ const theme = useTheme()
25
+ const [{ token }] = useSession()
26
+ const [alertState, setAlertState] = useState<{ open: boolean, content: Array<string> }>({ open: false, content: [] })
27
+ const [newCard, setNewCard] = useState<any>(null)
28
+
29
+ const onChangeCardForm = (values : any) => {
30
+ if (values?.valid) {
31
+ const expiry = values?.values?.expiry?.split('/')
32
+ const expiryMonth = expiry[0]
33
+ const expiryYear = expiry[1]
34
+ const expiryString = expiryMonth + expiryYear
35
+ let lastFourDigits = values?.values?.number?.substr(-4);
36
+ setNewCard({
37
+ name: values?.values.name,
38
+ number: values?.values.number.replace(/\s/g, ''),
39
+ cvc: values?.values.cvc,
40
+ expiryMonth: expiryMonth,
41
+ expiryYear: expiryYear,
42
+ expiry: expiry,
43
+ brand: values?.values?.type,
44
+ last4: lastFourDigits,
45
+ expiryString: expiryString
46
+ })
47
+ }
48
+ }
49
+
50
+ const handleAddNewCard = () => {
51
+ handleNewCard(newCard)
52
+ setAddCardOpen({ ...addCardOpen, card: false })
53
+ setNewCard(null)
54
+ }
55
+
56
+ useEffect(() => {
57
+ if (cardsList.error && !cardsList.loading) {
58
+ setAlertState({
59
+ open: true,
60
+ content: cardsList.error
61
+ })
62
+ }
63
+ }, [JSON.stringify(cardsList)])
64
+
65
+ const style = StyleSheet.create({
66
+ wrapperIcon: {
67
+ marginLeft: 25,
68
+ marginTop: Platform.OS === 'ios' ? 40 : 12,
69
+ marginBottom: 20,
70
+ alignItems: 'center',
71
+ justifyContent: 'center',
72
+ },
73
+ buttonStyle: {
74
+ marginVertical: 20,
75
+ borderRadius: 7.6,
76
+ shadowOpacity: 0,
77
+ height: 44,
78
+ borderWidth: 1
79
+ }
80
+ })
81
+
82
+ return (
83
+ <View>
84
+ <>
85
+ {token && (!cardSelected || !paymethodsWithoutSaveCards.includes(gateway)) && (
86
+ <OButton
87
+ text={t('ADD_PAYMENT_CARD', 'Add New Payment Card')}
88
+ bgColor={theme.colors.white}
89
+ borderColor={theme.colors.primary}
90
+ style={{
91
+ marginVertical: 20,
92
+ borderRadius: 7.6,
93
+ shadowOpacity: 0,
94
+ height: 44,
95
+ borderWidth: 1
96
+ }}
97
+ textStyle={{ color: theme.colors.primary, fontSize: 12 }}
98
+ imgRightSrc={null}
99
+ onClick={() => setAddCardOpen({ ...addCardOpen, card: true })}
100
+ />
101
+ )}
102
+ <StripeCardsListUI
103
+ cardSelected={cardSelected}
104
+ deleteCard={deleteCard}
105
+ onSelectCard={onSelectCard}
106
+ handleCardClick={handleCardClick}
107
+ cardsList={cardsList}
108
+ noShowErrors
109
+ gateway={gateway}
110
+ />
111
+ </>
112
+ <Modal
113
+ animationType="slide"
114
+ visible={addCardOpen?.card}
115
+ onDismiss={() => setAddCardOpen({ ...addCardOpen, card: false })}
116
+ >
117
+ <KeyboardAvoidingView
118
+ behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
119
+ style={{
120
+ flex: 1,
121
+ }}
122
+ >
123
+ <ScrollView>
124
+ <TouchableOpacity onPress={() => setAddCardOpen({ ...addCardOpen, card: false })}>
125
+ <OIcon
126
+ src={theme.images.general.close}
127
+ width={16}
128
+ style={style.wrapperIcon}
129
+ />
130
+ </TouchableOpacity>
131
+ <>
132
+ <CreditCardInput
133
+ onChange={onChangeCardForm}
134
+ requiresName
135
+ />
136
+ {alertState?.content?.[0] && !cardsList?.loading && (
137
+ <OText
138
+ color={theme?.colors?.error}
139
+ style={{
140
+ alignSelf: 'center'
141
+ }}
142
+ size={20}
143
+ >
144
+ {alertState.content[0]}
145
+ </OText>
146
+ )}
147
+ <OButton
148
+ text={t('ADD_CARD', 'Add card')}
149
+ isDisabled={!newCard || cardsList?.loading}
150
+ isLoading={cardsList?.loading}
151
+ onClick={() => handleAddNewCard()}
152
+ style={{
153
+ margin: 20,
154
+ ...style.buttonStyle
155
+ }}
156
+ />
157
+ </>
158
+ </ScrollView>
159
+ </KeyboardAvoidingView>
160
+ </Modal>
161
+ <Alert
162
+ open={alertState?.open || false}
163
+ title=''
164
+ content={alertState.content}
165
+ onClose={() => setAlertState({ open: false, content: [] })}
166
+ onAccept={() => setAlertState({ open: false, content: [] })}
167
+ />
168
+ </View>
169
+ )
170
+ }
171
+
172
+ export const PaymentOptionCard = (props : any) => {
173
+ const paymentOptions = {
174
+ ...props,
175
+ UIComponent: PaymentOptionCardUI
176
+ }
177
+ return (
178
+ <PaymentOptionStripe {...paymentOptions} />
179
+ )
180
+ }
@@ -40,6 +40,9 @@ export const OSItem = styled.View`
40
40
  justify-content: space-between;
41
41
  align-items: center;
42
42
  padding: 10px 0px;
43
+ ${({ isInvalid } : any) => isInvalid && css`
44
+ opacity: 0.7;
45
+ `}
43
46
  `;
44
47
 
45
48
  export const OSItemContent = styled.TouchableOpacity`
@@ -45,7 +45,7 @@ const PaymentOptionWalletUI = (props: any) => {
45
45
  new Array(walletsState.result?.length).fill(false)
46
46
  );
47
47
 
48
- const creditBalance: any = (wallet: any) => ` = ${parsePrice(wallet.balance / wallet.redemption_rate, { isTruncable: true })}`
48
+ const creditBalance: any = (wallet: any) => ` = ${parsePrice(wallet.balance / wallet.redemption_rate)}`
49
49
 
50
50
  const walletName: any = {
51
51
  cash: {
@@ -87,65 +87,65 @@ const PaymentOptionWalletUI = (props: any) => {
87
87
  {!walletsState.loading &&
88
88
  !walletsState.error &&
89
89
  walletsState.result?.length > 0 &&
90
- (
91
- <>
92
- {walletsState.result?.map((wallet: any, idx: any) => wallet.valid && wallet.balance >= 0 && walletName[wallet.type]?.isActive && (
93
- <Container
94
- key={wallet.id}
95
- isBottomBorder={idx === walletsState.result?.filter((wallet: any) => wallet.valid)?.length - 1}
96
- onPress={() => handleOnChange(idx, wallet)}
97
- disabled={(cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0}
98
- >
99
- <SectionLeft>
100
- {checkedState[idx] ? (
101
- <MaterialCommunityIcons
102
- name="checkbox-marked"
103
- size={25}
104
- color={theme.colors.primary}
105
- />
106
- ) : (
107
- <MaterialCommunityIcons
108
- name="checkbox-blank-outline"
109
- size={25}
110
- color={theme.colors.disabled}
111
- />
112
- )}
113
- <View style={{ alignItems: 'baseline', marginLeft: 5 }}>
114
- <View>
115
- <OText
116
- style={((cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0) ? {
117
- color: theme.colors.disabled
118
- } : {}}
119
- >
120
- {walletName[wallet.type]?.name}
121
- </OText>
122
- </View>
90
+ (
91
+ <>
92
+ {walletsState.result?.map((wallet: any, idx: any) => wallet.valid && wallet.balance >= 0 && walletName[wallet.type]?.isActive && (
93
+ <Container
94
+ key={wallet.id}
95
+ isBottomBorder={idx === walletsState.result?.filter((wallet: any) => wallet.valid)?.length - 1}
96
+ onPress={() => handleOnChange(idx, wallet)}
97
+ disabled={(cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0}
98
+ >
99
+ <SectionLeft>
100
+ {checkedState[idx] ? (
101
+ <MaterialCommunityIcons
102
+ name="checkbox-marked"
103
+ size={25}
104
+ color={theme.colors.primary}
105
+ />
106
+ ) : (
107
+ <MaterialCommunityIcons
108
+ name="checkbox-blank-outline"
109
+ size={25}
110
+ color={theme.colors.disabled}
111
+ />
112
+ )}
113
+ <View style={{ alignItems: 'baseline', marginLeft: 5 }}>
114
+ <View>
115
+ <OText
116
+ style={((cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0) ?{
117
+ color: theme.colors.disabled
118
+ } : {}}
119
+ >
120
+ {walletName[wallet.type]?.name}
121
+ </OText>
123
122
  </View>
124
- </SectionLeft>
125
-
126
- <View style={{ maxWidth: '35%', alignItems: 'flex-end' }}>
127
- {wallet.type === 'cash' && (
128
- <OText>
129
- {parsePrice(wallet?.balance, { isTruncable: true })}
123
+ </View>
124
+ </SectionLeft>
125
+
126
+ <View style={{maxWidth: '35%', alignItems: 'flex-end' }}>
127
+ {wallet.type === 'cash' && (
128
+ <OText>
129
+ {parsePrice(wallet?.balance)}
130
+ </OText>
131
+ )}
132
+ {wallet.type === 'credit_point' && (
133
+ <OText>
134
+ <OText color={theme.colors.primary} weight='bold'>
135
+ {`${wallet?.balance} ${t('POINTS', 'Points')}`}
130
136
  </OText>
131
- )}
132
- {wallet.type === 'credit_point' && (
133
137
  <OText>
134
- <OText color={theme.colors.primary} weight='bold'>
135
- {`${wallet?.balance} ${t('POINTS', 'Points')}`}
136
- </OText>
137
- <OText>
138
- {wallet?.balance > 0
139
- ? creditBalance(wallet)
140
- : null}
141
- </OText>
138
+ {wallet?.balance > 0
139
+ ? creditBalance(wallet)
140
+ : null}
142
141
  </OText>
143
- )}
144
- </View>
145
- </Container>
146
- ))}
147
- </>
148
- )}
142
+ </OText>
143
+ )}
144
+ </View>
145
+ </Container>
146
+ ))}
147
+ </>
148
+ )}
149
149
 
150
150
  {walletsState?.loading && (
151
151
  <View>