ordering-ui-react-native 0.17.44 → 0.17.46

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.44",
3
+ "version": "0.17.46",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -130,6 +130,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
130
130
  const [subcategoriesSelected, setSubcategoriesSelected] = useState([])
131
131
  const [openService, setOpenService] = useState(false)
132
132
  const [currentProduct, setCurrentProduct] = useState(null)
133
+ const [searchBarHeight, setSearchBarHeight] = useState(60)
133
134
 
134
135
  const isCheckoutMultiBusinessEnabled: Boolean = configs?.checkout_multi_business_enabled?.value === '1'
135
136
  const openCarts = (Object.values(orderState?.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) || []
@@ -262,6 +263,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
262
263
  style={{
263
264
  marginTop: Platform.OS === 'ios' ? insets.top : 0
264
265
  }}
266
+ onLayout={(event: any) => setSearchBarHeight(event.nativeEvent.layout.height) }
265
267
  >
266
268
  {!isOpenSearchBar && (
267
269
  <>
@@ -322,12 +324,12 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
322
324
 
323
325
  {business?.categories?.length > 0 && isOpenFiltProducts && (
324
326
  <FiltProductsContainer
325
- isIos={Platform.OS === 'ios'}
326
- style={{
327
- height: Dimensions.get('window').height - filtProductsHeight
328
- }}
329
- contentContainerStyle={{ flexGrow: 1 }}
330
- >
327
+ style={{
328
+ height: Dimensions.get('window').height - filtProductsHeight,
329
+ top: Platform.OS === 'ios' ? searchBarHeight + insets.top : searchBarHeight
330
+ }}
331
+ contentContainerStyle={{ flexGrow: 1 }}
332
+ >
331
333
  <View style={{ padding: 20, backgroundColor: theme.colors.white }}>
332
334
  <BusinessProductsList
333
335
  categories={[
@@ -485,22 +487,24 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
485
487
  )}
486
488
  </IOScrollView>
487
489
  {!loading && auth && currentCart?.products?.length > 0 && categoryState.products.length !== 0 && (
488
- <FloatingButton
489
- btnText={
490
- openUpselling
491
- ? t('LOADING', 'Loading')
492
- : currentCart?.subtotal >= currentCart?.minimum
493
- ? t('VIEW_ORDER', 'View Order')
494
- : `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(currentCart?.minimum)}`
495
- }
496
- isSecondaryBtn={currentCart?.subtotal < currentCart?.minimum || openUpselling}
497
- btnLeftValueShow={currentCart?.subtotal >= currentCart?.minimum && currentCart?.products?.length > 0}
498
- btnRightValueShow={currentCart?.subtotal >= currentCart?.minimum && currentCart?.products?.length > 0}
499
- btnLeftValue={currentCart?.products.reduce((prev: number, product: any) => prev + product.quantity, 0)}
500
- btnRightValue={parsePrice(currentCart?.total)}
501
- disabled={currentCart?.subtotal < currentCart?.minimum || openUpselling}
502
- handleClick={() => setOpenUpselling(true)}
503
- />
490
+ <View style={{ marginBottom: Platform.OS === 'ios' ? 20 : 0 }}>
491
+ <FloatingButton
492
+ btnText={
493
+ openUpselling
494
+ ? t('LOADING', 'Loading')
495
+ : currentCart?.subtotal >= currentCart?.minimum
496
+ ? t('VIEW_ORDER', 'View Order')
497
+ : `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(currentCart?.minimum)}`
498
+ }
499
+ isSecondaryBtn={currentCart?.subtotal < currentCart?.minimum || openUpselling}
500
+ btnLeftValueShow={currentCart?.subtotal >= currentCart?.minimum && currentCart?.products?.length > 0}
501
+ btnRightValueShow={currentCart?.subtotal >= currentCart?.minimum && currentCart?.products?.length > 0}
502
+ btnLeftValue={currentCart?.products.reduce((prev: number, product: any) => prev + product.quantity, 0)}
503
+ btnRightValue={parsePrice(currentCart?.total)}
504
+ disabled={currentCart?.subtotal < currentCart?.minimum || openUpselling}
505
+ handleClick={() => setOpenUpselling(true)}
506
+ />
507
+ </View>
504
508
  )}
505
509
  {openUpselling && (
506
510
  <UpsellingRedirect
@@ -38,8 +38,6 @@ export const FiltProductsContainer = styled.ScrollView`
38
38
  position: absolute;
39
39
  width: 100%;
40
40
  z-index: 20000;
41
- top: 80px;
42
- margin-top: 20px;
43
41
  `
44
42
 
45
43
  export const BackgroundGray = styled.View`
@@ -167,6 +167,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
167
167
  const timerId = useRef<any>(false)
168
168
  const [favoriteIds, setFavoriteIds] = useState<any>([])
169
169
  const chewOrderTypes = [{ name: t('DELIVERY', 'Delivery').toUpperCase(), value: 1 }, { name: t('PICKUP', 'Pickup').toUpperCase(), value: 2 }]
170
+ const enabledPoweredByOrdering = configs?.powered_by_ordering_module?.value
170
171
 
171
172
  const handleMomentClick = () => {
172
173
  if (isPreorderEnabled) {
@@ -353,6 +354,13 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
353
354
  />
354
355
  }
355
356
  >
357
+ {enabledPoweredByOrdering && auth && (
358
+ <View style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', top: 20 }}>
359
+ <OText>
360
+ Powered By Ordering.co
361
+ </OText>
362
+ </View>
363
+ )}
356
364
  <View style={{
357
365
  height: !isPreOrderSetting && isChewLayout ? 150 : isChewLayout ? 200 : isFarAway ? 150 : 100,
358
366
  marginTop: Platform.OS == 'ios' ? 0 : 50,
@@ -458,7 +466,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
458
466
  </View>
459
467
  {!isChewLayout ? (
460
468
  <HeaderWrapper
461
- source={bgHeader ? {uri: bgHeader} : theme.images.backgrounds.business_list_header}
469
+ source={bgHeader ? { uri: bgHeader } : theme.images.backgrounds.business_list_header}
462
470
  style={{ paddingTop: top + 20 }}
463
471
  resizeMode='cover'
464
472
  >
@@ -118,9 +118,11 @@ const CheckoutUI = (props: any) => {
118
118
  paddingHorizontal: 40,
119
119
  width: '100%'
120
120
  },
121
- wrapperNavbar: Platform.OS === 'ios'
122
- ? { paddingVertical: 0, paddingHorizontal: 40 }
123
- : { paddingVertical: 20, paddingHorizontal: 40 }
121
+ wrapperNavbar: {
122
+ paddingVertical: 0,
123
+ paddingHorizontal: 40,
124
+ marginVertical: 2
125
+ }
124
126
  })
125
127
 
126
128
  const [, { showToast }] = useToast();
@@ -180,8 +182,8 @@ const CheckoutUI = (props: any) => {
180
182
  }
181
183
  }
182
184
 
183
- const handlePlaceOrder = (confirmPayment: any) => {
184
- if (!userErrors.length && !requiredFields?.length) {
185
+ const handlePlaceOrder = (confirmPayment: any, forcePlace: boolean = false) => {
186
+ if (!userErrors.length && !requiredFields?.length || forcePlace) {
185
187
  handlerClickPlaceOrder && handlerClickPlaceOrder(null, null, confirmPayment)
186
188
  return
187
189
  }
@@ -284,7 +286,6 @@ const CheckoutUI = (props: any) => {
284
286
  onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
285
287
  showCall={false}
286
288
  btnStyle={{ paddingLeft: 0 }}
287
- style={{ marginTop: Platform.OS === 'ios' ? 0 : 30 }}
288
289
  titleWrapStyle={{ paddingHorizontal: 0 }}
289
290
  titleStyle={{ marginRight: 0, marginLeft: 0 }}
290
291
  />
@@ -741,7 +742,10 @@ const CheckoutUI = (props: any) => {
741
742
  togglePhoneUpdate={togglePhoneUpdate}
742
743
  requiredFields={requiredFields}
743
744
  hideUpdateButton
744
- onClose={() => setIsOpen(false)}
745
+ onClose={() => {
746
+ setIsOpen(false)
747
+ handlePlaceOrder(null, true)
748
+ }}
745
749
  />
746
750
  </View>
747
751
  </OModal>
@@ -1,91 +1,113 @@
1
- import React, { useEffect } from 'react'
1
+ import React, { useEffect, useState } from 'react'
2
2
  import { formatSeconds } from '../../../utils'
3
3
  import { StyleSheet, TouchableOpacity } from 'react-native';
4
4
  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 } from '../../shared';
8
- import OTPInputView from '@twotalltotems/react-native-otp-input'
8
+ import OtpInputs from 'react-native-otp-inputs';
9
9
  import { useTheme } from 'styled-components/native';
10
10
  import { otpParams } from '../../../types'
11
11
 
12
12
  export const Otp = (props: otpParams) => {
13
- const {
14
- willVerifyOtpState,
15
- setWillVerifyOtpState,
16
- onSubmit,
17
- handleLoginOtp,
18
- setAlertState,
19
- pinCount
20
- } = props
13
+ const {
14
+ willVerifyOtpState,
15
+ setWillVerifyOtpState,
16
+ onSubmit,
17
+ handleLoginOtp,
18
+ setAlertState,
19
+ pinCount
20
+ } = props
21
21
 
22
- const theme = useTheme();
23
- const [, t] = useLanguage();
24
- const [otpLeftTime, _, resetOtpLeftTime]: any = useCountdownTimer(
25
- 600, willVerifyOtpState)
22
+ const theme = useTheme();
23
+ const [, t] = useLanguage();
24
+ const [otpLeftTime, _, resetOtpLeftTime]: any = useCountdownTimer(
25
+ 600, willVerifyOtpState)
26
26
 
27
+ const [code, setCode] = useState('')
27
28
 
28
- const handleOnSubmit = () => {
29
- setAlertState({
30
- open: true,
31
- title: t('CODE_SENT', 'The code has been sent'),
32
- })
33
- resetOtpLeftTime()
34
- onSubmit()
29
+
30
+ const handleOnSubmit = () => {
31
+ setAlertState({
32
+ open: true,
33
+ title: t('CODE_SENT', 'The code has been sent'),
34
+ })
35
+ resetOtpLeftTime()
36
+ onSubmit()
37
+ }
38
+
39
+ useEffect(() => {
40
+ if (otpLeftTime === 0) {
41
+ setAlertState({
42
+ open: true,
43
+ title: t('TIME_IS_UP', 'Time is up'),
44
+ content: t('PLEASE_RESEND_CODE', 'Please resend code again')
45
+ })
35
46
  }
47
+ }, [otpLeftTime])
36
48
 
37
- useEffect(() => {
38
- if (otpLeftTime === 0) {
39
- setAlertState({
40
- open: true,
41
- title: t('TIME_IS_UP', 'Time is up'),
42
- content: t('PLEASE_RESEND_CODE', 'Please resend code again')
43
- })
44
- }
45
- }, [otpLeftTime])
49
+ useEffect(() => {
50
+ if (code?.length === (pinCount || 6)) {
51
+ handleLoginOtp(code)
52
+ }
53
+ }, [code])
46
54
 
47
- const loginStyle = StyleSheet.create({
48
- underlineStyleBase: {
49
- width: 45,
50
- height: 60,
51
- borderWidth: 1,
52
- fontSize: 16
53
- },
54
- underlineStyleHighLighted: {
55
- borderColor: theme.colors.primary,
56
- color: theme.colors.primary,
57
- fontSize: 16
58
- },
59
- });
55
+ const loginStyle = StyleSheet.create({
56
+ container: {
57
+ width: '100%',
58
+ flexDirection: 'row',
59
+ justifyContent: 'space-between',
60
+ marginVertical: 30
61
+ },
62
+ focusStyles: {
63
+ borderColor: theme.colors.primary,
64
+ borderWidth: 1,
65
+ borderRadius: 8
66
+ },
67
+ underlineStyleBase: {
68
+ width: 45,
69
+ height: 50,
70
+ borderWidth: 1,
71
+ fontSize: 16,
72
+ borderRadius: 8,
73
+ borderColor: theme.colors.lightGray,
74
+ textAlign: 'center'
75
+ },
76
+ underlineStyleHighLighted: {
77
+ borderColor: theme.colors.primary,
78
+ color: theme.colors.primary,
79
+ fontSize: 16
80
+ },
81
+ });
60
82
 
61
- return (
62
- <>
63
- <OTPContainer>
64
- <OText size={24}>
65
- {formatSeconds(otpLeftTime)}
66
- </OText>
67
- <OTPInputView
68
- style={{ width: '100%', height: 150 }}
69
- pinCount={pinCount || 6}
70
- codeInputFieldStyle={loginStyle.underlineStyleBase}
71
- codeInputHighlightStyle={loginStyle.underlineStyleHighLighted}
72
- onCodeFilled={(code: string) => handleLoginOtp(code)}
73
- selectionColor={theme.colors.primary}
74
- />
75
- <TouchableOpacity onPress={() => handleOnSubmit()} disabled={otpLeftTime > 520}>
76
- <OText size={16} mBottom={30} color={otpLeftTime > 520 ? theme.colors.disabled : theme.colors.primary}>
77
- {t('RESEND_CODE', 'Resend code')}
78
- </OText>
79
- </TouchableOpacity>
80
- <OButton
81
- onClick={() => setWillVerifyOtpState(false)}
82
- bgColor={theme.colors.white}
83
- borderColor={theme.colors.primary}
84
- textStyle={{ color: theme.colors.primary }}
85
- style={{ borderRadius: 8, width: '100%' }}
86
- text={t('CANCEL', 'Cancel')}
87
- />
88
- </OTPContainer>
89
- </>
90
- )
83
+ return (
84
+ <>
85
+ <OTPContainer>
86
+ <OText size={24}>
87
+ {formatSeconds(otpLeftTime)}
88
+ </OText>
89
+ <OtpInputs
90
+ autofillFromClipboard
91
+ numberOfInputs={pinCount || 6}
92
+ style={loginStyle.container}
93
+ inputStyles={loginStyle.underlineStyleBase}
94
+ focusStyles={loginStyle.focusStyles}
95
+ handleChange={setCode}
96
+ />
97
+ <TouchableOpacity onPress={() => handleOnSubmit()} disabled={otpLeftTime > 520}>
98
+ <OText size={16} mBottom={30} color={otpLeftTime > 520 ? theme.colors.disabled : theme.colors.primary}>
99
+ {t('RESEND_CODE', 'Resend code')}
100
+ </OText>
101
+ </TouchableOpacity>
102
+ <OButton
103
+ onClick={() => setWillVerifyOtpState(false)}
104
+ bgColor={theme.colors.white}
105
+ borderColor={theme.colors.primary}
106
+ textStyle={{ color: theme.colors.primary }}
107
+ style={{ borderRadius: 8, width: '100%' }}
108
+ text={t('CANCEL', 'Cancel')}
109
+ />
110
+ </OTPContainer>
111
+ </>
112
+ )
91
113
  }
@@ -96,7 +96,7 @@ const LoginFormUI = (props: LoginParams) => {
96
96
  const [alertState, setAlertState] = useState({ open: false, title: '', content: [] })
97
97
  const [tabLayouts, setTabLayouts] = useState<any>({})
98
98
  const tabsRef = useRef<any>(null)
99
-
99
+ const enabledPoweredByOrdering = configs?.powered_by_ordering_module?.value
100
100
  const theme = useTheme();
101
101
  const isOtpEmail = loginTab === 'otp' && otpType === 'email'
102
102
  const isOtpCellphone = loginTab === 'otp' && otpType === 'cellphone'
@@ -789,6 +789,12 @@ const LoginFormUI = (props: LoginParams) => {
789
789
  </Placeholder>
790
790
  </SkeletonWrapper>
791
791
  )}
792
+
793
+ {enabledPoweredByOrdering && (
794
+ <OText>
795
+ Powered By Ordering.co
796
+ </OText>
797
+ )}
792
798
  </FormSide>
793
799
  <OModal
794
800
  open={isModalVisible}
@@ -118,6 +118,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
118
118
  const mapValidStatuses = [9, 19, 23]
119
119
  const placeSpotTypes = [3, 4, 5]
120
120
  const directionTypes = [2, 3, 4, 5]
121
+ const enabledPoweredByOrdering = configs?.powered_by_ordering_module?.value
121
122
 
122
123
  const walletName: any = {
123
124
  cash: {
@@ -599,6 +600,13 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
599
600
  : parseDate(order?.delivery_datetime, { utc: false })}
600
601
  </OText>}
601
602
  />
603
+ {enabledPoweredByOrdering && (
604
+ <View style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
605
+ <OText>
606
+ Powered By Ordering.co
607
+ </OText>
608
+ </View>
609
+ )}
602
610
  <OrderInfo>
603
611
  <OrderData>
604
612
  <View style={styles.linkWrapper}>
@@ -124,7 +124,7 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
124
124
  flagButtonStyle={flagStyle}
125
125
  countryPickerButtonStyle={{ ...style.countryBtn, ...boxStyle ? boxStyle : {} }}
126
126
  placeholder={t('PHONE_NUMBER', 'Phone Number')}
127
- textInputProps={{ autoCompleteType: 'tel', ref: forwardRef, ...textInputProps }}
127
+ textInputProps={{ keyboardType: 'number-pad', autoCompleteType: 'tel', textContentType: 'telephoneNumber', dataDetectorTypes: 'phoneNumber', ref: forwardRef, ...textInputProps }}
128
128
  containerStyle={{ width: '100%' }}
129
129
  renderDropdownImage={noDropIcon ? <View /> : <OIcon src={theme.images.general.arrow_down} width={13} color={'#B1BCCC'}></OIcon>}
130
130
  />
@@ -111,7 +111,7 @@ const WalletsUI = (props: any) => {
111
111
  <>
112
112
  <Container>
113
113
  <Header>
114
- <OText size={24}>{t('WALLETS', 'Wallets')}</OText>
114
+ <OText size={24} style={{ marginTop: 30 }}>{t('WALLETS', 'Wallets')}</OText>
115
115
  {isChewLayout && (
116
116
  <OButton
117
117
  text={t('WALLET_HISTORY', 'Wallet history')}