ordering-ui-react-native 0.17.87 → 0.17.88-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 +33 -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/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 +8 -8
  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 -52
  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 -46
  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 +88 -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 +37 -26
  159. package/themes/original/src/components/SingleProductCard/styles.tsx +9 -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
@@ -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)}
@@ -9,8 +9,7 @@ import {
9
9
  I18nManager,
10
10
  SafeAreaView,
11
11
  Platform,
12
- Button,
13
- Vibration
12
+ Button
14
13
  } from 'react-native';
15
14
  import {
16
15
  ProductForm as ProductOptions,
@@ -19,8 +18,11 @@ import {
19
18
  useOrder,
20
19
  useUtils,
21
20
  ToastType,
22
- useToast
21
+ useToast,
22
+ useConfig,
23
+ useEvent
23
24
  } from 'ordering-components/native';
25
+ import uuid from 'react-native-uuid';
24
26
  import { useTheme } from 'styled-components/native';
25
27
  import { ProductIngredient } from '../ProductIngredient';
26
28
  import { ProductOption } from '../ProductOption';
@@ -28,6 +30,7 @@ import Swiper from 'react-native-swiper'
28
30
  import FastImage from 'react-native-fast-image';
29
31
  import IconAntDesign from 'react-native-vector-icons/AntDesign';
30
32
  import YoutubePlayer from "react-native-youtube-iframe"
33
+ import ReactNativeHapticFeedback from "react-native-haptic-feedback";
31
34
 
32
35
  import {
33
36
  WrapHeader,
@@ -52,6 +55,7 @@ import { ProductOptionSubOption } from '../ProductOptionSubOption';
52
55
  import { NotFoundSource } from '../NotFoundSource';
53
56
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
54
57
  import NavBar from '../NavBar';
58
+ import { orderTypeList, vibrateApp } from '../../utils';
55
59
  const windowWidth = Dimensions.get('window').width;
56
60
 
57
61
  export const ProductOptionsUI = (props: any) => {
@@ -71,13 +75,16 @@ export const ProductOptionsUI = (props: any) => {
71
75
  handleChangeSuboptionState,
72
76
  handleChangeCommentState,
73
77
  productObject,
74
- productAddedToCartLength
78
+ productAddedToCartLength,
79
+ actionStatus,
80
+ handleCreateGuestUser
75
81
  } = props;
76
82
 
77
83
  const theme = useTheme();
78
84
  const [, { showToast }] = useToast()
85
+ const [events] = useEvent()
79
86
 
80
- const isChewLayout = theme?.header?.components?.layout?.type === 'chew'
87
+ const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
81
88
 
82
89
  const styles = StyleSheet.create({
83
90
  mainContainer: {
@@ -130,7 +137,9 @@ export const ProductOptionsUI = (props: any) => {
130
137
  },
131
138
  slide1: {
132
139
  flex: 1,
133
- alignItems: 'center'
140
+ alignItems: 'center',
141
+ width: '100%',
142
+ marginLeft: 32
134
143
  },
135
144
  mainSwiper: {
136
145
  height: 258,
@@ -169,7 +178,7 @@ export const ProductOptionsUI = (props: any) => {
169
178
  marginTop: 10
170
179
  },
171
180
  wrapperNavbar: {
172
- paddingHorizontal: 40,
181
+ paddingHorizontal: 30,
173
182
  paddingTop: 0,
174
183
  }
175
184
  });
@@ -178,6 +187,7 @@ export const ProductOptionsUI = (props: any) => {
178
187
  const [, t] = useLanguage();
179
188
  const [orderState] = useOrder();
180
189
  const [{ auth }] = useSession();
190
+ const [{ configs }] = useConfig()
181
191
  const { product, loading, error } = productObject;
182
192
  const [gallery, setGallery] = useState([])
183
193
  const [thumbsSwiper, setThumbsSwiper] = useState(0)
@@ -197,6 +207,19 @@ export const ProductOptionsUI = (props: any) => {
197
207
  const [summaryRefHeight, setSummaryRefHeight] = useState(0)
198
208
  const [isScrollAvailable, setIsScrollAvailable] = useState(null)
199
209
  const [editionsLayoutY, setEditionsLayoutY] = useState(null)
210
+ const [viewedProduct, setViewedProduct] = useState<any>(null)
211
+ const [showTitle, setShowTitle] = useState(false)
212
+
213
+ const guestCheckoutEnabled = configs?.guest_checkout_enabled?.value === '1'
214
+ const orderTypeEnabled = !orderTypeList[orderState?.options?.type - 1] || configs?.allowed_order_types_guest_checkout?.value?.includes(orderTypeList[orderState?.options?.type - 1])
215
+
216
+ const vibrateApp = (impact?: string) => {
217
+ const options = {
218
+ enableVibrateFallback: true,
219
+ ignoreAndroidSystemSettings: false
220
+ };
221
+ ReactNativeHapticFeedback.trigger(impact || "impactLight", options);
222
+ }
200
223
 
201
224
  const isError = (id: number) => {
202
225
  let bgColor = theme.colors.white;
@@ -213,7 +236,7 @@ export const ProductOptionsUI = (props: any) => {
213
236
  };
214
237
 
215
238
  const handleSaveProduct = () => {
216
- Vibration.vibrate()
239
+ vibrateApp()
217
240
  if (!productCart.quantity) {
218
241
  showToast(ToastType.Error, t('VALIDATION_ERROR_REQUIRED', 'The quantity field is required').replace('_attribute_', t('PRODUCT_POTIONS_QUANTITY', 'Quantity')))
219
242
  return
@@ -294,6 +317,11 @@ export const ProductOptionsUI = (props: any) => {
294
317
  }
295
318
  }
296
319
 
320
+ const handleUpdateGuest = () => {
321
+ const guestToken = uuid.v4()
322
+ if (guestToken) handleCreateGuestUser({ guest_token: guestToken })
323
+ }
324
+
297
325
  const handleOnLayout = (event: any, optionId: any) => {
298
326
  const _optionLayout = { ...optionLayout }
299
327
  const optionKey = 'id:' + optionId
@@ -345,12 +373,8 @@ export const ProductOptionsUI = (props: any) => {
345
373
  </>
346
374
  );
347
375
 
348
- const handleScroll = ({ nativeEvent: { contentOffset, layoutMeasurement } }: any) => {
349
-
350
- const _topOption = Object.keys(optionLayout).find(((option: any) => Math.abs(contentOffset?.y - layoutMeasurement?.height - optionLayout[option]?.y) < 20))
351
- if (_topOption) {
352
- const _topOptionId = Number(_topOption.replace('id:', ''))
353
- }
376
+ const handleScroll = ({ nativeEvent: { contentOffset } }: any) => {
377
+ setShowTitle(contentOffset.y > 30)
354
378
  }
355
379
 
356
380
  const handleGoBack = navigation?.canGoBack()
@@ -467,14 +491,27 @@ export const ProductOptionsUI = (props: any) => {
467
491
  : t('LOGIN_SIGNUP', 'Login / Sign Up')
468
492
  }
469
493
  imgRightSrc=""
470
- textStyle={{ color: theme.colors.primary, fontSize: 14 }}
494
+ textStyle={{ color: theme.colors.primary, fontSize: 13, textAlign: 'center' }}
471
495
  style={{
472
- height: 44,
496
+ height: 42,
473
497
  borderColor: theme.colors.primary,
474
498
  backgroundColor: theme.colors.white,
499
+ paddingLeft: 0,
500
+ paddingRight: 0
475
501
  }}
476
502
  />
477
503
  )}
504
+ {!auth && guestCheckoutEnabled && orderTypeEnabled && (
505
+ <TouchableOpacity style={{ marginTop: 10 }} onPress={handleUpdateGuest}>
506
+ {actionStatus?.loading ? (
507
+ <Placeholder Animation={Fade}>
508
+ <PlaceholderLine height={20} />
509
+ </Placeholder>
510
+ ) : (
511
+ <OText color={theme.colors.primary} size={13} style={{ textAlign: 'center' }}>{t('AS_GUEST_USER', 'As guest user')}</OText>
512
+ )}
513
+ </TouchableOpacity>
514
+ )}
478
515
  </View>
479
516
  )
480
517
  }
@@ -488,21 +525,43 @@ export const ProductOptionsUI = (props: any) => {
488
525
  }
489
526
  }, [])
490
527
 
528
+ useEffect(() => {
529
+ if (!product?.id || product?.id === viewedProduct?.id) return
530
+ setViewedProduct(product)
531
+ events.emit('product_viewed', product)
532
+ }, [product?.id, viewedProduct])
533
+
491
534
  return (
492
535
  <SafeAreaView style={{ flex: 1 }}>
493
536
  <View style={styles.wrapperNavbar}>
494
- <NavBar
495
- onActionLeft={() => handleGoBack()}
496
- showCall={false}
497
- btnStyle={{ paddingLeft: 0 }}
498
- paddingTop={4}
499
- />
537
+ <TopHeader>
538
+ <>
539
+ <TopActions onPress={() => handleGoBack()}>
540
+ <IconAntDesign
541
+ name='arrowleft'
542
+ size={26}
543
+ />
544
+ </TopActions>
545
+ {showTitle && (
546
+ <OText
547
+ size={16}
548
+ style={{ flex: 1, textAlign: 'center' }}
549
+ weight={Platform.OS === 'ios' ? '600' : 'bold'}
550
+ numberOfLines={2}
551
+ ellipsizeMode='tail'
552
+ >
553
+ {product?.name}
554
+ </OText>
555
+ )}
556
+ </>
557
+ </TopHeader>
500
558
  </View>
501
559
  {!error && (
502
560
  <ScrollView
503
561
  ref={scrollViewRef}
504
562
  contentContainerStyle={{ paddingBottom: 80 }}
505
563
  stickyHeaderIndices={[2]}
564
+ scrollEventThrottle={100}
506
565
  onScroll={handleScroll}
507
566
  >
508
567
  <WrapHeader onLayout={(event: any) => setHeaderRefHeight(event.nativeEvent.layout?.height)}>
@@ -630,7 +689,7 @@ export const ProductOptionsUI = (props: any) => {
630
689
  )}
631
690
  </WrapHeader>
632
691
  <ProductSummary
633
- ph={isChewLayout ? 20 : 40}
692
+ ph={isChewLayout ? 20 : 30}
634
693
  onLayout={(event: any) => setSummaryRefHeight(event.nativeEvent.layout?.height)}
635
694
  >
636
695
  <ProductTitle>
@@ -700,6 +759,7 @@ export const ProductOptionsUI = (props: any) => {
700
759
  </ProductDescription>
701
760
  <ScrollView
702
761
  horizontal
762
+ scrollEventThrottle={100}
703
763
  showsHorizontalScrollIndicator={false}
704
764
  contentContainerStyle={{ paddingBottom: 30 }}
705
765
  >
@@ -727,12 +787,13 @@ export const ProductOptionsUI = (props: any) => {
727
787
  {(!loading && product) && (
728
788
  <ExtraOptionWrap
729
789
  horizontal
790
+ scrollEventThrottle={100}
730
791
  showsHorizontalScrollIndicator={false}
731
792
  style={{
732
793
  marginBottom: 20,
733
794
  borderBottomWidth: 1,
734
795
  borderBottomColor: theme.colors.border,
735
- marginHorizontal: isChewLayout ? 20 : 30,
796
+ marginHorizontal: 20,
736
797
  backgroundColor: theme.colors.backgroundPage,
737
798
  }}
738
799
  >
@@ -806,7 +867,7 @@ export const ProductOptionsUI = (props: any) => {
806
867
  </>
807
868
  ) : (
808
869
  <ProductEditions
809
- style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}
870
+ style={{ paddingHorizontal: isChewLayout ? 20 : 30 }}
810
871
  onLayout={(event: any) => {
811
872
  setEditionsLayoutY(event.nativeEvent.layout?.y)
812
873
  }}
@@ -853,12 +914,7 @@ export const ProductOptionsUI = (props: any) => {
853
914
  }}>
854
915
  {option?.suboptions?.sort((a: any, b: any) => a.rank - b.rank).map(
855
916
  (suboption: any) => {
856
- const currentState =
857
- productCart.options[
858
- `id:${option.id}`
859
- ]?.suboptions[
860
- `id:${suboption.id}`
861
- ] || {};
917
+ const currentState = productCart.options[`id:${option.id}`]?.suboptions[`id:${suboption.id}`] || {};
862
918
  const balance =
863
919
  productCart.options[
864
920
  `id:${option.id}`
@@ -873,6 +929,7 @@ export const ProductOptionsUI = (props: any) => {
873
929
  balance={balance}
874
930
  option={option}
875
931
  suboption={suboption}
932
+ image={suboption.image}
876
933
  state={currentState}
877
934
  disabled={
878
935
  isSoldOut ||
@@ -8,8 +8,8 @@ export const WrapHeader = styled.View`
8
8
  export const TopActions = styled.TouchableOpacity`
9
9
  height: 60px;
10
10
  justify-content: center;
11
- padding-horizontal: 30px;
12
- width: 100px;
11
+ min-width: 30px;
12
+ padding-right: 15px;
13
13
  `;
14
14
 
15
15
  export const TopHeader = styled.View`
@@ -70,7 +70,7 @@ export const ProductActions = styled.View`
70
70
  position: absolute;
71
71
  bottom: 0px;
72
72
  padding-top: ${(props: any) => props.ios ? '20px' : '0'};
73
- padding-horizontal: 40px;
73
+ padding-horizontal: 30px;
74
74
  padding-vertical: 20px;
75
75
  width: 100%;
76
76
  flex-direction: ${(props: any) => props.isColumn ? 'column' : 'row'};
@@ -77,6 +77,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
77
77
  const [isServiceOpen, setIsServiceOpen] = useState(false)
78
78
  // const [setHeight, setHeightState] = useState({ height: new Animated.Value(0) })
79
79
  // const [setRotate, setRotateState] = useState({ angle: new Animated.Value(0) })
80
+ const [productQuantity, setProductQuantity] = useState(product.quantity.toString())
80
81
 
81
82
  const productInfo = () => {
82
83
  if (isCartProduct) {
@@ -107,19 +108,20 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
107
108
  /* const toggleAccordion = () => {
108
109
  if ((!product?.valid_menu && isCartProduct)) return
109
110
  if (isActive) {
110
- Animated.timing(setHeight.height, {
111
+ Animated.timing(setHeight.height, {
111
112
  toValue: 100,
112
113
  duration: 500,
113
114
  easing: Easing.linear,
114
115
  useNativeDriver: false,
115
- }).start()
116
+ }).start()
116
117
  } else {
117
- setHeightState({height: new Animated.Value(0)})
118
+ setHeightState({height: new Animated.Value(0)})
118
119
  }
119
120
  }*/
120
121
 
121
122
  const handleChangeQuantity = (value: string) => {
122
123
  if (!orderState.loading) {
124
+ setProductQuantity(value)
123
125
  if (parseInt(value) === 0) {
124
126
  onDeleteProduct && onDeleteProduct(product)
125
127
  } else {
@@ -134,7 +136,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
134
136
  }
135
137
 
136
138
  /*useEffect(() => {
137
- toggleAccordion()
139
+ toggleAccordion()
138
140
  }, [isActive])*/
139
141
 
140
142
  const productOptions = getProductMax && [...Array(getProductMax(product) + 1),].map((_: any, opt: number) => {
@@ -209,7 +211,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
209
211
  <RNPickerSelect
210
212
  items={productOptions}
211
213
  onValueChange={handleChangeQuantity}
212
- value={product.quantity.toString()}
214
+ value={productQuantity}
213
215
  style={pickerStyle}
214
216
  useNativeAndroidPickerStyle={false}
215
217
  placeholder={{}}
@@ -287,7 +289,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
287
289
  )}
288
290
  {productInfo().options.length > 0 && (
289
291
  <ProductOptionsList>
290
- {productInfo().options.map((option: any, i: number) => (
292
+ {productInfo().options.sort((a: any, b: any) => a.rank - b.rank).map((option: any, i: number) => (
291
293
  <ProductOption key={option.id + i}>
292
294
  <OText size={10} color={theme.colors.textSecondary}>{option.name}</OText>
293
295
  {option.suboptions.map((suboption: any) => (