ordering-ui-react-native 0.16.4 → 0.16.7

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.16.4",
3
+ "version": "0.16.7",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -49,7 +49,7 @@ const DriverTipsUI = (props: any) => {
49
49
  const [{ configs }] = useConfig();
50
50
  const [{loading}] = useOrder()
51
51
 
52
- const [value, setvalue] = useState(0);
52
+ const [value, setvalue] = useState('');
53
53
  const [valueOption,setValueOption] = useState(0)
54
54
 
55
55
  const placeholderCurrency = (configs?.currency_position?.value || 'left') === 'left'
@@ -57,9 +57,12 @@ const DriverTipsUI = (props: any) => {
57
57
  : `0${configs?.format_number_currency?.value}`
58
58
 
59
59
  const handleChangeDriverTip = (val: any) => {
60
- let tip = parseFloat(val)
61
- tip = isNaN(tip) ? 0 : tip
62
- setvalue(tip)
60
+ const tip = Number(val)
61
+ if ((isNaN(tip) || tip < 0)) {
62
+ setvalue(value)
63
+ return
64
+ }
65
+ setvalue(val)
63
66
  }
64
67
 
65
68
  const handleChangeOptionCustom = (val : any) => {
@@ -110,6 +113,8 @@ const DriverTipsUI = (props: any) => {
110
113
  <OInput
111
114
  placeholder={placeholderCurrency}
112
115
  style={style.inputStyle}
116
+ value={value}
117
+ type={'numeric'}
113
118
  onChange={handleChangeDriverTip}
114
119
  autoCapitalize='none'
115
120
  autoCorrect={false}
@@ -121,10 +126,10 @@ const DriverTipsUI = (props: any) => {
121
126
  textStyle={{ color: 'white', fontSize: 18, maxWidth: 110, minWidth: 60 }}
122
127
  imgRightSrc={null}
123
128
  textProps={{numberOfLines: 1}}
124
- isDisabled={!(value > 0 && value !== driverTip) || !value}
129
+ isDisabled={parseFloat(value || '0') < 0 || parseFloat(value || '0') === driverTip || value === ''}
125
130
  onClick={() => {
126
131
  handlerChangeOption(value)
127
- setvalue(0)
132
+ setvalue('')
128
133
  }}
129
134
  />
130
135
  </DTWrapperInput>
@@ -323,6 +323,12 @@ export const OrderContentComponent = (props: OrderContent) => {
323
323
  {order?.customer?.zipcode}
324
324
  </OText>
325
325
  )}
326
+
327
+ {!!order?.on_behalf_of && (
328
+ <OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
329
+ {t('ON_BEHALF_OF', 'On behalf of')}{': '} {order?.on_behalf_of}
330
+ </OText>
331
+ )}
326
332
  {((order?.delivery_option !== undefined && order?.delivery_type === 1) || !!order?.comment) && (
327
333
  <View style={{ marginTop: 10 }}>
328
334
  {order?.delivery_option !== undefined && order?.delivery_type === 1 && (
@@ -1,5 +1,5 @@
1
1
  import React, { useState, useEffect } from 'react';
2
-
2
+ import { _retrieveStoreData } from '../../../../../src/providers/StoreUtil';
3
3
  import {
4
4
  Checkout as CheckoutController,
5
5
  useOrder,
@@ -35,10 +35,18 @@ const CheckoutUI = (props: any) => {
35
35
  } = props
36
36
 
37
37
  const [errorCash, setErrorCash] = useState(false);
38
+ const [customerName, setCustomerName] = useState(null);
39
+
40
+ const getCustomerName = async () => {
41
+ const data = await _retrieveStoreData('customer_name');
42
+ setCustomerName(data?.customerName)
43
+ }
38
44
 
39
45
  useEffect(() => {
40
46
  if (!cartState.loading && cart && !cart?.valid && cart?.status === 2) {
41
47
  navigation?.canGoBack() && navigation.goBack()
48
+ } else {
49
+ getCustomerName()
42
50
  }
43
51
  }, [cart])
44
52
 
@@ -48,6 +56,7 @@ const CheckoutUI = (props: any) => {
48
56
  navigation={navigation}
49
57
  cart={cart}
50
58
  errors={errors}
59
+ customerName={customerName}
51
60
  onPaymentChange={handlePaymethodChange}
52
61
  onNavigationRedirect={onNavigationRedirect}
53
62
  paySelected={paymethodSelected}
@@ -110,7 +119,7 @@ export const Checkout = (props: any) => {
110
119
  loading: false,
111
120
  cart: result
112
121
  })
113
- } catch (error) {
122
+ } catch (error: any) {
114
123
  showToast(ToastType.Error, error?.toString() || error.message)
115
124
  }
116
125
  } else {
@@ -122,7 +131,7 @@ export const Checkout = (props: any) => {
122
131
  error: cart ? null : result
123
132
  })
124
133
  }
125
- } catch (e) {
134
+ } catch (e: any) {
126
135
  setCartState({
127
136
  ...cartState,
128
137
  loading: false,
@@ -113,12 +113,6 @@ const CustomerName = (props: Props): React.ReactElement => {
113
113
  style={{ bottom: 20 }}
114
114
  >
115
115
  {t('WHATS_YOUR_NAME', "What's your name?")}
116
- {/* <OText
117
- size={orientationState?.dimensions?.width * 0.05}
118
- weight={'700'}
119
- >
120
- {`${t('ORDER_BE_FOR', 'order be for?')}`}
121
- </OText> */}
122
116
  </OText>
123
117
  <Controller
124
118
  control={control}
@@ -395,7 +395,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
395
395
  </View>
396
396
  </OSTable>
397
397
 
398
- {order?.products?.length && (
398
+ {order?.products?.length > 0 && (
399
399
  <>
400
400
  <View
401
401
  style={{
@@ -598,7 +598,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
598
598
  <>
599
599
  <Spinner visible={!order || Object.keys(order).length === 0} />
600
600
 
601
- {order && Object.keys(order).length > 0 && (
601
+ {!!order && Object.keys(order).length > 0 && (
602
602
  <>
603
603
  <Container>
604
604
  <NavBar
@@ -107,7 +107,7 @@ const PaymentOptionsUI = (props: any) => {
107
107
 
108
108
  const handlePlaceOrder = () => {
109
109
  if (!userErrors.length) {
110
- handlerClickPlaceOrder && handlerClickPlaceOrder();
110
+ handlerClickPlaceOrder && handlerClickPlaceOrder(null, { on_behalf_of: props.customerName });
111
111
  return;
112
112
  }
113
113
  let stringError = '';
@@ -305,9 +305,9 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
305
305
  onCancel={() => handleChangeSearch('')}
306
306
  placeholder={t('SEARCH', 'Search')}
307
307
  height={26}
308
- isDisabled={configs?.advanced_business_search_enabled?.value === '1' || !businessTypes}
308
+ isDisabled={!businessTypes}
309
309
  inputStyle={{ ...styles.searchInput, ...Platform.OS === 'ios' ? {} : { paddingBottom: 4 } }}
310
- onPress={() => { configs?.advanced_business_search_enabled?.value === '1' && navigation.navigate('BusinessSearch', { businessTypes }) }}
310
+ onSubmitEditing={() => { configs?.advanced_business_search_enabled?.value === '1' && navigation.navigate('BusinessSearch', { businessTypes, defaultTerm: searchValue }) }}
311
311
  />
312
312
  )}
313
313
 
@@ -269,7 +269,7 @@ const CheckoutUI = (props: any) => {
269
269
  onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
270
270
  showCall={false}
271
271
  btnStyle={{ paddingLeft: 0 }}
272
- style={{ flexDirection: 'column', alignItems: 'flex-start', marginTop: Platform.OS === 'ios' ? 0 : 20 }}
272
+ style={{ marginTop: Platform.OS === 'ios' ? 0 : 30 }}
273
273
  titleWrapStyle={{ paddingHorizontal: 0 }}
274
274
  titleStyle={{ marginRight: 0, marginLeft: 0 }}
275
275
  />
@@ -48,16 +48,19 @@ const DriverTipsUI = (props: any) => {
48
48
  }
49
49
  })
50
50
 
51
- const [value, setvalue] = useState(0);
51
+ const [value, setvalue] = useState('');
52
52
 
53
53
  const placeholderCurrency = (configs?.currency_position?.value || 'left') === 'left'
54
54
  ? `${configs?.format_number_currency?.value}0`
55
55
  : `0${configs?.format_number_currency?.value}`
56
56
 
57
57
  const handleChangeDriverTip = (val: any) => {
58
- let tip = parseFloat(val)
59
- tip = isNaN(tip) ? 0 : tip
60
- setvalue(tip)
58
+ const tip = Number(val)
59
+ if ((isNaN(tip) || tip < 0)) {
60
+ setvalue(value)
61
+ return
62
+ }
63
+ setvalue(val)
61
64
  }
62
65
 
63
66
  return (
@@ -97,6 +100,8 @@ const DriverTipsUI = (props: any) => {
97
100
  <OInput
98
101
  placeholder={placeholderCurrency}
99
102
  style={style.inputStyle}
103
+ value={value}
104
+ type={'numeric'}
100
105
  onChange={handleChangeDriverTip}
101
106
  autoCapitalize='none'
102
107
  autoCorrect={false}
@@ -108,10 +113,10 @@ const DriverTipsUI = (props: any) => {
108
113
  textStyle={{ color: 'white', fontSize: 14 }}
109
114
  imgRightSrc={null}
110
115
  style={{ borderRadius: 5, height: 44 }}
111
- isDisabled={!(value > 0 && value !== driverTip) || !value}
116
+ isDisabled={parseFloat(value || '0') < 0 || parseFloat(value || '0') === driverTip || value === ''}
112
117
  onClick={() => {
113
118
  handlerChangeOption(value)
114
- setvalue(0)
119
+ setvalue('')
115
120
  }}
116
121
  />
117
122
  </DTWrapperInput>
@@ -20,7 +20,9 @@ export const SearchBar = (props: any) => {
20
20
  inputStyle,
21
21
  onPress,
22
22
  isDisabled,
23
- iconCustomRight
23
+ iconCustomRight,
24
+ onSubmitEditing,
25
+ blurOnSubmit
24
26
  } = props
25
27
 
26
28
  const theme = useTheme();
@@ -88,6 +90,7 @@ export const SearchBar = (props: any) => {
88
90
  inputStyle={{padding: 0, paddingTop: Platform.OS == 'android' ? 2 : 0, ...inputStyle}}
89
91
  onPress={() => onPress && onPress()}
90
92
  iconCustomRight={iconCustomRight}
93
+ onSubmitEditing={() => onSubmitEditing && onSubmitEditing()}
91
94
  />
92
95
  {isCancelButtonShow && (
93
96
  <OButton