ordering-ui-react-native 0.18.62 → 0.18.64

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.18.62",
3
+ "version": "0.18.64",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -25,9 +25,9 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
25
25
  const [{ configs }] = useConfig()
26
26
  const applePay = ['global_apple_pay', 'apple_pay']
27
27
  const googlePay = ['global_google_pay', 'google_pay']
28
+
28
29
  useEffect(() => {
29
30
  if (Platform.OS === 'ios') {
30
- setErrors(t('GOOGLE_PAY_NOT_SUPPORTED', 'Google pay not supported'))
31
31
  setMethodPaySupported({
32
32
  enabled: false,
33
33
  loading: false
@@ -78,7 +78,7 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
78
78
  setPlaceByMethodPay(false)
79
79
  }
80
80
  }
81
- if (googlePay.includes(paymethod)) {
81
+ if (googlePay.includes(paymethod) && !methodPaySupported?.enabled) {
82
82
  initialize();
83
83
  }
84
84
  }, [initGooglePay, paymethod]);
@@ -87,9 +87,8 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
87
87
  if (applePay.includes(paymethod) && !paymethod) return
88
88
  if (Platform.OS === 'android') {
89
89
  setPlaceByMethodPay(false)
90
- setErrors(t('APPLE_PAY_NOT_SUPPORTED', 'Apple pay not supported'))
91
90
  setMethodPaySupported({
92
- enabled: false,
91
+ ...methodPaySupported,
93
92
  loading: false
94
93
  })
95
94
  return
@@ -111,7 +110,6 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
111
110
  enabled: true,
112
111
  loading: false
113
112
  })
114
- return;
115
113
  } else if (paymentMethod) {
116
114
  setMethodPaySupported({
117
115
  enabled: true,
@@ -14,7 +14,8 @@ import { OIcon, OText } from '../shared';
14
14
  import { Dimensions, StyleSheet, View } from 'react-native';
15
15
  import { InView } from 'react-native-intersection-observer'
16
16
  import { BusinessControllerParams } from '../../types';
17
- import { convertHoursToMinutes, lightenDarkenColor, shape, vibrateApp } from '../../utils';
17
+ import { convertHoursToMinutes, lightenDarkenColor, shape } from '../../utils';
18
+ import ReactNativeHapticFeedback from "react-native-haptic-feedback";
18
19
 
19
20
  import {
20
21
  BusinessHero,
@@ -151,6 +152,14 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
151
152
  return _types.join(', ');
152
153
  };
153
154
 
155
+ const vibrateApp = (impact?: string) => {
156
+ const options = {
157
+ enableVibrateFallback: true,
158
+ ignoreAndroidSystemSettings: false
159
+ };
160
+ ReactNativeHapticFeedback.trigger(impact || "impactLight", options);
161
+ }
162
+
154
163
  const handleBusinessClick = (selectedBusiness: any) => {
155
164
  vibrateApp()
156
165
  if (business?.open) handleClick && handleClick(selectedBusiness)
@@ -26,6 +26,7 @@ import { _retrieveStoreData, _removeStoreData } from '../../providers/StoreUtil'
26
26
  import IconAntDesign from 'react-native-vector-icons/AntDesign';
27
27
  import { useIsFocused } from '@react-navigation/native';
28
28
  import AntDesignIcon from 'react-native-vector-icons/AntDesign'
29
+ import ReactNativeHapticFeedback from "react-native-haptic-feedback";
29
30
 
30
31
  import {
31
32
  TopHeader,
@@ -44,7 +45,6 @@ import { ProfessionalFilter } from '../ProfessionalFilter';
44
45
  import { ServiceForm } from '../ServiceForm';
45
46
  import { BusinessesListing } from '../BusinessesListing/Layout/Original'
46
47
  import { PageBanner } from '../PageBanner'
47
- import { vibrateApp } from '../../utils';
48
48
 
49
49
  const PIXELS_TO_SCROLL = 2000
50
50
 
@@ -147,11 +147,18 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
147
147
  const currentCart: any = Object.values(orderState.carts).find((cart: any) => cart?.business?.slug === business?.slug) ?? {}
148
148
  const isOpenFiltProducts = isOpenSearchBar && !!searchValue
149
149
  const filtProductsHeight = Platform.OS === 'ios' ? 165 : 100
150
- const viewOrderButtonVisible = !loading && auth && currentCart?.products?.length > 0 && categoryState.products.length !== 0
150
+ const viewOrderButtonVisible = !loading && auth && currentCart?.products?.length > 0 && categoryState.products.length !== 0
151
151
 
152
152
  const onRedirect = (route: string, params?: any) => {
153
153
  navigation.navigate(route, params)
154
154
  }
155
+ const vibrateApp = (impact?: string) => {
156
+ const options = {
157
+ enableVibrateFallback: true,
158
+ ignoreAndroidSystemSettings: false
159
+ };
160
+ ReactNativeHapticFeedback.trigger(impact || "impactLight", options);
161
+ }
155
162
  const onProductClick = async (product: any) => {
156
163
  if (product.ingredients?.length === 0 && product.extras.length === 0 && !product.inventoried && auth && isQuickAddProduct) {
157
164
  const isProductAddedToCart = currentCart?.products?.find((Cproduct: any) => Cproduct.id === product.id)
@@ -315,7 +322,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
315
322
  }
316
323
  }, [isFocused])
317
324
 
318
-
325
+
319
326
  useEffect(() => {
320
327
  function onKeyboardDidShow(e: KeyboardEvent) {
321
328
  setKeyboardHeight(e?.endCoordinates?.height);
@@ -395,7 +402,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
395
402
  <>
396
403
  {!(businessSingleId && auth) && (
397
404
  <TopActions onPress={() => handleBackNavigation()}>
398
- <AntDesignIcon
405
+ <AntDesignIcon
399
406
  name='arrowleft'
400
407
  size={26}
401
408
  />
@@ -3,6 +3,7 @@ import { View, StyleSheet, TouchableOpacity, Platform, I18nManager, ScrollView }
3
3
  import { initStripe, useConfirmPayment } from '@stripe/stripe-react-native';
4
4
  import Picker from 'react-native-country-picker-modal';
5
5
  import MaterialIcons from 'react-native-vector-icons/MaterialIcons'
6
+ import ReactNativeHapticFeedback from "react-native-haptic-feedback";
6
7
  import {
7
8
  Checkout as CheckoutController,
8
9
  useOrder,
@@ -52,7 +53,7 @@ import { FloatingButton } from '../FloatingButton';
52
53
  import { Container } from '../../layouts/Container';
53
54
  import NavBar from '../NavBar';
54
55
  import { OrderSummary } from '../OrderSummary';
55
- import { getTypesText, vibrateApp } from '../../utils';
56
+ import { getTypesText } from '../../utils';
56
57
  import { CartStoresListing } from '../CartStoresListing';
57
58
  import { PaymentOptionsWebView } from '../../../../../src/components/PaymentOptionsWebView';
58
59
 
@@ -211,6 +212,14 @@ const CheckoutUI = (props: any) => {
211
212
  }
212
213
  }
213
214
 
215
+ const vibrateApp = (impact?: string) => {
216
+ const options = {
217
+ enableVibrateFallback: true,
218
+ ignoreAndroidSystemSettings: false
219
+ };
220
+ ReactNativeHapticFeedback.trigger(impact || "impactLight", options);
221
+ }
222
+
214
223
  const handleSuccessSignup = (user: any) => {
215
224
  login({
216
225
  user,
@@ -77,7 +77,7 @@ export const GPSButton = (props: any) => {
77
77
  useEffect(() => {
78
78
  if (isIntGeoCoder) return
79
79
  Geocoder.init(apiKey);
80
- }, [])
80
+ }, [isIntGeoCoder])
81
81
 
82
82
  return (
83
83
  <GpsButtonStyle
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from 'react'
1
+ import React, { useEffect, useState } from 'react'
2
2
  import {
3
3
  useLanguage, useUtils, RedeemGiftCard as RedeemGiftCardController
4
4
  } from 'ordering-components/native'
@@ -26,6 +26,8 @@ const RedeemGiftCardUI = (props: any) => {
26
26
  const { handleSubmit, control, errors } = useForm()
27
27
  const [{ parsePrice }] = useUtils()
28
28
 
29
+ const [codeValue, setCodeValue] = useState('')
30
+
29
31
  const style = StyleSheet.create({
30
32
  btnStyle: {
31
33
  borderRadius: 7.6,
@@ -43,6 +45,14 @@ const RedeemGiftCardUI = (props: any) => {
43
45
  handleApply(values)
44
46
  }
45
47
 
48
+ const handleChangeCode = (string: any) => {
49
+ string = string.replace(/-/g, '')
50
+ if (!string) return
51
+ const codeSlices = string.match(/.{1,4}/g)
52
+ string = codeSlices.join('-')
53
+ setCodeValue(string)
54
+ }
55
+
46
56
  useEffect(() => {
47
57
  if (Object.keys(errors).length > 0) {
48
58
  const list = Object.values(errors)
@@ -90,9 +100,12 @@ const RedeemGiftCardUI = (props: any) => {
90
100
  control={control}
91
101
  render={({ onChange, value }: any) => (
92
102
  <OInput
93
- placeholder='0000 0000'
94
- value={value}
95
- onChange={(val: any) => onChange(val)}
103
+ placeholder='XXXX-XXXX-XXXX-XXXX'
104
+ value={codeValue}
105
+ onChange={(val: any) => {
106
+ onChange(val)
107
+ handleChangeCode(val)
108
+ }}
96
109
  autoCapitalize='none'
97
110
  autoCorrect={false}
98
111
  blurOnSubmit={false}
@@ -6,6 +6,7 @@ import { PhoneInputNumber } from '../PhoneInputNumber';
6
6
  import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
7
7
  import Recaptcha from 'react-native-recaptcha-that-works'
8
8
  import ReCaptcha from '@fatnlazycat/react-native-recaptcha-v3'
9
+ import ReactNativeHapticFeedback from "react-native-haptic-feedback";
9
10
 
10
11
  import {
11
12
  LoginForm as LoginFormController,
@@ -45,7 +46,6 @@ import { AppleLogin } from '../AppleLogin';
45
46
  import { Otp } from './Otp'
46
47
  import { TouchableOpacity } from 'react-native-gesture-handler';
47
48
  import Alert from '../../../../../src/providers/AlertProvider'
48
- import { vibrateApp } from '../../utils';
49
49
 
50
50
  const LoginFormUI = (props: LoginParams) => {
51
51
  const {
@@ -162,6 +162,14 @@ const LoginFormUI = (props: LoginParams) => {
162
162
  handleCategoryScroll(otpType ? `${val}_${otpType}` : val)
163
163
  };
164
164
 
165
+ const vibrateApp = (impact?: string) => {
166
+ const options = {
167
+ enableVibrateFallback: true,
168
+ ignoreAndroidSystemSettings: false
169
+ };
170
+ ReactNativeHapticFeedback.trigger(impact || "impactLight", options);
171
+ }
172
+
165
173
  const onSubmit = (values?: any) => {
166
174
  Keyboard.dismiss();
167
175
  if (loginTab === 'otp') {
@@ -170,7 +178,7 @@ const LoginFormUI = (props: LoginParams) => {
170
178
  vibrateApp()
171
179
  return
172
180
  }
173
- if(!values?.cellphone && otpType === 'cellphone'){
181
+ if (!values?.cellphone && otpType === 'cellphone') {
174
182
  showToast(ToastType.Error, t('PHONE_NUMBER_REQUIRED', 'Phone number is required'));
175
183
  return
176
184
  }
@@ -259,7 +267,7 @@ const LoginFormUI = (props: LoginParams) => {
259
267
  const handleLoginOtp = async (code: string) => {
260
268
  if (!code) return
261
269
  const logged = await handleButtonLoginClick({ code })
262
- if (logged){
270
+ if (logged) {
263
271
  setWillVerifyOtpState(false)
264
272
  } else {
265
273
  setAlertState({
@@ -13,6 +13,7 @@ import { getIconCard, flatArray } from '../../utils'
13
13
  import { StripeElementsForm } from '../StripeElementsForm'
14
14
  import { StripeCardsList } from '../StripeCardsList'
15
15
  import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
16
+ import { useApplePay } from '@stripe/stripe-react-native';
16
17
 
17
18
  import {
18
19
  PMContainer,
@@ -44,6 +45,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
44
45
  const [, t] = useLanguage()
45
46
  const [{ configs }] = useConfig()
46
47
  const [{ parsePrice }] = useUtils()
48
+ const { confirmApplePayPayment } = useApplePay()
47
49
 
48
50
  const [addCardOpen, setAddCardOpen] = useState({ stripe: false, stripeConnect: false });
49
51
 
@@ -92,7 +94,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
92
94
  if (methodsPay.includes(paymethodSelected?.gateway)) {
93
95
  if (typeof paymethodSelected?.paymethod_data === 'string'){
94
96
  const sourceId = JSON.parse(paymethodSelected?.paymethod_data)?.source_id
95
- sourceId && handlePlaceOrder()
97
+ sourceId && handlePlaceOrder(confirmApplePayPayment)
96
98
  }
97
99
  }
98
100
  }, [JSON.stringify(paymethodSelected)])
@@ -100,7 +102,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
100
102
  const renderPaymethods = ({ item }: any) => {
101
103
  return (
102
104
  <>
103
- {item?.gateway === 'apple_pay' ? (
105
+ {item?.gateway === 'global_apple_pay' ? (
104
106
  <TouchableOpacity
105
107
  onPress={() => handleSelectPaymethod({ ...item, paymethod: { gateway: item.gateway }, paymethod_id: item?.id })}
106
108
  >
@@ -123,7 +125,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
123
125
  src={getPayIcon(item?.gateway ?? item.paymethod?.gateway)}
124
126
  width={20}
125
127
  height={20}
126
- color={item?.gateway === 'apple_pay' ? '' : paymethodSelected?.id === item.id ? theme.colors.white : theme.colors.backgroundDark}
128
+ color={item?.gateway === 'global_apple_pay' ? '' : paymethodSelected?.id === item.id ? theme.colors.white : theme.colors.backgroundDark}
127
129
  />
128
130
  <OText
129
131
  size={10}
@@ -177,9 +177,9 @@ const MultiCheckoutUI = (props: any) => {
177
177
  setPhoneUpdate(val)
178
178
  }
179
179
 
180
- const handlePlaceOrder = () => {
180
+ const handlePlaceOrder = (confirmPayment ?: any) => {
181
181
  if (!userErrors.length) {
182
- handleGroupPlaceOrder && handleGroupPlaceOrder()
182
+ handleGroupPlaceOrder && handleGroupPlaceOrder(confirmPayment)
183
183
  return
184
184
  }
185
185
  let stringError = ''
@@ -12,14 +12,31 @@ export const OrderEta = (props: any) => {
12
12
  const [estimatedDeliveryTime, setEstimatedDeliveryTime] = useState(null)
13
13
 
14
14
  const getEstimatedDeliveryTime = () => {
15
- let _estimatedTime = null
15
+ let estimatedUtcTime = null
16
16
  let totalEta = 0
17
+ if (order?.delivered_in) totalEta += order?.delivered_in
18
+ if (order?.prepared_in) totalEta += order?.prepared_in
19
+ if (order?.delivery_type === 1 && order?.eta_drive_time) {
20
+ totalEta += order?.eta_drive_time
21
+ }
22
+
17
23
  const _delivery = order?.delivery_datetime_utc
18
24
  ? order?.delivery_datetime_utc
19
25
  : order?.delivery_datetime
26
+
20
27
  if (order?.eta_current_status_time) {
21
28
  const currentStatueEta = order?.eta_current_status_time
22
29
  totalEta += currentStatueEta
30
+ let previousStatusTimes = 0
31
+ if (order?.eta_previous_status_times) {
32
+ Object.keys(order.eta_previous_status_times).map(key => {
33
+ if (!key.includes('status_penalty')) {
34
+ previousStatusTimes += order.eta_previous_status_times[key]
35
+ }
36
+ })
37
+ }
38
+ totalEta += previousStatusTimes
39
+
23
40
  let nextStatusTimes = 0
24
41
  if (order?.eta_next_status_times) {
25
42
  Object.keys(order.eta_next_status_times).map(key => {
@@ -28,7 +45,6 @@ export const OrderEta = (props: any) => {
28
45
  }
29
46
  })
30
47
  }
31
-
32
48
  totalEta += nextStatusTimes
33
49
 
34
50
  const diffTimeAsSeconds = moment.utc(order?.reporting_data?.at[`status:${order.status}`]).add(order?.eta_current_status_time, 'minutes').diff(moment().utc(), 'seconds')
@@ -36,15 +52,11 @@ export const OrderEta = (props: any) => {
36
52
  if (diffTimeAsMinutes <= 0) {
37
53
  totalEta += (Math.floor(Math.abs(diffTimeAsMinutes / order?.eta_current_status_time) + 1) * order?.eta_current_status_penalty_time)
38
54
  }
39
- _estimatedTime = moment.utc(_delivery).add(totalEta, 'minutes')
40
55
  } else {
41
- let timesToAdd = 0
42
- if (order?.delivered_in) timesToAdd += order?.delivered_in
43
- if (order?.prepared_in) timesToAdd += order?.prepared_in
44
- const _etaTime = order?.eta_time + timesToAdd
45
- _estimatedTime = moment.utc(_delivery).add(_etaTime, 'minutes')
56
+ totalEta = order?.eta_time + totalEta
46
57
  }
47
- _estimatedTime = outputFormat ? moment(_estimatedTime).local().format(outputFormat) : parseDate(_estimatedTime, { utc: false })
58
+ estimatedUtcTime = moment.utc(_delivery).add(totalEta, 'minutes')
59
+ const _estimatedTime = outputFormat ? moment(estimatedUtcTime).local().format(outputFormat) : parseDate(estimatedUtcTime, { utc: false })
48
60
  setEstimatedDeliveryTime(_estimatedTime)
49
61
  }
50
62
 
@@ -30,6 +30,7 @@ import Swiper from 'react-native-swiper'
30
30
  import FastImage from 'react-native-fast-image';
31
31
  import IconAntDesign from 'react-native-vector-icons/AntDesign';
32
32
  import YoutubePlayer from "react-native-youtube-iframe"
33
+ import ReactNativeHapticFeedback from "react-native-haptic-feedback";
33
34
 
34
35
  import {
35
36
  WrapHeader,
@@ -54,7 +55,7 @@ import { ProductOptionSubOption } from '../ProductOptionSubOption';
54
55
  import { NotFoundSource } from '../NotFoundSource';
55
56
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
56
57
  import NavBar from '../NavBar';
57
- import { orderTypeList, vibrateApp } from '../../utils';
58
+ import { orderTypeList } from '../../utils';
58
59
  const windowWidth = Dimensions.get('window').width;
59
60
 
60
61
  export const ProductOptionsUI = (props: any) => {
@@ -208,7 +209,15 @@ export const ProductOptionsUI = (props: any) => {
208
209
  const [showTitle, setShowTitle] = useState(false)
209
210
 
210
211
  const guestCheckoutEnabled = configs?.guest_checkout_enabled?.value === '1'
211
- const orderTypeEnabled = !orderTypeList[orderState?.options?.type - 1] || configs?.allowed_order_types_guest_checkout?.value?.includes(orderTypeList[orderState?.options?.type - 1])
212
+ const orderTypeEnabled = !orderTypeList[orderState?.options?.type - 1] || configs?.allowed_order_types_guest_checkout?.value?.includes(orderTypeList[orderState?.options?.type - 1])
213
+
214
+ const vibrateApp = (impact?: string) => {
215
+ const options = {
216
+ enableVibrateFallback: true,
217
+ ignoreAndroidSystemSettings: false
218
+ };
219
+ ReactNativeHapticFeedback.trigger(impact || "impactLight", options);
220
+ }
212
221
 
213
222
  const isError = (id: number) => {
214
223
  let bgColor = theme.colors.white;
@@ -8,6 +8,7 @@ import { PhoneInputNumber } from '../PhoneInputNumber';
8
8
  import { FacebookLogin } from '../FacebookLogin';
9
9
  import Recaptcha from 'react-native-recaptcha-that-works'
10
10
  import ReCaptcha from '@fatnlazycat/react-native-recaptcha-v3'
11
+ import ReactNativeHapticFeedback from "react-native-haptic-feedback";
11
12
 
12
13
  import {
13
14
  SignupForm as SignUpController,
@@ -37,7 +38,7 @@ import Alert from '../../../../../src/providers/AlertProvider'
37
38
  import { OText, OButton, OInput } from '../shared';
38
39
  import { OModal } from '../../../../../src/components/shared';
39
40
  import { SignupParams } from '../../types';
40
- import { sortInputFields, vibrateApp } from '../../utils';
41
+ import { sortInputFields } from '../../utils';
41
42
  import { GoogleLogin } from '../GoogleLogin';
42
43
  import { AppleLogin } from '../AppleLogin';
43
44
 
@@ -164,6 +165,14 @@ const SignupFormUI = (props: SignupParams) => {
164
165
  })
165
166
  }
166
167
 
168
+ const vibrateApp = (impact?: string) => {
169
+ const options = {
170
+ enableVibrateFallback: true,
171
+ ignoreAndroidSystemSettings: false
172
+ };
173
+ ReactNativeHapticFeedback.trigger(impact || "impactLight", options);
174
+ }
175
+
167
176
  const handleRefs = (ref: any, code: string) => {
168
177
  switch (code) {
169
178
  case 'name': {
@@ -260,9 +260,13 @@ const WalletsUI = (props: any) => {
260
260
  </OText>
261
261
  </BalanceElement>
262
262
 
263
- <View style={styles.dividerStyle} />
264
- <GiftCardUI navigation={navigation} />
265
- <View style={styles.dividerStyle} />
263
+ {currentWalletSelected?.type === 'cash' && (
264
+ <>
265
+ <View style={styles.dividerStyle} />
266
+ <GiftCardUI navigation={navigation} />
267
+ <View style={styles.dividerStyle} />
268
+ </>
269
+ )}
266
270
 
267
271
  {!isChewLayout && (
268
272
  <WalletTransactions
@@ -4,7 +4,6 @@ import FontAwesome from 'react-native-vector-icons/FontAwesome';
4
4
  import { CODES } from 'ordering-components/native'
5
5
  import { ORDER_TYPES } from '../config/constants';
6
6
  import { useTheme } from 'styled-components/native';
7
- import ReactNativeHapticFeedback from "react-native-haptic-feedback";
8
7
 
9
8
  const [languageState, t] = useLanguage();
10
9
  const theme = useTheme()
@@ -613,13 +612,3 @@ export const lightenDarkenColor = (color: any) => {
613
612
  return false
614
613
  }
615
614
  }
616
-
617
- export const vibrateApp = (impact?: string) => {
618
- const options = {
619
- enableVibrateFallback: true,
620
- ignoreAndroidSystemSettings: false
621
- };
622
-
623
- ReactNativeHapticFeedback.trigger(impact || "impactLight", options);
624
-
625
- }