ordering-ui-react-native 0.16.15 → 0.16.18

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.15",
3
+ "version": "0.16.18",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -276,7 +276,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
276
276
  };
277
277
  }, [])
278
278
 
279
-
280
279
  return (
281
280
  <OrderDetailsContainer keyboardShouldPersistTaps='handled'>
282
281
  {order && order?.id && !error && !loading && (
@@ -400,6 +399,11 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
400
399
  <InfoBlock>
401
400
  <OText size={18} style={{ textAlign: 'left' }} >{order?.customer?.name} {order?.customer?.lastname}</OText>
402
401
  <OText style={{ textAlign: 'left' }}>{order?.customer?.address}</OText>
402
+ {(!!order?.customer?.cellphone) && (
403
+ <OText size={18} style={{ textAlign: 'left' }}>
404
+ {(order?.customer?.country_phone_code) && `+${(order?.customer?.country_phone_code)} `}{(order?.customer?.cellphone)}
405
+ </OText>
406
+ )}
403
407
  </InfoBlock>
404
408
  </Customer>
405
409
  {order?.delivery_option !== undefined && order?.delivery_type === 1 && (
@@ -274,8 +274,8 @@ export const OrderContentComponent = (props: OrderContent) => {
274
274
  <View style={styles.linkWithIcons}>
275
275
  <OLink
276
276
  PressStyle={styles.linkWithIcons}
277
- url={`tel:${order?.customer?.cellphone}`}
278
- shorcut={order?.customer?.cellphone}
277
+ url={`tel:${!!order?.customer?.country_phone_code ? '+' + order?.customer?.country_phone_code : ''} ${order?.customer?.cellphone}`}
278
+ shorcut={`${!!order?.customer?.country_phone_code ? '+' + order?.customer?.country_phone_code : ''} ${order?.customer?.cellphone}`}
279
279
  TextStyle={styles.textLink}
280
280
  />
281
281
  </View>
@@ -45,7 +45,7 @@ export const BusinessItemAccordion = (props: any) => {
45
45
  }, [orderState?.carts])
46
46
 
47
47
  return (
48
- <BIContainer isClosed={isClosed} checkoutVisible={!isActive && !isClosed && !!isProducts && !checkoutButtonDisabled}>
48
+ <BIContainer isClosed={isClosed} isMultiCheckout={isMultiCheckout} checkoutVisible={!isActive && !isClosed && !!isProducts && !checkoutButtonDisabled}>
49
49
  <BIHeader
50
50
  isClosed={isClosed}
51
51
  onPress={() => !isClosed ? setActiveState(!isActive) : isClosed}
@@ -7,8 +7,12 @@ export const BIContainer = styled.View`
7
7
  opacity: 1;
8
8
  border-radius: 7.6px;
9
9
  overflow: hidden;
10
+ ${(props: any) => !props.isMultiCheckout && css`
11
+ min-height: 120px;
12
+ `}
10
13
  ${(props: any) => props.isClosed && css`
11
14
  opacity: 0.5;
15
+ min-height: 60px;
12
16
  `}
13
17
  `
14
18
 
@@ -124,6 +124,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
124
124
  isSoldOut={product.inventoried && !product.quantity}
125
125
  product={product}
126
126
  businessId={businessId}
127
+ categoryState={categoryState}
127
128
  onProductClick={() => onProductClick(product)}
128
129
  productAddedToCartLength={currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0)}
129
130
  handleUpdateProducts={handleUpdateProducts}
@@ -148,6 +149,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
148
149
  isSoldOut={product.inventoried && !product.quantity}
149
150
  product={product}
150
151
  businessId={businessId}
152
+ categoryState={categoryState}
151
153
  onProductClick={onProductClick}
152
154
  handleUpdateProducts={handleUpdateProducts}
153
155
  productAddedToCartLength={currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0)}
@@ -236,10 +238,11 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
236
238
  <>
237
239
  {products.sort((a: any, b: any) => a.rank - b.rank).map((product: any, i: any) => (
238
240
  <SingleProductCard
239
- key={i}
241
+ key={`${product?.id}_${i}`}
240
242
  isSoldOut={product.inventoried && !product.quantity}
241
243
  businessId={businessId}
242
244
  product={product}
245
+ categoryState={categoryState}
243
246
  onProductClick={onProductClick}
244
247
  handleUpdateProducts={handleUpdateProducts}
245
248
  productAddedToCartLength={currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0)}
@@ -256,6 +256,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
256
256
 
257
257
  {business?.categories?.length > 0 && isOpenFiltProducts && (
258
258
  <FiltProductsContainer
259
+ isIos={Platform.OS === 'ios'}
259
260
  style={{
260
261
  height: Dimensions.get('window').height - filtProductsHeight
261
262
  }}
@@ -285,6 +286,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
285
286
  currentCart={currentCart}
286
287
  setSubcategoriesSelected={setSubcategoriesSelected}
287
288
  onClickCategory={handleChangeCategory}
289
+ handleUpdateProducts={handleUpdateProducts}
288
290
  isFiltMode
289
291
  />
290
292
  </View>
@@ -252,7 +252,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
252
252
  }
253
253
  >
254
254
  <HeaderWrapper
255
- source={theme.images.general.homeHero}
255
+ source={theme.images.backgrounds.business_list_header}
256
256
  style={{ paddingTop: top + 20 }}>
257
257
  {!auth && (
258
258
  <TouchableOpacity onPress={() => navigation?.canGoBack() && navigation.goBack()} style={{ position: 'absolute', marginStart: 40, paddingVertical: 20 }}>
@@ -418,31 +418,35 @@ const CartUI = (props: any) => {
418
418
  )}
419
419
  </OSBill>
420
420
  )}
421
- {cart?.valid_products ? (
422
- <CheckoutAction>
423
- <OButton
424
- text={(cart?.subtotal >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
425
- !openUpselling !== canOpenUpselling ? t('CHECKOUT', 'Checkout') : t('LOADING', 'Loading')
426
- ) : !cart?.valid_address ? (
427
- `${t('OUT_OF_COVERAGE', 'Out of Coverage')}`
428
- ) : (
429
- `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`
430
- )}
431
- bgColor={(cart?.subtotal < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
432
- isDisabled={(openUpselling && !canOpenUpselling) || cart?.subtotal < cart?.minimum || !cart?.valid_address}
433
- borderColor={theme.colors.primary}
434
- imgRightSrc={null}
435
- textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
436
- onClick={() => setOpenUpselling(true)}
437
- style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
438
- />
439
- </CheckoutAction>
440
- ) : (
441
- <View style={{ alignItems: 'center', width: '100%' }}>
442
- <OText size={12} color={theme.colors.red} style={{ textAlign: 'center', marginTop: 5 }}>
443
- {t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
444
- </OText>
445
- </View>
421
+ {!isMultiCheckout && (
422
+ <>
423
+ {cart?.valid_products ? (
424
+ <CheckoutAction>
425
+ <OButton
426
+ text={(cart?.subtotal >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
427
+ !openUpselling !== canOpenUpselling ? t('CHECKOUT', 'Checkout') : t('LOADING', 'Loading')
428
+ ) : !cart?.valid_address ? (
429
+ `${t('OUT_OF_COVERAGE', 'Out of Coverage')}`
430
+ ) : (
431
+ `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`
432
+ )}
433
+ bgColor={(cart?.subtotal < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
434
+ isDisabled={(openUpselling && !canOpenUpselling) || cart?.subtotal < cart?.minimum || !cart?.valid_address}
435
+ borderColor={theme.colors.primary}
436
+ imgRightSrc={null}
437
+ textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
438
+ onClick={() => setOpenUpselling(true)}
439
+ style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
440
+ />
441
+ </CheckoutAction>
442
+ ) : (
443
+ <View style={{ alignItems: 'center', width: '100%' }}>
444
+ <OText size={12} color={theme.colors.red} style={{ textAlign: 'center', marginTop: 5 }}>
445
+ {t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
446
+ </OText>
447
+ </View>
448
+ )}
449
+ </>
446
450
  )}
447
451
  </BusinessItemAccordion>
448
452
 
@@ -194,9 +194,9 @@ const FavoriteListUI = (props: FavoriteParams) => {
194
194
  ))
195
195
  )}
196
196
  {!favoriteList?.loading && favoriteList?.favorites?.length > 0 && (
197
- favoriteList.favorites.map((order: any) => (
197
+ favoriteList.favorites.map((order: any, i: number) => (
198
198
  <SingleOrderCard
199
- key={order?.id}
199
+ key={`${order?.id}_${i}`}
200
200
  order={order}
201
201
  getOrderStatus={getOrderStatus}
202
202
  onNavigationRedirect={onNavigationRedirect}
@@ -231,9 +231,9 @@ const FavoriteListUI = (props: FavoriteParams) => {
231
231
  ))
232
232
  )}
233
233
  {!favoriteList?.loading && favoriteList?.favorites?.length > 0 && (
234
- favoriteList.favorites.map((product: any) => (
234
+ favoriteList.favorites.map((product: any, i: number) => (
235
235
  <SingleProductCard
236
- key={product?.id}
236
+ key={`${product?.id}_${i}`}
237
237
  isSoldOut={product.inventoried && !product.quantity}
238
238
  product={product}
239
239
  onProductClick={() => {}}
@@ -107,7 +107,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
107
107
  {t('PAYMENT_METHODS', 'Payment Methods')}
108
108
  </OText>
109
109
  {paymethodsAndWallets.loading ? (
110
- <Placeholder style={{ marginTop: 10 }} Animation={Fade}>
110
+ <Placeholder style={{ marginTop: 10, marginBottom: 10 }} Animation={Fade}>
111
111
  <View style={{ display: 'flex', flexDirection: 'row' }}>
112
112
  {[...Array(3)].map((_, i) => (
113
113
  <PlaceholderLine
@@ -115,7 +115,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
115
115
  width={37}
116
116
  height={80}
117
117
  noMargin
118
- style={{ borderRadius: 10, marginRight: 10 }}
118
+ style={{ borderRadius: 10, marginRight: 10, }}
119
119
  />
120
120
  ))}
121
121
  </View>
@@ -77,7 +77,8 @@ const MultiCheckoutUI = (props: any) => {
77
77
 
78
78
  const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
79
79
  const isPreOrder = configs?.preorder_status_enabled?.value === '1'
80
- const isDisablePlaceOrderButton = !(paymethodSelected?.paymethod_id || paymethodSelected?.wallet_id) || placing
80
+ const maximumCarts = 5
81
+ const isDisablePlaceOrderButton = !(paymethodSelected?.paymethod_id || paymethodSelected?.wallet_id) || openCarts.length > maximumCarts
81
82
 
82
83
  const [isUserDetailsEdit, setIsUserDetailsEdit] = useState(false);
83
84
  const [phoneUpdate, setPhoneUpdate] = useState(false);
@@ -240,6 +241,7 @@ const MultiCheckoutUI = (props: any) => {
240
241
  cart={cart}
241
242
  cartuuid={cart.uuid}
242
243
  isMultiCheckout
244
+ onNavigationRedirect={(route: string, params: any) => props.navigation.navigate(route, params)}
243
245
  />
244
246
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
245
247
  </React.Fragment>
@@ -264,6 +266,11 @@ const MultiCheckoutUI = (props: any) => {
264
266
  </OText>
265
267
  </ChCartsTotal>
266
268
  )}
269
+ {openCarts.length > maximumCarts && (
270
+ <OText size={14} color={theme.colors.danger5} style={{ marginVertical: 20 }}>
271
+ {t('WARNING_MAXIMUM_CARTS', 'You can only pay for a maximum of 5 carts, please discard one or more to continue.')}
272
+ </OText>
273
+ )}
267
274
  </ChCarts>
268
275
  </ChSection>
269
276
  </ChContainer>
@@ -258,25 +258,27 @@ const SingleOrderCardUI = (props: any) => {
258
258
  return (
259
259
  <SingleOrderContainer>
260
260
  <View style={{ flexDirection: 'row', justifyContent: 'space-between', marginBottom: 35 }}>
261
- <View>
261
+ <View style={{ flex: 1, marginRight: 10 }}>
262
262
  <OText size={16} lineHeight={24} mBottom={5} weight={'500'} color={theme.colors.textNormal}>
263
263
  {t('ORDER', 'Order')} #{order.id}
264
264
  </OText>
265
- <View style={{ flexDirection: 'row', alignItems: 'center' }}>
265
+ <View style={{ flexDirection: 'row' }}>
266
266
  <OText size={12} lineHeight={18} color={theme.colors.textNormal}>{orderTypes?.find((type: any) => order?.delivery_type === type?.value)?.text}:</OText>
267
- <OText mLeft={10} size={12} lineHeight={18} color={theme.colors.textNormal}>
268
- {
269
- order?.delivery_datetime_utc
270
- ? parseDate(order?.delivery_datetime_utc)
271
- : parseDate(order?.delivery_datetime, { utc: false })
272
- }
273
- </OText>
267
+ <View style={{ flex: 1 }}>
268
+ <OText mLeft={5} size={12} lineHeight={18} color={theme.colors.textNormal}>
269
+ {
270
+ order?.delivery_datetime_utc
271
+ ? parseDate(order?.delivery_datetime_utc)
272
+ : parseDate(order?.delivery_datetime, { utc: false })
273
+ }
274
+ </OText>
275
+ </View>
274
276
  </View>
275
277
  </View>
276
278
  <OButton
277
279
  onClick={() => handleGoToOrderDetails(order?.uuid)}
278
- textStyle={{ color: theme.colors.primary, textAlign: 'center' }}
279
- style={{ flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
280
+ textStyle={{ color: theme.colors.primary, textAlign: 'center', fontSize: 14 }}
281
+ style={{ flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0, paddingLeft: 5, paddingRight: 5, height: 44 }}
280
282
  text={t('ORDER_DETAILS', 'Order Details')}
281
283
  bgColor={theme.colors.white}
282
284
  borderColor={theme.colors.primary}
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect } from 'react'
2
2
  import { useLanguage, useUtils, useToast, ToastType, MultiOrdersDetails as MultiOrdersDetailsController } from 'ordering-components/native'
3
- import { View, StyleSheet } from 'react-native'
3
+ import { View, StyleSheet, BackHandler } from 'react-native'
4
4
  import { useTheme } from 'styled-components/native'
5
5
  import { OText, OButton } from '../shared'
6
6
  import { Container } from '../../layouts/Container'
@@ -53,12 +53,13 @@ export const MultiOrdersDetailsUI = (props: any) => {
53
53
  }
54
54
  }
55
55
 
56
- const handleBackNavigation = () => {
56
+ const handleArrowBack: any = () => {
57
57
  if (!isFromMultiCheckout) {
58
58
  navigation?.canGoBack() && navigation.goBack();
59
59
  return;
60
60
  }
61
- navigation.navigate('BottomTab');
61
+ navigation.navigate('BusinessList');
62
+ return true
62
63
  }
63
64
 
64
65
  const handleGoToOrderDetails = (uuid: any) => {
@@ -71,6 +72,13 @@ export const MultiOrdersDetailsUI = (props: any) => {
71
72
  }
72
73
  }, [error])
73
74
 
75
+ useEffect(() => {
76
+ BackHandler.addEventListener('hardwareBackPress', handleArrowBack)
77
+ return () => {
78
+ BackHandler.removeEventListener('hardwareBackPress', handleArrowBack)
79
+ }
80
+ }, [])
81
+
74
82
  return (
75
83
  <OrdersDetailsContainer keyboardShouldPersistTaps="handled" contentContainerStyle={{ paddingHorizontal: 40 }}>
76
84
  <View style={{ flexDirection: 'row' }}>
@@ -78,7 +86,7 @@ export const MultiOrdersDetailsUI = (props: any) => {
78
86
  imgLeftSrc={theme.images.general.arrow_left}
79
87
  imgRightSrc={null}
80
88
  style={styles.btnBackArrow}
81
- onClick={() => handleBackNavigation()}
89
+ onClick={() => handleArrowBack()}
82
90
  imgLeftStyle={{ tintColor: theme.colors.textNormal, width: 16 }}
83
91
  />
84
92
  </View>
@@ -663,13 +663,15 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
663
663
  mBottom={2}>
664
664
  {order?.customer?.address}
665
665
  </OText>
666
- <OText
667
- size={12}
668
- lineHeight={18}
669
- color={theme.colors.textNormal}
670
- mBottom={2}>
671
- {order?.customer?.cellphone}
672
- </OText>
666
+ {(!!order?.customer?.cellphone) && (
667
+ <OText
668
+ size={12}
669
+ lineHeight={18}
670
+ color={theme.colors.textNormal}
671
+ mBottom={2}>
672
+ {`${!!order?.customer?.country_phone_code ? '+' + order?.customer?.country_phone_code : ''} ${order?.customer?.cellphone}`}
673
+ </OText>
674
+ )}
673
675
  </InfoBlock>
674
676
  </Customer>
675
677
  {order?.delivery_option !== undefined && order?.delivery_type === 1 && (
@@ -156,9 +156,11 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
156
156
  )}
157
157
  <CardInfoWrapper>
158
158
  <ContentHeader>
159
- <OText size={12} lineHeight={18} weight={'600'} numberOfLines={1} ellipsizeMode={'tail'}>
160
- {order.business?.name}
161
- </OText>
159
+ <View style={{ flex: 1 }}>
160
+ <OText size={12} lineHeight={18} weight={'600'} numberOfLines={1} ellipsizeMode={'tail'}>
161
+ {order.business?.name}
162
+ </OText>
163
+ </View>
162
164
  {!!!pastOrders && (
163
165
  <>
164
166
  {isMessageView ? (
@@ -18,17 +18,19 @@ import { shape } from '../../utils';
18
18
  function SingleProductCardPropsAreEqual(prevProps : any, nextProps : any) {
19
19
  return JSON.stringify(prevProps.product) === JSON.stringify(nextProps.product) &&
20
20
  prevProps.isSoldOut === nextProps.isSoldOut &&
21
- prevProps.productAddedToCartLength === nextProps.productAddedToCartLength
21
+ prevProps.productAddedToCartLength === nextProps.productAddedToCartLength &&
22
+ prevProps.categoryState === nextProps.categoryState
22
23
  }
23
24
 
24
- const SinguleProductCardUI = (props: SingleProductCardParams) => {
25
+ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
25
26
  const {
26
27
  product,
27
28
  isSoldOut,
28
29
  onProductClick,
29
30
  productAddedToCartLength,
30
31
  style,
31
- handleFavoriteProduct
32
+ handleFavoriteProduct,
33
+ handleUpdateProducts
32
34
  } = props;
33
35
 
34
36
  const theme = useTheme();
@@ -210,12 +212,12 @@ const SinguleProductCardUI = (props: SingleProductCardParams) => {
210
212
  )}
211
213
  </CardContainer>
212
214
  );
213
- }
215
+ }, SingleProductCardPropsAreEqual);
214
216
 
215
- export const SingleProductCard = React.memo((props: SingleProductCardParams) => {
217
+ export const SingleProductCard = (props: SingleProductCardParams) => {
216
218
  const singleProductCardProps = {
217
219
  ...props,
218
220
  UIComponent: SinguleProductCardUI
219
221
  }
220
222
  return <SingleProductCardController {...singleProductCardProps} />
221
- }, SingleProductCardPropsAreEqual);
223
+ }
@@ -278,6 +278,7 @@ export interface SingleProductCardParams {
278
278
  onProductClick: any;
279
279
  productAddedToCartLength: number;
280
280
  style?: ViewStyle,
281
+ categoryState?: any,
281
282
  handleFavoriteProduct?: any,
282
283
  handleUpdateProducts?: any
283
284
  }