ordering-ui-react-native 0.17.88 → 0.17.90

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.88",
3
+ "version": "0.17.90",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -240,13 +240,16 @@ export const BusinessListingSearchUI = (props: BusinessSearchParams) => {
240
240
  <SearchBar
241
241
  lazyLoad
242
242
  {...(isChewLayout && { height: 55 })}
243
- inputStyle={{ ...styles.searchInput, ...Platform.OS === 'ios' ? {} : { paddingBottom: 4 } }}
244
- placeholder={`${t('SEARCH_BUSINESSES', 'Search Businesses')} / ${t('TYPE_AT_LEAST_3_CHARACTERS', 'type at least 3 characters')}`}
243
+ inputStyle={{ ...styles.searchInput }}
244
+ placeholder={t('SEARCH_BUSINESSES', 'Search Businesses')}
245
245
  onSearch={(val: string) => handleChangeTermValue(val)}
246
246
  value={termValue}
247
247
  iconCustomRight={<AntDesignIcon name='filter' size={16} style={{ bottom: 2 }} onPress={() => handleOpenfilters()} />}
248
248
  />
249
249
  </SearchWrapper>
250
+ <OText size={12} lineHeight={20} color={theme.colors.textThird} mLeft={5}>
251
+ {t('TYPE_AT_LEAST_3_CHARACTERS', 'Type at least 3 characters')}
252
+ </OText>
250
253
  {
251
254
  noResults && (
252
255
  <View>
@@ -273,11 +276,13 @@ export const BusinessListingSearchUI = (props: BusinessSearchParams) => {
273
276
  />
274
277
  )}
275
278
 
276
- <OptionTitle isBusinessesSearchList={!!businessesSearchList}>
277
- <OText size={16} lineHeight={24} weight={'500'} color={theme.colors.textNormal} mBottom={10}>
278
- {t('BUSINESSES', 'Businesses')}
279
- </OText>
280
- </OptionTitle>
279
+ {businessesSearchList.businesses?.length > 0 && (
280
+ <OptionTitle isBusinessesSearchList={!!businessesSearchList}>
281
+ <OText size={16} lineHeight={24} weight={'500'} color={theme.colors.textNormal} mBottom={10}>
282
+ {t('BUSINESSES', 'Businesses')}
283
+ </OText>
284
+ </OptionTitle>
285
+ )}
281
286
  <ScrollView horizontal showsHorizontalScrollIndicator={false}>
282
287
  {businessesSearchList.businesses?.length > 0 && businessesSearchList.businesses.map((business: any, i: number) => (
283
288
  <View
@@ -401,12 +401,13 @@ const CartUI = (props: any) => {
401
401
  uuid={cart?.uuid}
402
402
  businessId={cart?.business_id}
403
403
  driverTipsOptions={!driverTipsOptions.includes(0) ? [0, ...driverTipsOptions] : driverTipsOptions}
404
- isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)}
404
+ isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1}
405
405
  isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
406
- driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)
406
+ driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1
407
407
  ? cart?.driver_tip
408
408
  : cart?.driver_tip_rate}
409
409
  useOrderContext
410
+ cart={cart}
410
411
  />
411
412
  </DriverTipsContainer>
412
413
  )}
@@ -558,12 +558,13 @@ const CheckoutUI = (props: any) => {
558
558
  uuid={cartUuid}
559
559
  businessId={cart?.business_id}
560
560
  driverTipsOptions={!driverTipsOptions.includes(0) ? [0, ...driverTipsOptions] : driverTipsOptions}
561
- isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)}
561
+ isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1}
562
562
  isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
563
- driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)
563
+ driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1
564
564
  ? cart?.driver_tip
565
565
  : cart?.driver_tip_rate}
566
566
  useOrderContext
567
+ cart={cart}
567
568
  />
568
569
  </ChDriverTips>
569
570
  </ChSection>
@@ -23,16 +23,19 @@ const DriverTipsUI = (props: any) => {
23
23
  driverTip,
24
24
  driverTipsOptions,
25
25
  optionSelected,
26
- isFixedPrice,
26
+ cart,
27
27
  isDriverTipUseCustom,
28
- handlerChangeOption
28
+ handlerChangeOption,
29
+ isFixedPrice
29
30
  } = props;
30
31
 
31
32
  const [{ parsePrice }] = useUtils();
33
+ const theme = useTheme();
32
34
  const [, t] = useLanguage();
33
35
  const [{ configs }] = useConfig();
34
-
35
- const theme = useTheme();
36
+ const [customTip, setCustomTip] = useState((isDriverTipUseCustom && !driverTipsOptions.includes(driverTip)) ?? false)
37
+ const currentTip = customTip ? parseFloat(driverTip || 0) > 0 : (!customTip && !driverTipsOptions.includes(driverTip) && parseFloat(driverTip || 0)) > 0
38
+ const [value, setvalue] = useState('');
36
39
 
37
40
  const style = StyleSheet.create({
38
41
  semicircle: {
@@ -48,53 +51,59 @@ const DriverTipsUI = (props: any) => {
48
51
  }
49
52
  })
50
53
 
51
- const [value, setvalue] = useState('');
52
-
53
- const placeholderCurrency = (configs?.currency_position?.value || 'left') === 'left'
54
+ const placeholderCurrency = !isFixedPrice ? `0%` : (configs?.currency_position?.value || 'left') === 'left'
54
55
  ? `${configs?.format_number_currency?.value}0`
55
56
  : `0${configs?.format_number_currency?.value}`
56
57
 
57
58
  const handleChangeDriverTip = (val: any) => {
58
59
  const tip = Number(val)
59
60
  if ((isNaN(tip) || tip < 0)) {
60
- setvalue(value)
61
- return
61
+ setvalue(value)
62
+ return
62
63
  }
63
64
  setvalue(val)
64
65
  }
65
-
66
+
66
67
  return (
67
68
  <DTContainer>
68
69
  <DTLabel>
69
70
  {t('CUSTOM_DRIVER_TIP_MESSAGE', '100% of these tips go directly to your driver')}
70
71
  </DTLabel>
71
72
  <DTWrapperTips>
72
- {!isDriverTipUseCustom && driverTipsOptions.map((option: any, i: number) => (
73
+ {driverTipsOptions.map((option: any, i: number) => (
73
74
  <TouchableOpacity
74
75
  key={i}
75
- onPress={() => handlerChangeOption(option)}
76
+ onPress={() => {
77
+ handlerChangeOption(option)
78
+ setCustomTip(false)
79
+ }}
76
80
  >
77
81
  <DTCard
78
82
  style={style.semicircle}
79
- isActive={option === optionSelected}
83
+ isActive={(option === driverTip && !customTip)}
80
84
  >
81
- <OText size={12} numberOfLines={2} color={option === optionSelected ? '#FFF' : theme.colors.textSecondary}>
85
+ <OText size={12} numberOfLines={2} color={(option === driverTip && !customTip) ? '#FFF' : theme.colors.textSecondary}>
82
86
  {`${isFixedPrice ? parsePrice(option) : `${option}%`}`}
83
87
  </OText>
84
88
  </DTCard>
85
89
  </TouchableOpacity>
86
90
  ))}
91
+ {isDriverTipUseCustom && (
92
+ <TouchableOpacity
93
+ onPress={() => setCustomTip(true)}
94
+ >
95
+ <DTCard
96
+ style={style.semicircle}
97
+ isActive={customTip}
98
+ >
99
+ <OText size={12} numberOfLines={2} color={customTip ? '#FFF' : theme.colors.textSecondary}>
100
+ {t('CUSTOM_TIP', 'Custom')}
101
+ </OText>
102
+ </DTCard>
103
+ </TouchableOpacity>
104
+ )}
87
105
  </DTWrapperTips>
88
- {(!isDriverTipUseCustom && !driverTipsOptions.includes(driverTip) && driverTip > 0) && (
89
- <OText
90
- color={theme.colors.error}
91
- size={16}
92
- style={{ marginTop: 10, textAlign: 'center' }}
93
- >
94
- {t('CUSTOM_DRIVER_TIP_AMOUNT', 'The driver\'s current tip comes from a custom option')}
95
- </OText>
96
- )}
97
- {isDriverTipUseCustom && (
106
+ {customTip && (
98
107
  <DTForm>
99
108
  <DTWrapperInput>
100
109
  <OInput
@@ -120,17 +129,18 @@ const DriverTipsUI = (props: any) => {
120
129
  }}
121
130
  />
122
131
  </DTWrapperInput>
123
- {parseFloat(driverTip || 0) > 0 && (
124
- <OText
125
- color={theme.colors.error}
126
- size={16}
127
- style={{ marginTop: 10, textAlign: 'center' }}
128
- >
129
- {t('CURRENT_DRIVER_TIP_AMOUNT', 'Current driver tip amount')}: {parsePrice(driverTip)}
130
- </OText>
131
- )}
132
132
  </DTForm>
133
133
  )}
134
+ {currentTip && (
135
+ <OText
136
+ color={theme.colors.primary}
137
+ size={16}
138
+ style={{ marginTop: 10, textAlign: 'center' }}
139
+ >
140
+ {t('CURRENT_DRIVER_TIP_AMOUNT', 'Current driver tip amount')}{!isFixedPrice &&
141
+ ` (${driverTip}%)`}: {isFixedPrice ? parsePrice(driverTip) : parsePrice(cart?.driver_tip)}
142
+ </OText>
143
+ )}
134
144
  </DTContainer>
135
145
  )
136
146
  }
@@ -147,18 +147,16 @@ export const MyOrders = (props: any) => {
147
147
  )}
148
148
  {selectedOption === 'orders' && (
149
149
  <>
150
- {ordersLength?.activeOrdersLength !== 0 && (
151
- <View style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}>
152
- <OrdersOption
153
- {...props}
154
- activeOrders
155
- ordersLength={ordersLength}
156
- setOrdersLength={setOrdersLength}
157
- setRefreshOrders={setRefreshOrders}
158
- refreshOrders={refreshOrders}
159
- />
160
- </View>
161
- )}
150
+ <View style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}>
151
+ <OrdersOption
152
+ {...props}
153
+ activeOrders
154
+ ordersLength={ordersLength}
155
+ setOrdersLength={setOrdersLength}
156
+ setRefreshOrders={setRefreshOrders}
157
+ refreshOrders={refreshOrders}
158
+ />
159
+ </View>
162
160
  <View style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}>
163
161
  <OrdersOption
164
162
  {...props}
@@ -26,7 +26,7 @@ export const PreviousProductsOrdered = (props: PreviousProductsOrderedParams) =>
26
26
  const ProductList = ({ style }: any) => {
27
27
  return (
28
28
  <>
29
- {products?.map((product: any) => (
29
+ {products?.filter((product : any) => product?.business?.available)?.map((product: any) => (
30
30
  <SingleProductCard
31
31
  key={product?.id}
32
32
  isProductId
@@ -3,7 +3,6 @@ import { OrderList, useLanguage, useOrder, ToastType, useToast } from 'ordering-
3
3
  import { useTheme } from 'styled-components/native';
4
4
  import { useFocusEffect } from '@react-navigation/native'
5
5
  import { OText, OButton } from '../shared'
6
- import { NotFoundSource } from '../NotFoundSource'
7
6
  import { ActiveOrders } from '../ActiveOrders'
8
7
  import { PreviousOrders } from '../PreviousOrders'
9
8
  import { PreviousBusinessOrdered } from './PreviousBusinessOrdered'
@@ -70,23 +69,25 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
70
69
  const _orders = customArray || values || []
71
70
  const uniqueOrders: any = []
72
71
 
73
-
74
72
  useEffect(() => {
75
73
  if (loading || error) return
76
74
  const ordersReduced = _orders.map((order: any) => order?.cart_group_id
77
- ? _orders
78
- ?.filter((_order : any) => _order?.cart_group_id === order?.cart_group_id)
79
- ?.reduce((orderCompleted : any, currentOrder : any) => ({
80
- ...orderCompleted,
81
- total: orderCompleted.summary?.total + currentOrder?.summary?.total,
82
- business: [orderCompleted.business, currentOrder.business].flat(),
83
- business_id: [orderCompleted.business_id, currentOrder.business_id].flat(),
84
- id: [orderCompleted.id, currentOrder.id].flat(),
85
- review: orderCompleted.review && currentOrder.review,
86
- user_review: orderCompleted.user_review && currentOrder.user_review,
87
- products: [orderCompleted.products, currentOrder.products].flat()
88
- }))
89
- : order)
75
+ ? _orders
76
+ .filter((_order: any) => _order?.cart_group_id === order?.cart_group_id)
77
+ .map((_o: any, _: any, _ordersList: any) => {
78
+ const obj = {
79
+ ..._o,
80
+ id: _ordersList.map(o => o.id),
81
+ review: _o.review,
82
+ user_review: _o.user_review,
83
+ total: _ordersList.reduce((acc: any, o: any) => acc + o.summary.total, 0),
84
+ business: _ordersList.map((o: any) => o.business),
85
+ business_id: _ordersList.map((o: any) => o.business_id),
86
+ products: _ordersList.map((o: any) => o.products)
87
+ }
88
+ return obj
89
+ }).find((o: any) => o)
90
+ : order)
90
91
  const orders = ordersReduced?.filter((order: any) => {
91
92
  if (!order?.cart_group_id) return true
92
93
  const isDuplicate = uniqueOrders.includes(order?.cart_group_id)
@@ -191,7 +192,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
191
192
 
192
193
  </NoOrdersWrapper>
193
194
  )}
194
- {(ordersLength?.activeOrdersLength > 0 || ordersLength?.previousOrdersLength > 0) && (
195
+ {((ordersLength?.activeOrdersLength > 0 && activeOrders) || (ordersLength?.previousOrdersLength > 0 && !activeOrders)) && (
195
196
  <>
196
197
  {((titleContent && ((isBusiness && businessOrderIds?.length > 0) || isProducts)) || !titleContent) && (
197
198
  <OptionTitle titleContent={!!titleContent} isBusinessesSearchList={!!businessesSearchList}>
@@ -204,17 +205,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
204
205
  </OText>
205
206
  </OptionTitle>
206
207
  )}
207
-
208
- {!(ordersLength?.activeOrdersLength === 0 && ordersLength?.previousOrdersLength === 0) &&
209
- !loading &&
210
- orders.filter((order: any) => orderStatus.includes(order.status)).length === 0 &&
211
- (
212
- <NotFoundSource
213
- content={t('NO_RESULTS_FOUND', 'Sorry, no results found')}
214
- image={imageFails}
215
- conditioned
216
- />
217
- )}
218
208
  </>
219
209
  )}
220
210
  {isBusiness && !!businessesSearchList && businesses?.loading && (
@@ -16,4 +16,5 @@ export const DurationWrapper = styled.View`
16
16
 
17
17
  export const Container = styled.View`
18
18
  padding-top: ${(props: any) => props.pdng};
19
+ margin-bottom: 50px;
19
20
  `
@@ -11,8 +11,8 @@ import {
11
11
  } from 'ordering-components/native';
12
12
  import { useTheme } from 'styled-components/native';
13
13
  import { SingleProductCardParams } from '../../types';
14
- import { CardInfo, SoldOut, QuantityContainer, PricesContainer, RibbonBox, LogoWrapper, WrapTags, TagsContainer } from './styles';
15
- import { StyleSheet, View } from 'react-native';
14
+ import { CardInfo, SoldOut, QuantityContainer, PricesContainer, RibbonBox, LogoWrapper, TagsContainer } from './styles';
15
+ import { ScrollView, StyleSheet, TouchableWithoutFeedback, View } from 'react-native';
16
16
  import { InView } from 'react-native-intersection-observer'
17
17
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
18
18
  import { OButton, OIcon, OText } from '../shared';
@@ -104,7 +104,7 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
104
104
  color: '#808080',
105
105
  textDecorationLine: 'line-through',
106
106
  marginLeft: 7,
107
- marginRight: 7
107
+ marginRight: 0
108
108
  },
109
109
  productTagsStyle: {
110
110
  width: 30,
@@ -215,21 +215,29 @@ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
215
215
  {product?.offer_price !== null && !!product?.in_offer && (
216
216
  <OText style={styles.regularPriceStyle}>{product?.offer_price ? parsePrice(product?.offer_price) : ''}</OText>
217
217
  )}
218
- {product?.tags && product?.tags.length > 0 && (
219
- <WrapTags>
218
+ {!isPreviously && product?.tags && product?.tags.length > 0 && (
219
+ <ScrollView
220
+ showsVerticalScrollIndicator={false}
221
+ showsHorizontalScrollIndicator={false}
222
+ horizontal
223
+ style={{ marginLeft: 10 }}
224
+ contentContainerStyle={{flexGrow: 1}}
225
+ >
220
226
  {product?.tags.map((tag: any, i: any) => (
221
- <TagsContainer key={i}>
222
- <FastImage
223
- style={styles.productTagsStyle}
224
- source={tag.image ? {
225
- uri: optimizeImage(tag.image, 'h_250,c_limit'),
226
- priority: FastImage.priority.normal,
227
- } : theme?.images?.dummies?.product}
228
- resizeMode={FastImage.resizeMode.cover}
229
- />
230
- </TagsContainer>
227
+ <TouchableWithoutFeedback key={i}>
228
+ <TagsContainer>
229
+ <FastImage
230
+ style={styles.productTagsStyle}
231
+ source={tag.image ? {
232
+ uri: optimizeImage(tag.image, 'h_250,c_limit'),
233
+ priority: FastImage.priority.normal,
234
+ } : theme?.images?.dummies?.product}
235
+ resizeMode={FastImage.resizeMode.cover}
236
+ />
237
+ </TagsContainer>
238
+ </TouchableWithoutFeedback>
231
239
  ))}
232
- </WrapTags>
240
+ </ScrollView>
233
241
  )}
234
242
  </PricesContainer>
235
243
  {!hideProductDescription && (
@@ -33,6 +33,7 @@ export const LogoWrapper = styled.View`
33
33
  export const WrapTags = styled.View`
34
34
  display: flex;
35
35
  flex-direction: row;
36
+ justify-content: flex-start;
36
37
  margin-left: 10px;
37
38
  `
38
39
  export const TagsContainer = styled.View`