ordering-ui-react-native 0.18.55-test1 → 0.18.56-test

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.18.55-test1",
3
+ "version": "0.18.56-test",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -49,8 +49,8 @@
49
49
  "@react-navigation/material-bottom-tabs": "^5.3.14",
50
50
  "@react-navigation/native": "^5.7.6",
51
51
  "@react-navigation/stack": "^5.9.3",
52
- "@segment/analytics-react-native": "^2.13.2",
53
- "@segment/sovran-react-native": "^1.0.1",
52
+ "@segment/analytics-react-native": "^2.1.11",
53
+ "@segment/sovran-react-native": "^0.2.6",
54
54
  "@sentry/react-native": "^2.6.0",
55
55
  "@stripe/stripe-react-native": "^0.2.0",
56
56
  "@types/react-native-loading-spinner-overlay": "^0.5.2",
@@ -1,5 +1,8 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { createClient, AnalyticsProvider } from '@segment/analytics-react-native';
2
+ import {
3
+ createClient,
4
+ AnalyticsProvider
5
+ } from '@segment/analytics-react-native';
3
6
  import { useEvent, useConfig, useLanguage } from 'ordering-components/native';
4
7
 
5
8
  export const AnalyticsSegment = (props: any) => {
@@ -23,7 +23,7 @@ import { ActivityIndicator, TouchableOpacity, View } from 'react-native';
23
23
  import AntIcon from 'react-native-vector-icons/AntDesign'
24
24
  import { TaxInformation } from '../TaxInformation';
25
25
  import { CartStoresListing } from '../CartStoresListing';
26
- import { OAlert } from '../../../../../src/components/shared'
26
+ import { OAlert } from '../shared'
27
27
  import { PlaceSpot } from '../PlaceSpot'
28
28
  import { DriverTips } from '../DriverTips'
29
29
  import { MomentOption } from '../MomentOption'
@@ -67,7 +67,6 @@ const CartUI = (props: any) => {
67
67
  const [openChangeStore, setOpenChangeStore] = useState(false)
68
68
  const [canOpenUpselling, setCanOpenUpselling] = useState(false)
69
69
  const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null, type: '' })
70
- const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
71
70
  const [openPlaceModal, setOpenPlaceModal] = useState(false)
72
71
  const [maxDate, setMaxDate] = useState<any>(null)
73
72
  const isCartPending = cart?.status === 2
@@ -75,7 +74,6 @@ const CartUI = (props: any) => {
75
74
  const business: any = (orderState?.carts && Object.values(orderState.carts).find((_cart: any) => _cart?.uuid === props.cartuuid)) ?? {}
76
75
  const businessId = business?.business_id ?? null
77
76
  const placeSpotTypes = [4]
78
- const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
79
77
  const hideCartComments = theme?.business_view?.components?.cart?.components?.comments?.hidden
80
78
  const hideCartDiscount = theme?.business_view?.components?.cart?.components?.discount?.hidden
81
79
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
@@ -167,16 +165,16 @@ const CartUI = (props: any) => {
167
165
  return cart?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
168
166
  }
169
167
 
170
- const onRemoveOffer = (id: number) => {
171
- setConfirm({
172
- open: true,
173
- content: [t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')],
174
- title: t('OFFER', 'Offer'),
175
- handleOnAccept: () => {
176
- setConfirm({ ...confirm, open: false })
177
- handleRemoveOfferClick(id)
178
- }
179
- })
168
+ const OfferAlert = ({ offerId }: any) => {
169
+ return (
170
+ <OAlert
171
+ title={t('OFFER', 'Offer')}
172
+ message={t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')}
173
+ onAccept={() => handleRemoveOfferClick(offerId)}
174
+ >
175
+ <AntIcon style={{ marginLeft: 3 }} name='closecircle' size={16} color={theme.colors.primary} />
176
+ </OAlert>
177
+ )
180
178
  }
181
179
 
182
180
  const walletName: any = {
@@ -283,9 +281,7 @@ const CartUI = (props: any) => {
283
281
  <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
284
282
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
285
283
  </TouchableOpacity>
286
- <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
287
- <AntIcon name='closecircle' size={16} color={theme.colors.primary} />
288
- </TouchableOpacity>
284
+ <OfferAlert offerId={offer?.id} />
289
285
  </OSRow>
290
286
  <OText size={12} lineHeight={18}>
291
287
  - {parsePrice(offer?.summary?.discount)}
@@ -348,9 +344,7 @@ const CartUI = (props: any) => {
348
344
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
349
345
  </TouchableOpacity>
350
346
  {!offer?.type && (
351
- <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
352
- <AntIcon name='closecircle' size={16} color={theme.colors.primary} />
353
- </TouchableOpacity>
347
+ <OfferAlert offerId={offer?.id} />
354
348
  )}
355
349
  </OSRow>
356
350
  <OText size={12} lineHeight={18}>
@@ -376,9 +370,7 @@ const CartUI = (props: any) => {
376
370
  <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
377
371
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
378
372
  </TouchableOpacity>
379
- <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
380
- <AntIcon name='closecircle' size={16} color={theme.colors.primary} />
381
- </TouchableOpacity>
373
+ <OfferAlert offerId={offer?.id} />
382
374
  </OSRow>
383
375
  <OText size={12} lineHeight={18}>
384
376
  - {parsePrice(offer?.summary?.discount)}
@@ -591,14 +583,6 @@ const CartUI = (props: any) => {
591
583
  setOpenPlaceModal={setOpenPlaceModal}
592
584
  />
593
585
  </OModal>
594
- <OAlert
595
- open={confirm.open}
596
- title={confirm.title}
597
- content={confirm.content}
598
- onAccept={confirm.handleOnAccept}
599
- onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
600
- onClose={() => setConfirm({ ...confirm, open: false, title: null })}
601
- />
602
586
  </CContainer>
603
587
  )
604
588
  }
@@ -114,7 +114,9 @@ const MultiCheckoutUI = (props: any) => {
114
114
 
115
115
  const clearAmount = (value: any) => parseFloat((Math.trunc(value * 100) / 100).toFixed(configs.format_number_decimal_length?.value ?? 2))
116
116
 
117
- const loyaltyRewardValue = openCarts.reduce((sum: any, cart: any) => sum + clearAmount((cart?.subtotal + getIncludedTaxes(cart)) * accumulationRateBusiness(cart?.business_id)), 0)
117
+ const loyaltyRewardValue = openCarts
118
+ ?.reduce((sum: any, cart: any) => sum + clearAmount((cart?.subtotal + getIncludedTaxes(cart)) * accumulationRateBusiness(cart?.business_id)), 0)
119
+ ?.toFixed(configs.format_number_decimal_length?.value ?? 2)
118
120
 
119
121
  const [isUserDetailsEdit, setIsUserDetailsEdit] = useState(false);
120
122
  const [phoneUpdate, setPhoneUpdate] = useState(false);
@@ -320,7 +322,7 @@ const MultiCheckoutUI = (props: any) => {
320
322
  isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1}
321
323
  isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
322
324
  driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1
323
- ? openCarts[0]?.driver_tip
325
+ ? openCarts?.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0)
324
326
  : openCarts[0]?.driver_tip_rate}
325
327
  useOrderContext
326
328
  />
@@ -38,9 +38,12 @@ export const OrderEta = (props: any) => {
38
38
  }
39
39
  _estimatedTime = moment.utc(_delivery).add(totalEta, 'minutes')
40
40
  } else {
41
- _estimatedTime = moment.utc(_delivery).add(order?.eta_time, 'minutes')
41
+ let timesToAdd = 0
42
+ if (order?.delivered_in) timesToAdd += order?.delivered_in
43
+ if (order?.prepared_in) timesToAdd += order?.prepared_in
44
+ const _etaTime = order?.eta_time + timesToAdd
45
+ _estimatedTime = moment.utc(_delivery).add(_etaTime, 'minutes')
42
46
  }
43
- if (order?.delivered_in) { _estimatedTime = moment.utc(_delivery).add(order?.delivered_in, 'minutes')}
44
47
  _estimatedTime = outputFormat ? moment(_estimatedTime).local().format(outputFormat) : parseDate(_estimatedTime, { utc: false })
45
48
  setEstimatedDeliveryTime(_estimatedTime)
46
49
  }
@@ -129,7 +129,7 @@ export const OrderHistory = (props: any) => {
129
129
  <OText
130
130
  size={14}
131
131
  weight='bold'
132
- numberOfLines={message.change?.attribute === 'delivered_in' ? 2 : 1}
132
+ numberOfLines={message.change?.attribute.includes(['delivered_in', 'prepared_in']) ? 2 : 1}
133
133
  ellipsizeMode='tail'
134
134
  >
135
135
  {message.change?.attribute === 'logistic_status'
@@ -140,7 +140,12 @@ export const OrderHistory = (props: any) => {
140
140
  {formatSeconds(parseInt(message.change.new, 10))}
141
141
  </>
142
142
  )
143
- : t(ORDER_STATUS[parseInt(message.change.new, 10)])
143
+ : message.change?.attribute === 'prepared_in' ? (
144
+ <>
145
+ {t('TIME_ADDED_BY_BUSINESS', 'Time added by business')}{'\n'}
146
+ {formatSeconds(parseInt(message.change.new, 10))}
147
+ </>
148
+ ) : t(ORDER_STATUS[parseInt(message.change.new, 10)])
144
149
  }
145
150
  </OText>
146
151
  ) : (
@@ -20,12 +20,11 @@ import {
20
20
 
21
21
  import { ProductItemAccordion } from '../ProductItemAccordion';
22
22
  import { CouponControl } from '../CouponControl';
23
- import { OInput, OModal, OText } from '../shared';
23
+ import { OInput, OModal, OText, OAlert } from '../shared';
24
24
  import { verifyDecimals } from '../../utils';
25
25
  import AntIcon from 'react-native-vector-icons/AntDesign'
26
26
  import { TaxInformation } from '../TaxInformation';
27
27
  import { TouchableOpacity } from 'react-native';
28
- import { OAlert } from '../../../../../src/components/shared'
29
28
  import { MomentOption } from '../MomentOption';
30
29
 
31
30
  const OrderSummaryUI = (props: any) => {
@@ -58,7 +57,6 @@ const OrderSummaryUI = (props: any) => {
58
57
  const [{ parsePrice, parseNumber }] = useUtils();
59
58
  const [validationFields] = useValidationFields();
60
59
  const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null, type: '' })
61
- const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
62
60
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
63
61
  const hideCartComments = !validationFields?.fields?.checkout?.comments?.enabled
64
62
 
@@ -106,16 +104,16 @@ const OrderSummaryUI = (props: any) => {
106
104
  return cart?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
107
105
  }
108
106
 
109
- const onRemoveOffer = (id: number) => {
110
- setConfirm({
111
- open: true,
112
- content: [t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')],
113
- title: t('OFFER', 'Offer'),
114
- handleOnAccept: () => {
115
- setConfirm({ ...confirm, open: false })
116
- handleRemoveOfferClick(id)
117
- }
118
- })
107
+ const OfferAlert = ({ offerId }: any) => {
108
+ return (
109
+ <OAlert
110
+ title={t('OFFER', 'Offer')}
111
+ message={t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')}
112
+ onAccept={() => handleRemoveOfferClick(offerId)}
113
+ >
114
+ <AntIcon style={{ marginLeft: 3 }} name='closecircle' size={16} color={theme.colors.primary} />
115
+ </OAlert>
116
+ )
119
117
  }
120
118
 
121
119
  return (
@@ -171,9 +169,7 @@ const OrderSummaryUI = (props: any) => {
171
169
  <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
172
170
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
173
171
  </TouchableOpacity>
174
- <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
175
- <AntIcon name='closecircle' size={16} color={theme.colors.primary} />
176
- </TouchableOpacity>
172
+ <OfferAlert offerId={offer?.id} />
177
173
  </OSRow>
178
174
  <OText size={12}>
179
175
  - {parsePrice(offer?.summary?.discount)}
@@ -237,9 +233,7 @@ const OrderSummaryUI = (props: any) => {
237
233
  <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
238
234
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
239
235
  </TouchableOpacity>
240
- <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
241
- <AntIcon name='closecircle' size={16} color={theme.colors.primary} />
242
- </TouchableOpacity>
236
+ <OfferAlert offerId={offer?.id} />
243
237
  </OSRow>
244
238
  <OText size={12}>
245
239
  - {parsePrice(offer?.summary?.discount)}
@@ -264,9 +258,7 @@ const OrderSummaryUI = (props: any) => {
264
258
  <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
265
259
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
266
260
  </TouchableOpacity>
267
- <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
268
- <AntIcon name='closecircle' size={16} color={theme.colors.primary} />
269
- </TouchableOpacity>
261
+ <OfferAlert offerId={offer?.id} />
270
262
  </OSRow>
271
263
  <OText size={12}>
272
264
  - {parsePrice(offer?.summary?.discount)}
@@ -388,14 +380,6 @@ const OrderSummaryUI = (props: any) => {
388
380
  products={cart?.products}
389
381
  />
390
382
  </OModal>
391
- <OAlert
392
- open={confirm.open}
393
- title={confirm.title}
394
- content={confirm.content}
395
- onAccept={confirm.handleOnAccept}
396
- onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
397
- onClose={() => setConfirm({ ...confirm, open: false, title: null })}
398
- />
399
383
  </>
400
384
  )}
401
385
  </OSContainer>
@@ -52,7 +52,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
52
52
  const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
53
53
  const [isPressed, setIsPressed] = useState(false)
54
54
 
55
- const allowedOrderStatus = [1, 2, 5, 6, 10, 11, 12];
55
+ const allowedOrderStatus = [1, 2, 5, 6, 10, 11, 12, 15];
56
56
 
57
57
  const styles = StyleSheet.create({
58
58
  container: {
@@ -49,12 +49,12 @@ export const WalletTransactionItem = (props: any) => {
49
49
  .replace(':order_id', item?.event?.order_id ? item?.event?.order_id + ' ' : '')}
50
50
  </OText>
51
51
  </MessageBlock>
52
- {/* {!!item?.description && (
52
+ {!!item?.description && (
53
53
  <DescriptionBlock>
54
54
  <OText>{item?.description}</OText>
55
55
  </DescriptionBlock>
56
56
  )}
57
- {!!item?.code && (
57
+ {/* {!!item?.code && (
58
58
  <DescriptionBlock>
59
59
  <OText weight={'bold'}>
60
60
  {t('CODE', 'Code')}
@@ -104,7 +104,9 @@ const OInput = (props: Props): React.ReactElement => {
104
104
  props.forwardRef && (props.forwardRef.current = e)
105
105
  }}
106
106
  style={{
107
- color: theme?.general?.components?.inputs?.color,
107
+ ...(theme?.general?.components?.inputs?.color && {
108
+ color: theme?.general?.components?.inputs?.color
109
+ }),
108
110
  ...props?.inputStyle
109
111
  }}
110
112
  onFocus={() => setInputFocused(true)}
@@ -384,7 +384,7 @@ export const getOrderStatus = (s: string) => {
384
384
  key: 0,
385
385
  value: t('PENDING', 'Pending'),
386
386
  slug: 'PENDING',
387
- percentage: 0.25,
387
+ percentage: 0.1,
388
388
  image: theme.images.order.status0,
389
389
  },
390
390
  {
@@ -412,7 +412,7 @@ export const getOrderStatus = (s: string) => {
412
412
  key: 4,
413
413
  value: t('PREPARATION_COMPLETED', 'Preparation Completed'),
414
414
  slug: 'PREPARATION_COMPLETED',
415
- percentage: 0.7,
415
+ percentage: 0.2,
416
416
  image: theme.images.order.status4,
417
417
  },
418
418
  {
@@ -433,21 +433,21 @@ export const getOrderStatus = (s: string) => {
433
433
  key: 7,
434
434
  value: t('ACCEPTED_BY_BUSINESS', 'Accepted by business'),
435
435
  slug: 'ACCEPTED_BY_BUSINESS',
436
- percentage: 0.35,
436
+ percentage: 0.15,
437
437
  image: theme.images.order.status7,
438
438
  },
439
439
  {
440
440
  key: 8,
441
441
  value: t('ACCEPTED_BY_DRIVER', 'Accepted by driver'),
442
442
  slug: 'ACCEPTED_BY_DRIVER',
443
- percentage: 0.45,
443
+ percentage: 0.4,
444
444
  image: theme.images.order.status8,
445
445
  },
446
446
  {
447
447
  key: 9,
448
448
  value: t('PICK_UP_COMPLETED_BY_DRIVER', 'Pick up completed by driver'),
449
449
  slug: 'PICK_UP_COMPLETED_BY_DRIVER',
450
- percentage: 0.8,
450
+ percentage: 0.7,
451
451
  image: theme.images.order.status9,
452
452
  },
453
453
  {
@@ -485,7 +485,7 @@ export const getOrderStatus = (s: string) => {
485
485
  key: 14,
486
486
  value: t('ORDER_NOT_READY', 'Order not ready'),
487
487
  slug: 'ORDER_NOT_READY',
488
- percentage: 0,
488
+ percentage: 0.15,
489
489
  image: theme.images.order.status13,
490
490
  },
491
491
  {
@@ -522,7 +522,7 @@ export const getOrderStatus = (s: string) => {
522
522
  'Driver almost arrived to business',
523
523
  ),
524
524
  slug: 'DRIVER_ALMOST_ARRIVED_TO_BUSINESS',
525
- percentage: 0.15,
525
+ percentage: 0.5,
526
526
  image: theme.images.order.status3,
527
527
  },
528
528
  {
@@ -552,21 +552,21 @@ export const getOrderStatus = (s: string) => {
552
552
  'Customer arrived to business',
553
553
  ),
554
554
  slug: 'ORDER_CUSTOMER_ARRIVED_BUSINESS',
555
- percentage: 0.95,
555
+ percentage: 0.9,
556
556
  image: theme.images.order.status7,
557
557
  },
558
558
  {
559
559
  key: 22,
560
560
  value: t('ORDER_LOOKING_FOR_DRIVER', 'Looking for driver'),
561
561
  slug: 'ORDER_LOOKING_FOR_DRIVER',
562
- percentage: 0.35,
562
+ percentage: 0.3,
563
563
  image: theme.images.order.status8
564
564
  },
565
565
  {
566
566
  key: 23,
567
567
  value: t('ORDER_DRIVER_ON_WAY', 'Driver on way'),
568
568
  slug: 'ORDER_DRIVER_ON_WAY',
569
- percentage: 0.45,
569
+ percentage: 0.8,
570
570
  image: theme.images.order.status8
571
571
  }
572
572
  ];
@@ -614,7 +614,7 @@ export const lightenDarkenColor = (color: any) => {
614
614
  }
615
615
  }
616
616
 
617
- export const vibrateApp = (impact ?: string) => {
617
+ export const vibrateApp = (impact?: string) => {
618
618
  const options = {
619
619
  enableVibrateFallback: true,
620
620
  ignoreAndroidSystemSettings: false