ordering-ui-react-native 0.17.21-release → 0.17.22-release

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.21-release",
3
+ "version": "0.17.22-release",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -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
 
@@ -66,7 +66,6 @@ const CartUI = (props: any) => {
66
66
  const [openChangeStore, setOpenChangeStore] = useState(false)
67
67
  const [canOpenUpselling, setCanOpenUpselling] = useState(false)
68
68
  const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null, type: '' })
69
- const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
70
69
  const [openPlaceModal, setOpenPlaceModal] = useState(false)
71
70
 
72
71
  const isCartPending = cart?.status === 2
@@ -74,7 +73,6 @@ const CartUI = (props: any) => {
74
73
  const business: any = (orderState?.carts && Object.values(orderState.carts).find((_cart: any) => _cart?.uuid === props.cartuuid)) ?? {}
75
74
  const businessId = business?.business_id ?? null
76
75
  const placeSpotTypes = [4]
77
- const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
78
76
  const hideCartComments = theme?.business_view?.components?.cart?.components?.comments?.hidden
79
77
  const hideCartDiscount = theme?.business_view?.components?.cart?.components?.discount?.hidden
80
78
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
@@ -166,16 +164,16 @@ const CartUI = (props: any) => {
166
164
  return cart?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
167
165
  }
168
166
 
169
- const onRemoveOffer = (id: number) => {
170
- setConfirm({
171
- open: true,
172
- content: [t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')],
173
- title: t('OFFER', 'Offer'),
174
- handleOnAccept: () => {
175
- setConfirm({ ...confirm, open: false })
176
- handleRemoveOfferClick(id)
177
- }
178
- })
167
+ const OfferAlert = ({ offerId }: any) => {
168
+ return (
169
+ <OAlert
170
+ title={t('OFFER', 'Offer')}
171
+ message={t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')}
172
+ onAccept={() => handleRemoveOfferClick(offerId)}
173
+ >
174
+ <AntIcon style={{ marginLeft: 3 }} name='closecircle' size={16} color={theme.colors.primary} />
175
+ </OAlert>
176
+ )
179
177
  }
180
178
 
181
179
  const walletName: any = {
@@ -268,9 +266,9 @@ const CartUI = (props: any) => {
268
266
  <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
269
267
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
270
268
  </TouchableOpacity>
271
- <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
272
- <AntIcon name='closecircle' size={16} color={theme.colors.primary} />
273
- </TouchableOpacity>
269
+ {!!offer?.id && (
270
+ <OfferAlert offerId={offer?.id} />
271
+ )}
274
272
  </OSRow>
275
273
  <OText size={12} lineHeight={18}>
276
274
  - {parsePrice(offer?.summary?.discount)}
@@ -332,10 +330,8 @@ const CartUI = (props: any) => {
332
330
  <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
333
331
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
334
332
  </TouchableOpacity>
335
- {!offer?.type && (
336
- <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
337
- <AntIcon name='closecircle' size={16} color={theme.colors.primary} />
338
- </TouchableOpacity>
333
+ {!!offer?.id && (
334
+ <OfferAlert offerId={offer?.id} />
339
335
  )}
340
336
  </OSRow>
341
337
  <OText size={12} lineHeight={18}>
@@ -361,9 +357,9 @@ const CartUI = (props: any) => {
361
357
  <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
362
358
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
363
359
  </TouchableOpacity>
364
- <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
365
- <AntIcon name='closecircle' size={16} color={theme.colors.primary} />
366
- </TouchableOpacity>
360
+ {!!offer?.id && (
361
+ <OfferAlert offerId={offer?.id} />
362
+ )}
367
363
  </OSRow>
368
364
  <OText size={12} lineHeight={18}>
369
365
  - {parsePrice(offer?.summary?.discount)}
@@ -561,14 +557,6 @@ const CartUI = (props: any) => {
561
557
  setOpenPlaceModal={setOpenPlaceModal}
562
558
  />
563
559
  </OModal>
564
- <OAlert
565
- open={confirm.open}
566
- title={confirm.title}
567
- content={confirm.content}
568
- onAccept={confirm.handleOnAccept}
569
- onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
570
- onClose={() => setConfirm({ ...confirm, open: false, title: null })}
571
- />
572
560
  </CContainer>
573
561
  )
574
562
  }
@@ -23,6 +23,7 @@ const DriverTipsUI = (props: any) => {
23
23
  driverTip,
24
24
  driverTipsOptions,
25
25
  isMulti,
26
+ isLoading,
26
27
  cart,
27
28
  carts,
28
29
  isDriverTipUseCustom,
@@ -79,8 +80,10 @@ const DriverTipsUI = (props: any) => {
79
80
  <TouchableOpacity
80
81
  key={i}
81
82
  onPress={() => {
82
- handlerChangeOption(option)
83
- setCustomTip(false)
83
+ if (!isLoading) {
84
+ handlerChangeOption(option)
85
+ setCustomTip(false)
86
+ }
84
87
  }}
85
88
  >
86
89
  <DTCard
@@ -95,7 +98,7 @@ const DriverTipsUI = (props: any) => {
95
98
  ))}
96
99
  {isDriverTipUseCustom && (
97
100
  <TouchableOpacity
98
- onPress={() => setCustomTip(true)}
101
+ onPress={() => { !isLoading && setCustomTip(true) }}
99
102
  >
100
103
  <DTCard
101
104
  style={style.semicircle}
@@ -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);
@@ -314,13 +316,14 @@ const MultiCheckoutUI = (props: any) => {
314
316
  </OText>
315
317
  <DriverTips
316
318
  isMulti
319
+ isLoading={loading}
317
320
  carts={openCarts}
318
321
  businessIds={openCarts.map((cart: any) => cart.business_id)}
319
322
  driverTipsOptions={driverTipsOptions}
320
323
  isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1}
321
324
  isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
322
325
  driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1
323
- ? openCarts[0]?.driver_tip
326
+ ? openCarts?.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0)
324
327
  : openCarts[0]?.driver_tip_rate}
325
328
  useOrderContext
326
329
  />
@@ -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
 
64
62
  const cart = orderState?.carts?.[`businessId:${props.cart.business_id}`]
@@ -105,16 +103,16 @@ const OrderSummaryUI = (props: any) => {
105
103
  return cart?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
106
104
  }
107
105
 
108
- const onRemoveOffer = (id: number) => {
109
- setConfirm({
110
- open: true,
111
- content: [t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')],
112
- title: t('OFFER', 'Offer'),
113
- handleOnAccept: () => {
114
- setConfirm({ ...confirm, open: false })
115
- handleRemoveOfferClick(id)
116
- }
117
- })
106
+ const OfferAlert = ({ offerId }: any) => {
107
+ return (
108
+ <OAlert
109
+ title={t('OFFER', 'Offer')}
110
+ message={t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')}
111
+ onAccept={() => handleRemoveOfferClick(offerId)}
112
+ >
113
+ <AntIcon style={{ marginLeft: 3 }} name='closecircle' size={16} color={theme.colors.primary} />
114
+ </OAlert>
115
+ )
118
116
  }
119
117
 
120
118
  return (
@@ -170,9 +168,9 @@ const OrderSummaryUI = (props: any) => {
170
168
  <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
171
169
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
172
170
  </TouchableOpacity>
173
- <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
174
- <AntIcon name='closecircle' size={16} color={theme.colors.primary} />
175
- </TouchableOpacity>
171
+ {!!offer?.id && (
172
+ <OfferAlert offerId={offer?.id} />
173
+ )}
176
174
  </OSRow>
177
175
  <OText size={12}>
178
176
  - {parsePrice(offer?.summary?.discount)}
@@ -236,9 +234,9 @@ const OrderSummaryUI = (props: any) => {
236
234
  <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
237
235
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
238
236
  </TouchableOpacity>
239
- <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
240
- <AntIcon name='closecircle' size={16} color={theme.colors.primary} />
241
- </TouchableOpacity>
237
+ {!!offer?.id && (
238
+ <OfferAlert offerId={offer?.id} />
239
+ )}
242
240
  </OSRow>
243
241
  <OText size={12}>
244
242
  - {parsePrice(offer?.summary?.discount)}
@@ -263,9 +261,9 @@ const OrderSummaryUI = (props: any) => {
263
261
  <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
264
262
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
265
263
  </TouchableOpacity>
266
- <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
267
- <AntIcon name='closecircle' size={16} color={theme.colors.primary} />
268
- </TouchableOpacity>
264
+ {!!offer?.id && (
265
+ <OfferAlert offerId={offer?.id} />
266
+ )}
269
267
  </OSRow>
270
268
  <OText size={12}>
271
269
  - {parsePrice(offer?.summary?.discount)}
@@ -387,14 +385,6 @@ const OrderSummaryUI = (props: any) => {
387
385
  products={cart?.products}
388
386
  />
389
387
  </OModal>
390
- <OAlert
391
- open={confirm.open}
392
- title={confirm.title}
393
- content={confirm.content}
394
- onAccept={confirm.handleOnAccept}
395
- onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
396
- onClose={() => setConfirm({ ...confirm, open: false, title: null })}
397
- />
398
388
  </>
399
389
  )}
400
390
  </OSContainer>
@@ -74,13 +74,22 @@ const ReviewProductsUI = (props: ReviewProductParams) => {
74
74
  titleWrapStyle={{ paddingHorizontal: 0 }}
75
75
  titleStyle={{ marginRight: 0, marginLeft: 0 }}
76
76
  />
77
- {order?.products?.map((product: any) => !product?.deleted && (
78
- <SingleProductReview
79
- key={product.id}
80
- product={product}
81
- formState={formState}
82
- handleChangeFormState={handleChangeFormState}
83
- />
77
+ {order?.products && order.products.length > 0 && order?.products.map(productsOrder => (
78
+ productsOrder?.length ? productsOrder?.map((product: any, i: any) => !product?.deleted ?
79
+ <SingleProductReview
80
+ key={i}
81
+ product={product}
82
+ formState={formState}
83
+ handleChangeFormState={handleChangeFormState}
84
+ /> : null
85
+ ) : (!productsOrder?.deleted ? (
86
+ <SingleProductReview
87
+ product={productsOrder}
88
+ formState={formState}
89
+ handleChangeFormState={handleChangeFormState}
90
+ />
91
+ ) : null
92
+ )
84
93
  ))}
85
94
  </ReviewProductsContainer>
86
95
 
@@ -50,7 +50,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
50
50
  const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
51
51
  const [isPressed, setIsPressed] = useState(false)
52
52
 
53
- const allowedOrderStatus = [1, 2, 5, 6, 10, 11, 12];
53
+ const allowedOrderStatus = [1, 2, 5, 6, 10, 11, 12, 15];
54
54
 
55
55
  const styles = StyleSheet.create({
56
56
  container: {
@@ -54,7 +54,7 @@ export const WalletTransactionItem = (props: any) => {
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')}
@@ -100,7 +100,12 @@ const OInput = (props: Props): React.ReactElement => {
100
100
  ref={(e: any) => {
101
101
  props.forwardRef && (props.forwardRef.current = e)
102
102
  }}
103
- style={props?.inputStyle}
103
+ style={{
104
+ ...(theme?.general?.components?.inputs?.color && {
105
+ color: theme?.general?.components?.inputs?.color
106
+ }),
107
+ ...props?.inputStyle
108
+ }}
104
109
  onFocus={() => setInputFocused(true)}
105
110
  onBlur={() => setInputFocused(false)}
106
111
  />