ordering-ui-react-native 0.17.81 → 0.17.83

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.81",
3
+ "version": "0.17.83",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -172,7 +172,7 @@ const AddressListUI = (props: AddressListParams) => {
172
172
  onActionLeft={() => goToBack()}
173
173
  showCall={false}
174
174
  btnStyle={{ paddingLeft: 0 }}
175
- paddingTop={0}
175
+ paddingTop={10}
176
176
  style={{ marginTop: 0 }}
177
177
  titleWrapStyle={{ paddingHorizontal: 0 }}
178
178
  titleStyle={{ marginLeft: 0, marginRight: 0 }}
@@ -191,7 +191,8 @@ export const BusinessListingSearchUI = (props: BusinessSearchParams) => {
191
191
 
192
192
  const isInteger = (val: any) => Number.isInteger(Number(val)) && !!val
193
193
 
194
- const onProductClick = (business: any, categoryId: any, productId: any) => {
194
+
195
+ const onProductClick = (business: any, categoryId: any, productId: any, product: any) => {
195
196
  if (!isInteger(business?.id) ||
196
197
  !isInteger(categoryId) ||
197
198
  !isInteger(productId) ||
@@ -199,17 +200,20 @@ export const BusinessListingSearchUI = (props: BusinessSearchParams) => {
199
200
  showToast(ToastType.error, t('NOT_AVAILABLE', 'Not Available'))
200
201
  return
201
202
  }
202
-
203
+ const currentCart: any = Object.values(orderState.carts).find((cart: any) => cart?.business?.slug === business?.slug) ?? {}
204
+ const productAddedToCartLength = currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === productId ? Cproduct?.quantity : 0) }, 0) || 0
203
205
  navigation.navigate('ProductDetails', {
204
206
  isRedirect: 'business',
205
207
  businessId: business?.id,
206
208
  categoryId: categoryId,
207
209
  productId: productId,
210
+ product: product,
208
211
  business: {
209
212
  store: business.slug,
210
213
  header: business.header,
211
214
  logo: business.logo,
212
- }
215
+ },
216
+ productAddedToCartLength
213
217
  })
214
218
  }
215
219
 
@@ -293,7 +297,6 @@ export const BusinessListingSearchUI = (props: BusinessSearchParams) => {
293
297
  />
294
298
  </View>
295
299
  ))}
296
- {console.log(screenWidth)}
297
300
  {!businessesSearchList.loading && paginationProps?.totalPages && paginationProps?.currentPage < paginationProps?.totalPages && (
298
301
  <LoadMoreBusinessContainer>
299
302
  <OButton
@@ -361,7 +364,7 @@ export const BusinessListingSearchUI = (props: BusinessSearchParams) => {
361
364
  product={product}
362
365
  enableIntersection={false}
363
366
  businessId={business?.id}
364
- onProductClick={(product: any) => onProductClick(business, category?.id, product?.id)}
367
+ onProductClick={(product: any) => onProductClick(business, category?.id, product?.id, product)}
365
368
  productAddedToCartLength={0}
366
369
  handleUpdateProducts={(productId: number, changes: any) => handleUpdateProducts(productId, category?.id, business?.id, changes)}
367
370
  style={{ width: screenWidth - 80, maxWidth: screenWidth - 80, marginRight: 20 }}
@@ -16,7 +16,7 @@ import {
16
16
  PlaceholderLine,
17
17
  Fade
18
18
  } from "rn-placeholder";
19
- import { View, BackHandler } from 'react-native'
19
+ import { View, BackHandler, Platform } from 'react-native'
20
20
  import {
21
21
  MessageListingWrapper,
22
22
  MessageContainer
@@ -77,7 +77,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
77
77
  { key: 20, value: t('ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS', 'Customer almost arrived to business') },
78
78
  { key: 21, value: t('ORDER_CUSTOMER_ARRIVED_BUSINESS', 'Customer arrived to business') },
79
79
  { key: 22, value: t('ORDER_LOOKING_FOR_DRIVER', 'Looking for driver') },
80
- { key: 23, value: t('ORDER_DRIVER_ON_WAY', 'Driver on way') }
80
+ { key: 23, value: t('ORDER_DRIVER_ON_WAY', 'Driver on way') }
81
81
  ]
82
82
 
83
83
  const objectStatus = orderStatus.find((o) => o.key === status)
@@ -102,7 +102,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
102
102
  }, [orderList, loading])
103
103
 
104
104
  useEffect(() => {
105
- if(refreshOrders){
105
+ if (refreshOrders) {
106
106
  loadOrders(false, false, false, true)
107
107
  setRefreshOrders && setRefreshOrders(false)
108
108
  }
@@ -225,7 +225,7 @@ const OrderMessageUI = (props: any) => {
225
225
  }
226
226
 
227
227
  export const OrderListing = (props: OrdersOptionParams) => {
228
- const [businessState] = useBusiness();
228
+ const [businessState] = useBusiness();
229
229
  const OrderListingProps = {
230
230
  ...props,
231
231
  UIComponent: OrdersOptionUI,
@@ -236,7 +236,7 @@ export const OrderListing = (props: OrdersOptionParams) => {
236
236
  pageSize: 10,
237
237
  controlType: 'infinity'
238
238
  },
239
- businessId: businessState?.business?.id,
239
+ businessId: businessState?.business?.id,
240
240
  profileMessages: true,
241
241
  orderBy: 'last_direct_message_at',
242
242
  orderDirection: 'asc'
@@ -292,7 +292,7 @@ export const MessageListing = (props: MessageListingParams) => {
292
292
  titleAlign={'center'}
293
293
  onActionLeft={goToBack}
294
294
  showCall={false}
295
- paddingTop={10}
295
+ paddingTop={Platform.OS === 'ios' ? 20 : 10}
296
296
  btnStyle={{ paddingLeft: 0 }}
297
297
  />
298
298
  <OrderListing
@@ -300,7 +300,7 @@ export const MessageListing = (props: MessageListingParams) => {
300
300
  setSelectedOrderId={setSelectedOrderId}
301
301
  setOrderList={setOrderListStatus}
302
302
  setOpenMessges={setOpenMessges}
303
- franchiseId={props.franchiseId}
303
+ franchiseId={props.franchiseId}
304
304
  />
305
305
  {openMessages && seletedOrder && (
306
306
  <OModal
@@ -13,7 +13,8 @@ import IconAntDesign from 'react-native-vector-icons/AntDesign'
13
13
  import {
14
14
  StyleSheet,
15
15
  View,
16
- TouchableOpacity
16
+ TouchableOpacity,
17
+ Platform
17
18
  } from 'react-native';
18
19
  import Spinner from 'react-native-loading-spinner-overlay';
19
20
  import { MomentOptionParams } from '../../types';
@@ -263,6 +264,7 @@ const MomentOptionUI = (props: MomentOptionParams) => {
263
264
  onActionLeft={() => goToBack()}
264
265
  btnStyle={{ paddingLeft: 0 }}
265
266
  style={{ paddingBottom: 0 }}
267
+ paddingTop={Platform.OS === 'ios' ? 10 : 0}
266
268
  title={t('QUESTION_WHEN_ORDER', 'When do you want your order?')}
267
269
  titleAlign={'center'}
268
270
  titleStyle={{ fontSize: 20, marginRight: 0, marginLeft: 0 }}
@@ -96,7 +96,7 @@ const OrderTypeSelectorUI = (props: OrderTypeSelectParams) => {
96
96
  <NavBar
97
97
  onActionLeft={() => goToBack()}
98
98
  btnStyle={{ paddingLeft: 0, width: 50 }}
99
- paddingTop={0}
99
+ paddingTop={Platform.OS === 'ios' ? 10 : 0}
100
100
  style={{ paddingBottom: 0 }}
101
101
  title={t('HOW_WILL_YOU_DELIVERY_TYPE', 'How will your order type?')}
102
102
  titleAlign={'center'}
@@ -169,9 +169,8 @@ export const ProductOptionsUI = (props: any) => {
169
169
  marginTop: 10
170
170
  },
171
171
  wrapperNavbar: {
172
- paddingVertical: 0,
173
172
  paddingHorizontal: 40,
174
- marginVertical: 2
173
+ paddingTop: 0,
175
174
  }
176
175
  });
177
176
 
@@ -219,7 +218,7 @@ export const ProductOptionsUI = (props: any) => {
219
218
  showToast(ToastType.Error, t('VALIDATION_ERROR_REQUIRED', 'The quantity field is required').replace('_attribute_', t('PRODUCT_POTIONS_QUANTITY', 'Quantity')))
220
219
  return
221
220
  }
222
- const isErrors = Object.values(errors).length > 0;
221
+ const isErrors = Object.values(errors)?.length > 0;
223
222
  if (!isErrors) {
224
223
  handleSave && handleSave();
225
224
  return;
@@ -238,7 +237,7 @@ export const ProductOptionsUI = (props: any) => {
238
237
  };
239
238
 
240
239
  const handleChangeMainIndex = (index: number) => {
241
- if (index < 0 || index > gallery.length - 1) {
240
+ if (index < 0 || index > gallery?.length - 1) {
242
241
  setThumbsSwiper(0)
243
242
  return
244
243
  }
@@ -281,7 +280,7 @@ export const ProductOptionsUI = (props: any) => {
281
280
  }
282
281
 
283
282
  const scrollDown = (id: any) => {
284
- const isErrors = Object.values(errors).length > 0
283
+ const isErrors = Object.values(errors)?.length > 0
285
284
  if (!isErrors) {
286
285
  return
287
286
  }
@@ -305,7 +304,7 @@ export const ProductOptionsUI = (props: any) => {
305
304
  const saveErrors =
306
305
  orderState.loading ||
307
306
  maxProductQuantity === 0 ||
308
- Object.keys(errors).length > 0;
307
+ Object.keys(errors)?.length > 0;
309
308
 
310
309
 
311
310
  const ExtraOptions = ({ eID, options }: any) => (
@@ -372,14 +371,14 @@ export const ProductOptionsUI = (props: any) => {
372
371
  ? product.images
373
372
  : theme?.images?.dummies?.product)
374
373
 
375
- if (product?.gallery && product?.gallery.length > 0) {
374
+ if (product?.gallery && product?.gallery?.length > 0) {
376
375
  for (const img of product?.gallery) {
377
376
  if (img?.file) {
378
377
  imageList.push(img?.file)
379
378
  }
380
379
  if (img?.video) {
381
380
  const keys = img?.video.split('/')
382
- let _videoId = keys[keys.length - 1]
381
+ let _videoId = keys[keys?.length - 1]
383
382
 
384
383
  if (_videoId.includes('watch')) {
385
384
  const __url = _videoId.split('=')[1]
@@ -394,7 +393,7 @@ export const ProductOptionsUI = (props: any) => {
394
393
  } else if (_videoId.search(/\?/i) >= 0) {
395
394
  _videoId = _videoId.split('?')[0]
396
395
  }
397
- if ((_videoId.length === 11)) {
396
+ if ((_videoId?.length === 11)) {
398
397
  videoList.push(_videoId)
399
398
  }
400
399
  }
@@ -495,9 +494,8 @@ export const ProductOptionsUI = (props: any) => {
495
494
  <NavBar
496
495
  onActionLeft={() => handleGoBack()}
497
496
  showCall={false}
498
- btnStyle={{ paddingLeft: 0, paddingTop: Platform.OS == 'ios' ? 0 : 2 }}
499
- titleWrapStyle={{ paddingHorizontal: 0 }}
500
- titleStyle={{ marginRight: 0, marginLeft: 0 }}
497
+ btnStyle={{ paddingLeft: 0 }}
498
+ paddingTop={4}
501
499
  />
502
500
  </View>
503
501
  {!error && (
@@ -548,7 +546,7 @@ export const ProductOptionsUI = (props: any) => {
548
546
  </View>
549
547
  }
550
548
  >
551
- {gallery && gallery.length > 0 && gallery.map((img, i) => (
549
+ {gallery && gallery?.length > 0 && gallery.map((img, i) => (
552
550
  <View
553
551
  style={styles.slide1}
554
552
  key={i}
@@ -583,7 +581,7 @@ export const ProductOptionsUI = (props: any) => {
583
581
  paddingVertical: 15
584
582
  }}
585
583
  >
586
- {gallery.length > 0 && gallery.map((img, index) => (
584
+ {gallery?.length > 0 && gallery.map((img, index) => (
587
585
  <TouchableOpacity
588
586
  key={index}
589
587
  onPress={() => handleClickThumb(index)}
@@ -738,7 +736,7 @@ export const ProductOptionsUI = (props: any) => {
738
736
  backgroundColor: theme.colors.backgroundPage,
739
737
  }}
740
738
  >
741
- {product?.ingredients.length > 0 && (
739
+ {product?.ingredients?.length > 0 && (
742
740
  <TouchableOpacity
743
741
  key={`eopt_key_01`}
744
742
  onPress={() => {
@@ -763,7 +761,7 @@ export const ProductOptionsUI = (props: any) => {
763
761
  </OText>
764
762
  </TouchableOpacity>
765
763
  )}
766
- {product?.extras.map((extra: any) =>
764
+ {product?.extras?.map((extra: any) =>
767
765
  <ExtraOptions key={extra.id} options={extra.options} />
768
766
  )}
769
767
  </ExtraOptionWrap>
@@ -814,7 +812,7 @@ export const ProductOptionsUI = (props: any) => {
814
812
  }}
815
813
  >
816
814
  <>
817
- {product?.ingredients.length > 0 && (
815
+ {product?.ingredients?.length > 0 && (
818
816
  <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, 0)}>
819
817
  <SectionTitle>
820
818
  <OText size={16}>
@@ -836,8 +834,8 @@ export const ProductOptionsUI = (props: any) => {
836
834
  </WrapperIngredients>
837
835
  </View>
838
836
  )}
839
- {product?.extras.sort((a: any, b: any) => a.rank - b.rank).map((extra: any) =>
840
- extra.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
837
+ {product?.extras?.sort((a: any, b: any) => a.rank - b.rank).map((extra: any) =>
838
+ extra.options?.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
841
839
  const currentState =
842
840
  productCart.options[`id:${option.id}`] || {};
843
841
  return (
@@ -853,7 +851,7 @@ export const ProductOptionsUI = (props: any) => {
853
851
  backgroundColor: isError(option.id),
854
852
  borderRadius: 7.6
855
853
  }}>
856
- {option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map(
854
+ {option?.suboptions?.sort((a: any, b: any) => a.rank - b.rank).map(
857
855
  (suboption: any) => {
858
856
  const currentState =
859
857
  productCart.options[
@@ -918,7 +916,7 @@ export const ProductOptionsUI = (props: any) => {
918
916
  )}
919
917
  </ProductEditions>
920
918
  )}
921
- {!!error && error.length > 0 && (
919
+ {!!error && error?.length > 0 && (
922
920
  <NotFoundSource content={error[0]?.message || error[0]} />
923
921
  )}
924
922
  </ScrollView>