ordering-ui-react-native 0.17.65-release → 0.17.66-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.17.65-release",
3
+ "version": "0.17.66-release",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -5,20 +5,23 @@ import { useCountdownTimer } from '../../../../../../src/hooks/useCountdownTimer
5
5
  import { useLanguage } from 'ordering-components/native';
6
6
  import { OTPContainer } from './styles';
7
7
  import { OText, OButton, OIcon } from '../../shared';
8
- import OtpInputs from 'react-native-otp-inputs';
8
+ import OtpInputs, { OtpInputsRef } from 'react-native-otp-inputs';
9
9
  import { useTheme } from 'styled-components/native';
10
10
  import { otpParams } from '../../../types'
11
+ import { ActivityIndicator } from 'react-native';
11
12
 
12
13
  export const Otp = (props: otpParams) => {
13
14
  const {
15
+ pinCount,
16
+ otpError,
17
+ setOtpError,
18
+ setAlertState,
14
19
  willVerifyOtpState,
20
+ isCheckingCode,
21
+ setCheckingCode,
15
22
  setWillVerifyOtpState,
16
- onSubmit,
17
23
  handleLoginOtp,
18
- setAlertState,
19
- pinCount,
20
- otpError,
21
- setOtpError
24
+ onSubmit,
22
25
  } = props
23
26
 
24
27
  const theme = useTheme();
@@ -26,8 +29,7 @@ export const Otp = (props: otpParams) => {
26
29
  const [otpLeftTime, _, resetOtpLeftTime]: any = useCountdownTimer(
27
30
  600, willVerifyOtpState)
28
31
 
29
- const [code, setCode] = useState('')
30
- const inputRef = useRef<any>()
32
+ const inputRef = useRef<OtpInputsRef | any>(null)
31
33
 
32
34
  const handleOnSubmit = () => {
33
35
  setAlertState({
@@ -39,7 +41,12 @@ export const Otp = (props: otpParams) => {
39
41
  }
40
42
 
41
43
  const handleChangeCode = (code : string) => {
42
- setCode(code)
44
+ if (code?.length === pinCount) {
45
+ setCheckingCode(true)
46
+ handleLoginOtp(code)
47
+ inputRef.current?.reset && inputRef.current.reset()
48
+ setTimeout(() => inputRef.current?.focus && inputRef.current.focus(), 100)
49
+ }
43
50
  setOtpError(null)
44
51
  }
45
52
 
@@ -58,13 +65,6 @@ export const Otp = (props: otpParams) => {
58
65
  }
59
66
  }, [otpLeftTime])
60
67
 
61
- useEffect(() => {
62
- if (code?.length === (pinCount || 6)) {
63
- handleLoginOtp(code)
64
- inputRef?.current?.reset()
65
- }
66
- }, [code])
67
-
68
68
  const loginStyle = StyleSheet.create({
69
69
  container: {
70
70
  width: '100%',
@@ -95,6 +95,13 @@ export const Otp = (props: otpParams) => {
95
95
  width: '100%',
96
96
  flexDirection: 'row',
97
97
  alignItems: 'center'
98
+ },
99
+ checkingCode: {
100
+ height: 50,
101
+ width: '100%',
102
+ marginVertical: 30,
103
+ justifyContent: 'center',
104
+ alignItems: 'center'
98
105
  }
99
106
  });
100
107
 
@@ -116,14 +123,24 @@ export const Otp = (props: otpParams) => {
116
123
  <OText size={24}>
117
124
  {formatSeconds(otpLeftTime)}
118
125
  </OText>
119
- <OtpInputs
120
- ref={inputRef}
121
- autofillFromClipboard
122
- numberOfInputs={pinCount || 6}
123
- style={loginStyle.container}
124
- inputStyles={loginStyle.underlineStyleBase}
125
- handleChange={handleChangeCode}
126
- />
126
+ {isCheckingCode && (
127
+ <View style={loginStyle.checkingCode}>
128
+ <OText size={18}>
129
+ <ActivityIndicator size="large" color={theme.colors.primary} />
130
+ </OText>
131
+ </View>
132
+ )}
133
+ {!isCheckingCode && (
134
+ <OtpInputs
135
+ ref={inputRef}
136
+ autofillFromClipboard={false}
137
+ numberOfInputs={pinCount}
138
+ style={loginStyle.container}
139
+ returnKeyType={'done'}
140
+ inputStyles={loginStyle.underlineStyleBase}
141
+ handleChange={handleChangeCode}
142
+ />
143
+ )}
127
144
  {!!otpError && (
128
145
  <OText
129
146
  color={theme?.colors?.error}
@@ -150,3 +167,7 @@ export const Otp = (props: otpParams) => {
150
167
  </SafeAreaView>
151
168
  )
152
169
  }
170
+
171
+ Otp.defaultProps = {
172
+ pinCount: 6
173
+ }
@@ -104,6 +104,8 @@ const LoginFormUI = (props: LoginParams) => {
104
104
  const isOtpEmail = loginTab === 'otp' && otpType === 'email'
105
105
  const isOtpCellphone = loginTab === 'otp' && otpType === 'cellphone'
106
106
 
107
+ const [isCheckingCode, setCheckingCode] = useState(false)
108
+
107
109
  const googleLoginEnabled = configs?.google_login_enabled?.value === '1' || !configs?.google_login_enabled?.enabled
108
110
  const facebookLoginEnabled = configs?.facebook_login_enabled?.value === '1' || !configs?.facebook_login_enabled?.enabled
109
111
  const appleLoginEnabled = configs?.apple_login_enabled?.value === '1' || !configs?.apple_login_enabled?.enabled
@@ -268,6 +270,7 @@ const LoginFormUI = (props: LoginParams) => {
268
270
  const handleLoginOtp = async (code: string) => {
269
271
  if (!code) return
270
272
  const logged = await handleButtonLoginClick({ code })
273
+ setCheckingCode(false)
271
274
  if (logged) {
272
275
  setWillVerifyOtpState(false)
273
276
  } else {
@@ -854,6 +857,8 @@ const LoginFormUI = (props: LoginParams) => {
854
857
  animationType='slide'
855
858
  >
856
859
  <Otp
860
+ isCheckingCode={isCheckingCode}
861
+ setCheckingCode={setCheckingCode}
857
862
  willVerifyOtpState={willVerifyOtpState}
858
863
  otpError={otpError}
859
864
  setOtpError={setOtpError}
@@ -64,7 +64,8 @@ const MultiCheckoutUI = (props: any) => {
64
64
  cartGroup,
65
65
  walletState,
66
66
  onNavigationRedirectReplace,
67
- merchantId
67
+ merchantId,
68
+ cartsInvalid
68
69
  } = props
69
70
 
70
71
  const theme = useTheme();
@@ -89,7 +90,7 @@ const MultiCheckoutUI = (props: any) => {
89
90
  const isMultiDriverTips = configs?.checkout_multi_business_enabled?.value === '1'
90
91
  const walletCarts = (Object.values(carts)?.filter((cart: any) => cart?.products && cart?.products?.length && cart?.status !== 2 && cart?.valid_schedule && cart?.valid_products && cart?.valid_address && cart?.valid_maximum && cart?.valid_minimum && cart?.wallets) || null) || []
91
92
  const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
92
-
93
+ const cartsToShow = openCarts?.length > 0 ? openCarts : cartsInvalid
93
94
  const walletName: any = {
94
95
  cash: {
95
96
  name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet'),
@@ -138,7 +139,7 @@ const MultiCheckoutUI = (props: any) => {
138
139
  const isDisablePlaceOrderButton = cartGroup?.loading || (!(paymethodSelected?.paymethod_id || paymethodSelected?.wallet_id) && cartGroup?.result?.balance > 0) ||
139
140
  (paymethodSelected?.paymethod?.gateway === 'stripe' && !paymethodSelected?.paymethod_data) ||
140
141
  walletCarts.length > 0
141
- || (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading))
142
+ || (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading)) || openCarts?.length === 0
142
143
 
143
144
  const handleMomentClick = () => {
144
145
  if (isPreOrder) {
@@ -179,7 +180,7 @@ const MultiCheckoutUI = (props: any) => {
179
180
  setPhoneUpdate(val)
180
181
  }
181
182
 
182
- const handlePlaceOrder = (confirmPayment ?: any) => {
183
+ const handlePlaceOrder = (confirmPayment?: any) => {
183
184
  if (!userErrors.length) {
184
185
  handleGroupPlaceOrder && handleGroupPlaceOrder(confirmPayment)
185
186
  return
@@ -199,14 +200,14 @@ const MultiCheckoutUI = (props: any) => {
199
200
  }, [validationFields, user])
200
201
 
201
202
  useEffect(() => {
202
- if (openCarts.length === 1) {
203
+ if (cartsToShow?.length === 1) {
203
204
  onNavigationRedirectReplace('CheckoutPage', {
204
- cartUuid: openCarts[0]?.uuid,
205
+ cartUuid: cartsToShow[0]?.uuid,
205
206
  fromMulti: true
206
207
  })
207
208
  return
208
209
  }
209
- }, [openCarts])
210
+ }, [cartsToShow])
210
211
 
211
212
  useEffect(() => {
212
213
  if (walletState.error) {
@@ -221,14 +222,14 @@ const MultiCheckoutUI = (props: any) => {
221
222
  }, [cartUuid])
222
223
 
223
224
  useEffect(() => {
224
- if(paymethodSelected?.gateway === 'global_google_pay'){
225
+ if (paymethodSelected?.gateway === 'global_google_pay') {
225
226
  setMethodPaySupported({
226
227
  enabled: true,
227
228
  loading: false,
228
229
  message: null
229
230
  })
230
231
  }
231
- }, [paymethodSelected])
232
+ }, [paymethodSelected])
232
233
 
233
234
  return (
234
235
  <>
@@ -309,27 +310,27 @@ const MultiCheckoutUI = (props: any) => {
309
310
  </ChAddress>
310
311
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
311
312
  </ChSection>
312
-
313
- <ChSection>
314
- <MultiCartsPaymethodsAndWallets
315
- openCarts={openCarts}
316
- paymethodSelected={paymethodSelected}
317
- walletsPaymethod={cartGroup?.result?.wallets}
318
- handleSelectPaymethod={handleSelectPaymethod}
319
- handleSelectWallet={handleSelectWallet}
320
- handlePaymethodDataChange={handlePaymethodDataChange}
321
- cartUuid={cartUuid}
322
- merchantId={merchantId}
323
- setMethodPaySupported={setMethodPaySupported}
324
- methodPaySupported={methodPaySupported}
325
- placeByMethodPay={placeByMethodPay}
326
- setPlaceByMethodPay={setPlaceByMethodPay}
327
- cartTotal={totalCartsPrice}
328
- handlePlaceOrder={handlePlaceOrder}
329
- />
330
- <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
331
- </ChSection>
332
-
313
+ {openCarts?.length > 0 && (
314
+ <ChSection>
315
+ <MultiCartsPaymethodsAndWallets
316
+ openCarts={openCarts}
317
+ paymethodSelected={paymethodSelected}
318
+ walletsPaymethod={cartGroup?.result?.wallets}
319
+ handleSelectPaymethod={handleSelectPaymethod}
320
+ handleSelectWallet={handleSelectWallet}
321
+ handlePaymethodDataChange={handlePaymethodDataChange}
322
+ cartUuid={cartUuid}
323
+ merchantId={merchantId}
324
+ setMethodPaySupported={setMethodPaySupported}
325
+ methodPaySupported={methodPaySupported}
326
+ placeByMethodPay={placeByMethodPay}
327
+ setPlaceByMethodPay={setPlaceByMethodPay}
328
+ cartTotal={totalCartsPrice}
329
+ handlePlaceOrder={handlePlaceOrder}
330
+ />
331
+ <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
332
+ </ChSection>
333
+ )}
333
334
  {
334
335
  isMultiDriverTips &&
335
336
  options?.type === 1 &&
@@ -364,6 +365,7 @@ const MultiCheckoutUI = (props: any) => {
364
365
  validationFields?.fields?.checkout?.coupon?.enabled &&
365
366
  openCarts.every((cart: any) => cart.business_id && cart.status !== 2) &&
366
367
  configs?.multi_business_checkout_coupon_input_style?.value === 'group' &&
368
+ openCarts?.length > 0 &&
367
369
  (
368
370
  <ChSection>
369
371
  <OText size={14} lineHeight={20} color={theme.colors.textNormal}>
@@ -390,7 +392,7 @@ const MultiCheckoutUI = (props: any) => {
390
392
  {t('MOBILE_FRONT_YOUR_ORDER', 'Your order')}
391
393
  </OText>
392
394
  </CartsHeader>
393
- {openCarts.map((cart: any) => (
395
+ {cartsToShow.map((cart: any) => (
394
396
  <React.Fragment key={cart.uuid}>
395
397
  <Cart
396
398
  cart={cart}
@@ -407,7 +409,7 @@ const MultiCheckoutUI = (props: any) => {
407
409
  )}
408
410
  </React.Fragment>
409
411
  ))}
410
- {!cartGroup?.loading && openCarts.length === 0 && (
412
+ {!cartGroup?.loading && openCarts.length === 0 && cartsInvalid?.length === 0 && (
411
413
  <CCNotCarts>
412
414
  <OText size={24} style={{ textAlign: 'center' }}>
413
415
  {t('CARTS_NOT_FOUND', 'You don\'t have carts available')}
@@ -465,6 +467,7 @@ const MultiCheckoutUI = (props: any) => {
465
467
  </OText>
466
468
  </View>
467
469
  )}
470
+
468
471
  <OText size={12} color={theme.colors.mediumGray} mRight={70} style={{ marginTop: 10 }}>
469
472
  {t('MULTI_CHECKOUT_DESCRIPTION', 'You will receive a receipt for each business. The payment is not combined between multiple stores. Each payment is processed by the store')}
470
473
  </OText>
@@ -472,6 +475,14 @@ const MultiCheckoutUI = (props: any) => {
472
475
  )}
473
476
  </ChCarts>
474
477
  </ChSection>
478
+ {cartsToShow?.some((cart: any) => !cart?.valid_products && cart?.status !== 2) && (
479
+ <OText
480
+ color={theme.colors.error}
481
+ size={12}
482
+ >
483
+ {t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
484
+ </OText>
485
+ )}
475
486
  </ChContainer>
476
487
  </Container>
477
488
 
@@ -107,8 +107,12 @@ export const OrderHistory = (props: any) => {
107
107
  ellipsizeMode='tail'
108
108
  >
109
109
  {t('ORDER_PLACED', 'Order placed')} {' '}
110
- {t('VIA', 'Via')}{' '}
111
- {order.app_id ? t(order.app_id.toUpperCase(), order.app_id) : t('OTHER', 'Other')}
110
+ {!props.hideViaText && (
111
+ <>
112
+ {t('VIA', 'Via')}{' '}
113
+ {order.app_id ? t(order.app_id.toUpperCase(), order.app_id) : t('OTHER', 'Other')}
114
+ </>
115
+ )}
112
116
  </OText>
113
117
  <OText size={12}>{parseDate(order?.created_at, { outputFormat: 'MMM DD, hh:mm A' })}</OText>
114
118
  </View>
@@ -1039,6 +1039,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
1039
1039
  >
1040
1040
  <OrderHistory
1041
1041
  order={order}
1042
+ hideViaText={props.hideViaText}
1042
1043
  messages={messages}
1043
1044
  enableReview={(
1044
1045
  parseInt(order?.status) === 1 ||
@@ -147,9 +147,6 @@ const OrderProgressUI = (props: any) => {
147
147
  marginBottom: 3
148
148
  }}
149
149
  >{statusToShow.includes(lastOrder?.status) ? t('ORDER_IN_PROGRESS', 'Order in progress') : t('ORDER', 'Order')}</OText>
150
- {statusToShow.includes(lastOrder?.status) && (
151
- <OText size={11} numberOfLines={1} ellipsizeMode='tail'>{t('RESTAURANT_PREPARING_YOUR_ORDER', 'The restaurant is preparing your order')}</OText>
152
- )}
153
150
  <TouchableOpacity onPress={() => handleGoToOrder('MyOrders')}>
154
151
  <View style={styles.navigationButton}>
155
152
  <OText size={11} color={theme.colors.primary}>{t('GO_TO_MY_ORDERS', 'Go to my orders')}</OText>
@@ -437,6 +437,7 @@ export interface OrderDetailsParams {
437
437
  onNavigationRedirect?: any,
438
438
  reorderState?: any,
439
439
  handleReorder?: any,
440
+ hideViaText?: boolean,
440
441
  }
441
442
  export interface ProductItemAccordionParams {
442
443
  key?: any;
@@ -572,6 +573,9 @@ export interface BusinessPreorderParams {
572
573
  goToBack: any;
573
574
  business: any;
574
575
  handleBusinessClick: (value: any) => {};
576
+ getActualSchedule?: any;
577
+ cateringPreorder?: boolean;
578
+ preorderLeadTime?: number
575
579
  }
576
580
  export interface BusinessMenuListParams {
577
581
  menu: any;
@@ -720,6 +724,8 @@ export interface otpParams {
720
724
  pinCount: number;
721
725
  otpError: any,
722
726
  setOtpError: any
727
+ isCheckingCode: boolean
728
+ setCheckingCode: (value: boolean) => void
723
729
  }
724
730
 
725
731
  export interface FavoriteParams {