ordering-ui-react-native 0.17.98 → 0.17.99-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 (224) 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 +2 -0
  14. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +36 -26
  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/index.tsx +5 -2
  22. package/themes/business/src/components/MapView/index.tsx +14 -10
  23. package/themes/business/src/components/MessagesOption/index.tsx +22 -94
  24. package/themes/business/src/components/NewOrderNotification/index.tsx +123 -96
  25. package/themes/business/src/components/NotFoundSource/index.tsx +2 -2
  26. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  27. package/themes/business/src/components/OrderDetails/Delivery.tsx +209 -15
  28. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +84 -37
  29. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +87 -66
  30. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +200 -0
  31. package/themes/business/src/components/OrderDetailsLogistic/styles.tsx +5 -0
  32. package/themes/business/src/components/OrderMessage/index.tsx +19 -18
  33. package/themes/business/src/components/OrderSummary/index.tsx +114 -123
  34. package/themes/business/src/components/OrdersListManager/index.tsx +7 -2
  35. package/themes/business/src/components/OrdersListManager/utils.tsx +1 -1
  36. package/themes/business/src/components/OrdersOption/index.tsx +60 -47
  37. package/themes/business/src/components/PreviousMessages/FooterMessageComponent.tsx +103 -0
  38. package/themes/business/src/components/PreviousMessages/index.tsx +97 -55
  39. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +21 -29
  40. package/themes/business/src/components/PreviousOrders/OrderList.tsx +93 -0
  41. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +1 -1
  42. package/themes/business/src/components/PreviousOrders/index.tsx +198 -221
  43. package/themes/business/src/components/PreviousOrders/styles.tsx +10 -0
  44. package/themes/business/src/components/ProductItemAccordion/index.tsx +7 -1
  45. package/themes/business/src/components/ReviewCustomer/index.tsx +18 -13
  46. package/themes/business/src/components/StoresList/index.tsx +3 -4
  47. package/themes/business/src/components/UserProfileForm/index.tsx +14 -15
  48. package/themes/business/src/components/WebsocketStatus/index.tsx +171 -0
  49. package/themes/business/src/components/WebsocketStatus/styles.tsx +28 -0
  50. package/themes/business/src/components/shared/OModal.tsx +16 -9
  51. package/themes/business/src/types/index.tsx +24 -10
  52. package/themes/business/src/utils/index.tsx +29 -2
  53. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  54. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  55. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  56. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  57. package/themes/kiosk/src/components/Intro/index.tsx +16 -1
  58. package/themes/kiosk/src/components/LoginForm/index.tsx +7 -5
  59. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  60. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  61. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  62. package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +2 -2
  63. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  64. package/themes/original/index.tsx +7 -3
  65. package/themes/original/src/components/AddressDetails/index.tsx +19 -3
  66. package/themes/original/src/components/AddressForm/index.tsx +33 -15
  67. package/themes/original/src/components/AddressList/index.tsx +5 -8
  68. package/themes/original/src/components/AnalyticsSegment/index.tsx +193 -10
  69. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  70. package/themes/original/src/components/AppleLogin/styles.tsx +3 -1
  71. package/themes/original/src/components/BusinessBasicInformation/index.tsx +72 -36
  72. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +10 -12
  73. package/themes/original/src/components/BusinessController/index.tsx +35 -44
  74. package/themes/original/src/components/BusinessController/styles.tsx +12 -5
  75. package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
  76. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
  77. package/themes/original/src/components/BusinessInformation/index.tsx +140 -85
  78. package/themes/original/src/components/BusinessItemAccordion/index.tsx +21 -23
  79. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +1 -1
  80. package/themes/original/src/components/BusinessListingSearch/index.tsx +346 -340
  81. package/themes/original/src/components/BusinessListingSearch/styles.tsx +0 -18
  82. package/themes/original/src/components/BusinessPreorder/index.tsx +105 -22
  83. package/themes/original/src/components/BusinessPreorder/styles.tsx +14 -0
  84. package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -2
  85. package/themes/original/src/components/BusinessProductsList/index.tsx +15 -7
  86. package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
  87. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +1 -1
  88. package/themes/original/src/components/BusinessProductsListing/index.tsx +137 -32
  89. package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -3
  90. package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
  91. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +69 -0
  92. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +406 -0
  93. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListing.tsx +76 -0
  94. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +37 -404
  95. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  96. package/themes/original/src/components/Cart/index.tsx +49 -47
  97. package/themes/original/src/components/CartContent/index.tsx +99 -38
  98. package/themes/original/src/components/CartContent/styles.tsx +6 -6
  99. package/themes/original/src/components/Checkout/index.tsx +323 -42
  100. package/themes/original/src/components/CitiesControl/index.tsx +1 -1
  101. package/themes/original/src/components/CouponControl/index.tsx +10 -3
  102. package/themes/original/src/components/DatePicker/index.tsx +17 -0
  103. package/themes/original/src/components/DatePicker/styles.tsx +20 -0
  104. package/themes/original/src/components/DriverTips/index.tsx +12 -4
  105. package/themes/original/src/components/FacebookLogin/styles.tsx +3 -1
  106. package/themes/original/src/components/Favorite/index.tsx +1 -5
  107. package/themes/original/src/components/GPSButton/index.tsx +6 -4
  108. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +8 -3
  109. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +42 -5
  110. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +2 -0
  111. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +84 -8
  112. package/themes/original/src/components/GoogleLogin/styles.tsx +1 -1
  113. package/themes/original/src/components/GoogleMap/index.tsx +63 -7
  114. package/themes/original/src/components/Home/index.tsx +13 -4
  115. package/themes/original/src/components/LastOrder/index.tsx +2 -1
  116. package/themes/original/src/components/LastOrders/index.tsx +2 -1
  117. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -25
  118. package/themes/original/src/components/LoginForm/index.tsx +64 -34
  119. package/themes/original/src/components/LottieAnimation/index.tsx +88 -63
  120. package/themes/original/src/components/MessageListing/index.tsx +9 -2
  121. package/themes/original/src/components/Messages/index.tsx +15 -4
  122. package/themes/original/src/components/MomentOption/index.tsx +44 -39
  123. package/themes/original/src/components/MomentSelector/index.tsx +1 -1
  124. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +161 -49
  125. package/themes/original/src/components/MultiCheckout/index.tsx +346 -68
  126. package/themes/original/src/components/MultiCheckout/styles.tsx +3 -1
  127. package/themes/original/src/components/MultiOrdersDetails/index.tsx +1 -1
  128. package/themes/original/src/components/MyOrders/index.tsx +12 -1
  129. package/themes/original/src/components/NavBar/index.tsx +20 -13
  130. package/themes/original/src/components/NotFoundSource/index.tsx +14 -10
  131. package/themes/original/src/components/OrderDetails/OrderEta.tsx +76 -0
  132. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +21 -5
  133. package/themes/original/src/components/OrderDetails/index.tsx +50 -38
  134. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  135. package/themes/original/src/components/OrderItAgain/index.tsx +3 -1
  136. package/themes/original/src/components/OrderProgress/index.tsx +34 -25
  137. package/themes/original/src/components/OrderSummary/index.tsx +62 -57
  138. package/themes/original/src/components/OrderTypeSelector/index.tsx +5 -6
  139. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +13 -13
  140. package/themes/original/src/components/OrdersOption/index.tsx +43 -20
  141. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  142. package/themes/original/src/components/PageBanner/index.tsx +65 -29
  143. package/themes/original/src/components/PageBanner/styles.tsx +0 -3
  144. package/themes/original/src/components/PaymentOptionCard/index.tsx +180 -0
  145. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +3 -0
  146. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  147. package/themes/original/src/components/PaymentOptions/index.tsx +100 -34
  148. package/themes/original/src/components/PhoneInputNumber/index.tsx +18 -4
  149. package/themes/original/src/components/ProductForm/ActionButton.tsx +120 -0
  150. package/themes/original/src/components/ProductForm/index.tsx +65 -34
  151. package/themes/original/src/components/ProductForm/styles.tsx +3 -3
  152. package/themes/original/src/components/ProductItemAccordion/index.tsx +8 -6
  153. package/themes/original/src/components/ProductOptionSubOption/index.tsx +49 -20
  154. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +10 -9
  155. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  156. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -50
  157. package/themes/original/src/components/ProfessionalProfile/index.tsx +36 -7
  158. package/themes/original/src/components/Promotions/index.tsx +2 -2
  159. package/themes/original/src/components/Promotions/styles.tsx +3 -1
  160. package/themes/original/src/components/ReviewProducts/index.tsx +16 -7
  161. package/themes/original/src/components/ScheduleAccordion/index.tsx +3 -3
  162. package/themes/original/src/components/ServiceForm/index.tsx +40 -20
  163. package/themes/original/src/components/SignupForm/index.tsx +27 -16
  164. package/themes/original/src/components/SingleOrderCard/index.tsx +44 -20
  165. package/themes/original/src/components/SingleOrderCard/styles.tsx +1 -1
  166. package/themes/original/src/components/SingleProductCard/index.tsx +13 -10
  167. package/themes/original/src/components/SingleProductCard/styles.tsx +8 -3
  168. package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
  169. package/themes/original/src/components/StripeCardsList/index.tsx +61 -5
  170. package/themes/original/src/components/StripeElementsForm/index.tsx +48 -34
  171. package/themes/original/src/components/StripeElementsForm/naked.tsx +12 -1
  172. package/themes/original/src/components/UpsellingProducts/index.tsx +3 -8
  173. package/themes/original/src/components/UserDetails/index.tsx +3 -1
  174. package/themes/original/src/components/UserFormDetails/index.tsx +84 -19
  175. package/themes/original/src/components/UserFormDetails/styles.tsx +1 -1
  176. package/themes/original/src/components/UserProfile/index.tsx +7 -25
  177. package/themes/original/src/components/UserProfileForm/index.tsx +30 -31
  178. package/themes/original/src/components/UserVerification/index.tsx +55 -50
  179. package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
  180. package/themes/original/src/components/WalletTransactions/index.tsx +3 -3
  181. package/themes/original/src/components/Wallets/index.tsx +51 -61
  182. package/themes/original/src/components/Wallets/styles.tsx +2 -4
  183. package/themes/original/src/components/shared/OButton.tsx +3 -3
  184. package/themes/original/src/components/shared/OInput.tsx +4 -5
  185. package/themes/original/src/components/shared/OModal.tsx +3 -3
  186. package/themes/original/src/types/index.tsx +30 -7
  187. package/themes/original/src/utils/index.tsx +180 -13
  188. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  189. package/src/navigators/BottomNavigator.tsx +0 -117
  190. package/src/navigators/CheckoutNavigator.tsx +0 -66
  191. package/src/navigators/HomeNavigator.tsx +0 -202
  192. package/src/navigators/NavigationRef.tsx +0 -7
  193. package/src/navigators/RootNavigator.tsx +0 -269
  194. package/src/pages/Account.tsx +0 -34
  195. package/src/pages/AddressForm.tsx +0 -62
  196. package/src/pages/AddressList.tsx +0 -24
  197. package/src/pages/BusinessProductsList.tsx +0 -81
  198. package/src/pages/BusinessesListing.tsx +0 -43
  199. package/src/pages/CartList.tsx +0 -49
  200. package/src/pages/Checkout.tsx +0 -101
  201. package/src/pages/ForgotPassword.tsx +0 -24
  202. package/src/pages/Help.tsx +0 -23
  203. package/src/pages/HelpAccountAndPayment.tsx +0 -23
  204. package/src/pages/HelpGuide.tsx +0 -23
  205. package/src/pages/HelpOrder.tsx +0 -23
  206. package/src/pages/Home.tsx +0 -36
  207. package/src/pages/IntroductoryTutorial.tsx +0 -170
  208. package/src/pages/Login.tsx +0 -47
  209. package/src/pages/MomentOption.tsx +0 -30
  210. package/src/pages/MultiCheckout.tsx +0 -31
  211. package/src/pages/MultiOrdersDetails.tsx +0 -27
  212. package/src/pages/MyOrders.tsx +0 -40
  213. package/src/pages/NetworkError.tsx +0 -24
  214. package/src/pages/NotFound.tsx +0 -22
  215. package/src/pages/OrderDetails.tsx +0 -25
  216. package/src/pages/ProductDetails.tsx +0 -55
  217. package/src/pages/Profile.tsx +0 -36
  218. package/src/pages/ReviewDriver.tsx +0 -30
  219. package/src/pages/ReviewOrder.tsx +0 -32
  220. package/src/pages/ReviewProducts.tsx +0 -30
  221. package/src/pages/Sessions.tsx +0 -22
  222. package/src/pages/Signup.tsx +0 -53
  223. package/src/pages/SpinnerLoader.tsx +0 -10
  224. package/src/pages/Splash.tsx +0 -21
@@ -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>
@@ -11,11 +11,14 @@ import {
11
11
  useLanguage,
12
12
  ToastType,
13
13
  useToast,
14
+ useSession
14
15
  } from 'ordering-components/native';
15
16
  import { useTheme } from 'styled-components/native';
16
17
  import { PaymentOptionCash } from '../PaymentOptionCash';
17
18
  import { StripeElementsForm } from '../StripeElementsForm';
18
19
  import { StripeCardsList } from '../StripeCardsList';
20
+ import { PaymentOptionCard } from '../PaymentOptionCard'
21
+
19
22
  // import { PaymentOptionStripe } from '../PaymentOptionStripe';
20
23
  // import { StripeRedirectForm } from '../StripeRedirectForm';
21
24
  // import { PaymentOptionPaypal } from '../PaymentOptionPaypal'
@@ -34,7 +37,7 @@ import { useApplePay } from '@stripe/stripe-react-native';
34
37
 
35
38
  const stripeOptions: any = ['stripe_direct', 'stripe', 'stripe_connect']
36
39
  const methodsPay = ['google_pay', 'apple_pay']
37
- const stripeDirectMethods = ['stripe_direct', ...methodsPay]
40
+ const stripeDirectMethods = ['stripe_direct']
38
41
  // const stripeRedirectOptions = [
39
42
  // { name: 'Bancontact', value: 'bancontact' },
40
43
  // { name: 'Alipay', value: 'alipay' },
@@ -43,6 +46,8 @@ const stripeDirectMethods = ['stripe_direct', ...methodsPay]
43
46
  // ]
44
47
 
45
48
  const webViewPaymentGateway: any = ['paypal', 'square']
49
+ const multiCheckoutMethods = ['global_google_pay', 'global_apple_pay']
50
+ const cardsPaymethods = ['credomatic']
46
51
 
47
52
  const PaymentOptionsUI = (props: any) => {
48
53
  const {
@@ -59,11 +64,22 @@ const PaymentOptionsUI = (props: any) => {
59
64
  isOpenMethod,
60
65
  handlePaymentMethodClickCustom,
61
66
  handlePlaceOrder,
62
- merchantId
67
+ merchantId,
68
+ setMethodPaySupported,
69
+ placeByMethodPay,
70
+ methodPaySupported,
71
+ setPlaceByMethodPay,
72
+ setCardList,
73
+ onPaymentChange,
74
+ requiredFields,
75
+ openUserModal,
76
+ paymethodClicked,
77
+ setPaymethodClicked
63
78
  } = props
64
79
 
65
80
  const theme = useTheme();
66
81
  const [, { showToast }] = useToast();
82
+ const [{ user }] = useSession()
67
83
  const { confirmApplePayPayment } = useApplePay()
68
84
 
69
85
  const getPayIcon = (method: string) => {
@@ -75,7 +91,7 @@ const PaymentOptionsUI = (props: any) => {
75
91
  case 'paypal':
76
92
  return theme.images.general.paypal
77
93
  case 'stripe':
78
- return theme.images.general.stripe
94
+ return theme.images.general.creditCard
79
95
  case 'stripe_direct':
80
96
  return theme.images.general.stripecc
81
97
  case 'stripe_connect':
@@ -84,6 +100,8 @@ const PaymentOptionsUI = (props: any) => {
84
100
  return theme.images.general.stripesb
85
101
  case 'apple_pay':
86
102
  return theme.images.general.applePayMark
103
+ case 'google_pay':
104
+ return theme.images.general.googlePayMark
87
105
  default:
88
106
  return theme.images.general.creditCard
89
107
  }
@@ -91,7 +109,7 @@ const PaymentOptionsUI = (props: any) => {
91
109
 
92
110
  const [, t] = useLanguage();
93
111
 
94
- const [addCardOpen, setAddCardOpen] = useState({ stripe: false, stripeConnect: false });
112
+ const [addCardOpen, setAddCardOpen] = useState({ stripe: false, stripeConnect: false, card: false });
95
113
  const paymethodSelected = props.paySelected || props.paymethodSelected || isOpenMethod?.paymethod
96
114
  // const [{ token }] = useSession()
97
115
 
@@ -101,8 +119,18 @@ const PaymentOptionsUI = (props: any) => {
101
119
  // { name: t('SELECT_A_PAYMENT_METHOD', 'Select a payment method'), value: '-1' },
102
120
  // ]
103
121
 
122
+ const paymethodsFieldRequired = ['paypal', 'apple_pay', 'global_apple_pay']
123
+
104
124
  const handlePaymentMethodClick = (paymethod: any) => {
105
- if (cart?.balance > 0) {
125
+ if (cart?.balance > 0 || !!user?.guest_id) {
126
+ if (paymethodsFieldRequired.includes(paymethod?.gateway) && requiredFields.length > 0) {
127
+ openUserModal && openUserModal(true)
128
+ setPaymethodClicked({
129
+ confirmed: false,
130
+ paymethod
131
+ })
132
+ return
133
+ }
106
134
  const isPopupMethod = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect', 'paypal'].includes(paymethod?.gateway)
107
135
  if (webViewPaymentGateway.includes(paymethod?.gateway)) {
108
136
  handlePaymentMethodClickCustom(paymethod)
@@ -116,6 +144,12 @@ const PaymentOptionsUI = (props: any) => {
116
144
  ;
117
145
  }
118
146
 
147
+ useEffect(() => {
148
+ if (cart?.balance === 0) {
149
+ handlePaymethodClick(null)
150
+ }
151
+ }, [cart?.balance])
152
+
119
153
  useEffect(() => {
120
154
  if (paymethodsList.paymethods.length === 1) {
121
155
  handlePaymethodClick && handlePaymethodClick(paymethodsList.paymethods[0])
@@ -142,10 +176,17 @@ const PaymentOptionsUI = (props: any) => {
142
176
  }
143
177
  }, [paymethodData, paymethodSelected])
144
178
 
179
+ useEffect(() => {
180
+ if (paymethodClicked?.confirmed) {
181
+ handlePaymentMethodClickCustom(paymethodClicked?.paymethod)
182
+ }
183
+ }, [paymethodClicked?.confirmed])
184
+
185
+
145
186
  const renderPaymethods = ({ item }: any) => {
146
187
  return (
147
188
  <>
148
- {item?.gateway === 'apple_pay' ? (
189
+ {methodsPay.includes(item?.gateway) ? (
149
190
  <TouchableOpacity
150
191
  onPress={() => handlePaymentMethodClick(item)}
151
192
  >
@@ -187,6 +228,7 @@ const PaymentOptionsUI = (props: any) => {
187
228
  }
188
229
 
189
230
  const excludeIds: any = [32]; //exclude paypal & connect & redirect
231
+ const filterMethodsPay = (gateway: string) => Platform.OS === 'ios' ? gateway !== 'google_pay' : gateway !== 'apple_pay'
190
232
 
191
233
  return (
192
234
  <PMContainer>
@@ -195,7 +237,11 @@ const PaymentOptionsUI = (props: any) => {
195
237
  horizontal
196
238
  showsHorizontalScrollIndicator={false}
197
239
  // data={paymethodsList.paymethods.sort((a: any, b: any) => a.id - b.id)}
198
- data={paymethodsList.paymethods.sort((a: any, b: any) => a.id - b.id).filter((p: any) => !excludeIds.includes(p.id))}
240
+ data={paymethodsList.paymethods.sort((a: any, b: any) => a.id - b.id)
241
+ .filter((p: any) =>
242
+ !multiCheckoutMethods.includes(p.gateway) &&
243
+ filterMethodsPay(p.gateway) &&
244
+ !excludeIds.includes(p.id))}
199
245
  renderItem={renderPaymethods}
200
246
  keyExtractor={(paymethod: any) => paymethod?.id?.toString?.()}
201
247
  />
@@ -241,7 +287,7 @@ const PaymentOptionsUI = (props: any) => {
241
287
  />
242
288
  )}
243
289
 
244
- {stripeOptions.includes(paymethodSelected?.gateway) &&
290
+ {/* {stripeOptions.includes(paymethodSelected?.gateway) &&
245
291
  (paymethodData?.brand || paymethodData?.card?.brand) &&
246
292
  (paymethodData?.last4 || paymethodData?.card?.last4) &&
247
293
  (
@@ -270,10 +316,10 @@ const PaymentOptionsUI = (props: any) => {
270
316
  </View>
271
317
  </PMCardItemContent>
272
318
  </PMCardSelected>
273
- )}
319
+ )} */}
274
320
 
275
321
  {/* Stripe */}
276
- {isOpenMethod?.paymethod?.gateway === 'stripe' && !paymethodData?.id && (
322
+ {isOpenMethod?.paymethod?.gateway === 'stripe' && (
277
323
  <View>
278
324
  <OButton
279
325
  text={t('ADD_PAYMENT_CARD', 'Add New Payment Card')}
@@ -291,35 +337,55 @@ const PaymentOptionsUI = (props: any) => {
291
337
  payType={paymethodsList?.name}
292
338
  onSelectCard={handlePaymethodDataChange}
293
339
  onNavigationRedirect={onNavigationRedirect}
340
+ paymethodCardId={paymethodData?.id}
294
341
  onCancel={() => handlePaymethodClick(null)}
342
+ setAddCardOpen={setAddCardOpen}
343
+ addCardOpen={addCardOpen}
344
+ isOpenMethod={isOpenMethod}
345
+ handlePaymethodDataChange={handlePaymethodDataChange}
346
+ clientSecret={props.clientSecret}
347
+ businessId={props.businessId}
348
+ onPaymentChange={onPaymentChange}
295
349
  />
296
350
  </View>
297
351
  )}
352
+ {/* Google pay, Apple pay */}
353
+ {methodsPay.includes(isOpenMethod?.paymethod?.gateway) && (
354
+ <StripeElementsForm
355
+ cart={cart}
356
+ paymethod={isOpenMethod?.paymethod?.gateway}
357
+ methodsPay={methodsPay}
358
+ businessId={props.businessId}
359
+ publicKey={isOpenMethod?.paymethod?.credentials?.publishable || isOpenMethod?.paymethod?.credentials?.publishable_key}
360
+ handleSource={handlePaymethodDataChange}
361
+ onCancel={() => handlePaymethodClick(null)}
362
+ merchantId={merchantId}
363
+ setMethodPaySupported={setMethodPaySupported}
364
+ methodPaySupported={methodPaySupported}
365
+ placeByMethodPay={placeByMethodPay}
366
+ setPlaceByMethodPay={setPlaceByMethodPay}
367
+ />
368
+ )}
298
369
 
299
- <OModal
300
- entireModal
301
- title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
302
- open={addCardOpen.stripe}
303
- onClose={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
304
- style={{ backgroundColor: 'red' }}
305
- >
306
- <KeyboardAvoidingView
307
- behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
308
- keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
309
- enabled={Platform.OS === 'ios' ? true : false}
310
- >
311
- <StripeElementsForm
312
- toSave
313
- businessId={props.businessId}
314
- publicKey={isOpenMethod?.paymethod?.credentials?.publishable}
315
- requirements={props.clientSecret}
316
- onSelectCard={handlePaymethodDataChange}
317
- onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
318
- />
319
- </KeyboardAvoidingView>
320
- </OModal>
370
+ {(cardsPaymethods.includes(isOpenMethod?.paymethod?.gateway) || cardsPaymethods.includes(paymethodSelected?.gateway)) && (
371
+ <PaymentOptionCard
372
+ setCardList={setCardList}
373
+ paymethod={isOpenMethod?.paymethod}
374
+ businessId={props.businessId}
375
+ publicKey={isOpenMethod?.paymethod?.credentials?.publishable}
376
+ gateway={isOpenMethod?.paymethod?.gateway || paymethodSelected?.gateway}
377
+ onPaymentChange={onPaymentChange}
378
+ payType={isOpenMethod?.paymethod?.name}
379
+ onSelectCard={handlePaymethodDataChange}
380
+ addCardOpen={addCardOpen}
381
+ setAddCardOpen={setAddCardOpen}
382
+ onCancel={() => handlePaymethodClick(null)}
383
+ paymethodSelected={paymethodSelected?.data?.id}
384
+ handlePaymentMethodClick={handlePaymentMethodClick}
385
+ />
386
+ )}
321
387
 
322
- {/* Stripe direct, Google pay, Apple pay */}
388
+ {/* Stripe direct */}
323
389
  <OModal
324
390
  entireModal
325
391
  title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
@@ -367,7 +433,7 @@ const PaymentOptionsUI = (props: any) => {
367
433
  />
368
434
  </View>
369
435
  )}
370
-
436
+ {/** Stripe connect add cards */}
371
437
  <OModal
372
438
  entireModal
373
439
  title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
@@ -7,7 +7,7 @@ import { Wrapper } from './styles'
7
7
 
8
8
  import { PhoneInputParams } from '../../types';
9
9
  import { OIcon, OText } from '../shared';
10
- import { transformCountryCode } from '../../utils'
10
+ import { findExitingCode, transformCountryCode } from '../../utils'
11
11
 
12
12
  export const PhoneInputNumber = (props: PhoneInputParams) => {
13
13
  const {
@@ -24,7 +24,8 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
24
24
  noDropIcon,
25
25
  isDisabled,
26
26
  isStartValidation,
27
- changeCountry
27
+ changeCountry,
28
+ updateStateWithSubmit
28
29
  } = props
29
30
 
30
31
  const theme = useTheme();
@@ -95,6 +96,19 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
95
96
  }
96
97
  }, [userphoneNumber])
97
98
 
99
+ useEffect(() => {
100
+ if (defaultValue && updateStateWithSubmit) {
101
+ phoneInput.current?.setState({
102
+ number: defaultValue,
103
+ countryCode: defaultCode ?
104
+ !isNaN(defaultCode)
105
+ ? transformCountryCode(defaultCode)
106
+ : findExitingCode(defaultCode)
107
+ : findExitingCode(configs?.default_country_code?.value?.toUpperCase())
108
+ })
109
+ }
110
+ }, [defaultValue])
111
+
98
112
  return (
99
113
  <Wrapper onPress={() => forwardRef?.current?.focus?.()}>
100
114
  {(isStartValidation && userphoneNumber === '') && (
@@ -112,8 +126,8 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
112
126
  defaultCode={defaultCode ?
113
127
  !isNaN(defaultCode)
114
128
  ? transformCountryCode(defaultCode)
115
- : defaultCode
116
- : configs?.default_country_code?.value}
129
+ : findExitingCode(defaultCode)
130
+ : findExitingCode(configs?.default_country_code?.value?.toUpperCase())}
117
131
  onChangeFormattedText={(text: string) => handleChangeNumber(text)}
118
132
  withDarkTheme
119
133
  onChangeCountry={(country) => changeCountry?.(country)}