ordering-ui-react-native 0.23.88 → 0.23.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.23.88",
3
+ "version": "0.23.90",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -242,116 +242,151 @@ export const OrderSummary = ({ order, navigation, orderStatus, askBluetoothPermi
242
242
  </div>`
243
243
  )
244
244
  }
245
- <div style="display: flex;">
246
-
247
- <div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">
248
- ${t('SUBTOTAL', 'Subtotal')}
249
- </div>
250
-
251
- <div style="display:flex; justify-content: flex-end; font-size: 26px; width: 30%">
252
- ${parsePrice(
253
- order.tax_type === 1
254
- ? order?.summary?.subtotal + order?.summary?.tax ?? 0
255
- : order?.summary?.subtotal ?? 0,
256
- )}
257
- </div>
245
+ <div style="display: flex;">
246
+ <div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">
247
+ ${t('SUBTOTAL', 'Subtotal')}
248
+ </div>
258
249
 
250
+ <div style="display:flex; justify-content: flex-end; font-size: 26px; width: 30%">
251
+ ${parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()), { currency: getCurrenySymbol(order?.currency) })}
259
252
  </div>
253
+ </div>
260
254
 
261
- <div style="display: flex">
255
+ <div style="display: flex">
262
256
  ${order?.summary?.discount > 0
263
257
  ? order?.offer_type === 1
264
258
  ? `<div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">
265
- ${t('DISCOUNT', 'Discount')} (${verifyDecimals(
266
- order?.offer_rate,
267
- parsePrice,
268
- )}%)
269
- </div>`
270
- : `<div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%"> ${t(
271
- 'DISCOUNT',
272
- 'Discount',
273
- )}
274
- </div>`
275
- : ''
276
- }
277
- ${order?.summary?.discount > 0
278
- ? `<div style="display:flex; justify-content: flex-end; font-size: 26px; width: 30%">- ${parsePrice(
279
- order?.summary?.discount,
280
- )}
259
+ ${t('DISCOUNT', 'Discount')} (${verifyDecimals(order?.offer_rate, parsePrice)}%)
281
260
  </div>`
261
+ : `<div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%"> ${t('DISCOUNT', 'Discount')}</div>`
282
262
  : ''
283
263
  }
284
- </div>
285
-
286
- ${order?.tax_type !== 1
287
- ? `<div style="font-size: 25px">
288
- ${t('TAX', 'Tax')}
289
- ${verifyDecimals(order?.summary?.tax_rate, parseNumber)}%
290
- ${parsePrice(order?.summary?.tax ?? 0)}
291
- ${t('TAX', 'Tax')}
292
- ${verifyDecimals(order?.summary?.tax_rate, parseNumber)}%
293
- </div>`
264
+ ${order?.summary?.discount > 0
265
+ ? `<div style="display:flex; justify-content: flex-end; font-size: 26px; width: 30%">
266
+ - ${parsePrice(order?.summary?.discount ?? order?.discount, { currency: getCurrenySymbol(order?.currency) })}
267
+ </div>`
294
268
  : ''
295
269
  }
270
+ </div>
296
271
 
297
- ${order?.summary?.delivery_price > 0 && order.delivery_type !== 2 ?
298
- ` <div style="display: flex">
299
- <div style="font-size: 26px; width: 70%; display: flex; justify-content: flex-start">
300
- ${t('DELIVERY_FEE', 'Delivery Fee')}
301
- </div>
302
-
303
- <div style="font-size: 26px; width: 30%; display: flex; justify-content: flex-end">
304
- ${parsePrice(order?.summary?.delivery_price + getIncludedTaxes(true), { currency: getCurrenySymbol(order?.currency) })}
305
- </div>` :
306
- ''}
307
-
308
- </div>
309
- <div style="display: flex">
310
-
311
- <div style="font-size: 26px; width: 70%; display: flex; justify-content: flex-start">
312
- ${t('DRIVER_TIP', 'Driver tip')}
313
- ${percentTip ? `(${percentTip}%)` : ''}
314
- </div>
315
-
316
- <div style="font-size: 26px; width: 30%; display: flex; justify-content: flex-end">
317
- ${parsePrice(order?.summary?.driver_tip ?? 0)}
272
+ ${order?.offers?.length > 0 ? order?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
273
+ `<div style="display: flex">
274
+ ${order?.rate_type === 1
275
+ ? `<div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">
276
+ ${t(offer.name?.toUpperCase?.()?.replace(/ /g, '_'), offer.name)} (${verifyDecimals(offer?.rate, parsePrice)}%)
277
+ </div>`
278
+ : `<div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">${t(offer.name?.toUpperCase?.()?.replace(/ /g, '_'), offer.name)}</div>`}
279
+ <div style="display:flex; justify-content: flex-end; font-size: 26px; width: 30%">
280
+ - ${parsePrice(offer?.summary?.discount, { currency: getCurrenySymbol(order?.currency) })}
318
281
  </div>
282
+ </div>`
283
+ )) : ''}
319
284
 
320
- </div>
321
-
322
- ${order?.summary?.service_fee > 0 && `
323
- <div style="display: flex">
324
- <div style="font-size: 26px; width: 70%; display: flex; justify-content: flex-start">
325
- ${t('SERVICE_FEE', 'Service Fee')}
326
- (${verifyDecimals(order?.summary?.service_fee, parseNumber)}%)
285
+ ${order?.taxes?.length === 0 && order?.tax_type === 2
286
+ ? `<div style="display: flex;">
287
+ <div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">
288
+ ${t('TAX', 'Tax')} (${verifyDecimals(order?.tax, parseNumber)}%)}
289
+ </div>
290
+ <div style="display:flex; justify-content: flex-end; font-size: 26px; width: 30%">
291
+ ${parsePrice(order?.summary?.tax ?? 0, { currency: getCurrenySymbol(order?.currency) })}
327
292
  </div>
293
+ </div>`
294
+ : ''}
328
295
 
329
- <div style="font-size: 26px; width: 30%; display: flex; justify-content: flex-end">
330
- ${parsePrice(order?.summary?.service_fee ?? 0)}
296
+ ${order?.fees?.length === 0 && order?.summary?.service_fee > 0 ? (
297
+ `<div style="display: flex;">
298
+ <div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">
299
+ ${t('SERVICE_FEE', 'Service fee')} (${verifyDecimals(order?.service_fee, parseNumber)}%)}
331
300
  </div>
301
+ <div style="display:flex; justify-content: flex-end; font-size: 26px; width: 30%">
302
+ ${parsePrice(order?.summary?.service_fee ?? 0, { currency: getCurrenySymbol(order?.currency) })}
303
+ </div>
304
+ </div>`
305
+ ) : ''}
332
306
 
333
- </div>
334
- `}
307
+ ${order?.taxes?.length > 0 ? order?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0 && tax?.target === 'product').map((tax: any) => (
308
+ `<div style="display: flex;">
309
+ <div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">
310
+ ${t(tax?.name?.toUpperCase?.()?.replace(/ /g, '_'), tax?.name) || t('INHERIT_FROM_BUSINESS', 'Inherit from business')} (${verifyDecimals(tax?.rate, parseNumber)}%)
311
+ </div>
312
+ <div style="display:flex; justify-content: flex-end; font-size: 26px; width: 30%">
313
+ ${parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0, { currency: getCurrenySymbol(order?.currency) })}
314
+ </div>
315
+ </div>`
316
+ )) : ''}
335
317
 
336
- <div style="display: flex">
318
+ ${order?.offers?.length > 0 ? order?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
319
+ `<div style="display: flex;">
320
+ <div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">
321
+ ${t(offer.name?.toUpperCase?.()?.replace(/ /g, '_'), offer.name)} ${offer.rate_type === 1 ? `(${verifyDecimals(offer?.rate, parsePrice)}%)` : ''}
322
+ </div>
323
+ <div style="display:flex; justify-content: flex-end; font-size: 26px; width: 30%">
324
+ - ${parsePrice(offer?.summary?.discount, { currency: getCurrenySymbol(order?.currency) })}
325
+ </div>
326
+ </div>`
327
+ )) : ''}
337
328
 
338
- <div style="font-size: 26px; width: 70%; display: flex; justify-content: flex-start; font-weight: bold">
339
- ${t('TOTAL', 'Total')}
329
+ ${order?.summary?.delivery_price > 0 && order.delivery_type !== 2 ?
330
+ ` <div style="display: flex">
331
+ <div style="font-size: 26px; width: 70%; display: flex; justify-content: flex-start">
332
+ ${t('DELIVERY_FEE', 'Delivery Fee')}
340
333
  </div>
341
334
 
342
335
  <div style="font-size: 26px; width: 30%; display: flex; justify-content: flex-end">
343
- ${parsePrice(order?.summary?.total ?? 0)}
344
- </div>
345
-
336
+ ${parsePrice(order?.summary?.delivery_price + getIncludedTaxes(true), { currency: getCurrenySymbol(order?.currency) })}
337
+ </div>` :
338
+ ''
339
+ }
340
+ </div>
341
+
342
+ <div style="display: flex">
343
+ <div style="font-size: 26px; width: 70%; display: flex; justify-content: flex-start">
344
+ ${t('DRIVER_TIP', 'Driver tip')}
345
+ ${percentTip ? `(${percentTip}%)` : ''}
346
+ </div>
347
+ <div style="font-size: 26px; width: 30%; display: flex; justify-content: flex-end">
348
+ ${parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip, { currency: getCurrenySymbol(order?.currency) })}
349
+ </div>
350
+ </div>
351
+
352
+ ${order?.taxes?.length > 0 ? order?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0 && tax?.target === 'delivery_fee').map((tax: any, i: number) => (
353
+ `<div style="display: flex;">
354
+ <div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">
355
+ ${tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')} (${verifyDecimals(tax?.rate, parsePrice)}%)
346
356
  </div>
357
+ <div style="display:flex; justify-content: flex-end; font-size: 26px; width: 30%">
358
+ ${parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0, { currency: getCurrenySymbol(order?.currency) })}
359
+ </div>
360
+ </div>`
361
+ )) : ''}
347
362
 
348
- ${order?.payment_events.length && `
349
- <div style="font-size: 26px; width: 70%; display: flex; justify-content: flex-start; font-weight: bold">
350
- ${t('PAYMENTS', 'Payments')}
351
- </div>
352
- `}
353
-
354
- ${order?.payment_events.length &&
363
+ ${order?.offers?.length > 0 ? order?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
364
+ `<div style="display: flex;">
365
+ <div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">
366
+ ${t(offer.name?.toUpperCase?.()?.replace(/ /g, '_'), offer.name)} ${offer.rate_type === 1 ? `(${verifyDecimals(offer?.rate, parsePrice, { currency: getCurrenySymbol(order?.currency) })}%)` : ''}
367
+ </div>
368
+ <div style="display:flex; justify-content: flex-end; font-size: 26px; width: 30%">
369
+ - ${parsePrice(offer?.summary?.discount, { currency: getCurrenySymbol(order?.currency) })}
370
+ </div>
371
+ </div>`
372
+ )) : ''}
373
+
374
+ <div style="display: flex">
375
+ <div style="font-size: 26px; width: 70%; display: flex; justify-content: flex-start; font-weight: bold">
376
+ ${t('TOTAL', 'Total')}
377
+ </div>
378
+ <div style="font-size: 26px; width: 30%; display: flex; justify-content: flex-end">
379
+ ${parsePrice(order?.summary?.total ?? 0)}
380
+ </div>
381
+ </div>
382
+
383
+ ${order?.payment_events.length && `
384
+ <div style="font-size: 26px; width: 70%; display: flex; justify-content: flex-start; font-weight: bold">
385
+ ${t('PAYMENTS', 'Payments')}
386
+ </div>
387
+ `}
388
+
389
+ ${order?.payment_events.length &&
355
390
  order?.payment_events.map(
356
391
  (event: any, i: number) =>
357
392
  `<div style="display: flex;flexDirection:row;flex-wrap:wrap">
@@ -374,7 +409,7 @@ export const OrderSummary = ({ order, navigation, orderStatus, askBluetoothPermi
374
409
  </div>
375
410
  </div>`
376
411
  )}
377
- </div>`;
412
+ </div> `;
378
413
  };
379
414
 
380
415
  const deliveryStatus: any = {
@@ -709,38 +744,17 @@ export const OrderSummary = ({ order, navigation, orderStatus, askBluetoothPermi
709
744
  </OText>
710
745
 
711
746
  <OText style={{ marginBottom: 5 }}>
712
- {parsePrice(
713
- order.tax_type === 1
714
- ? order?.summary?.subtotal + order?.summary?.tax ?? 0
715
- : order?.summary?.subtotal ?? 0,
716
- )}
747
+ {parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()), { currency: getCurrenySymbol(order?.currency) })}
717
748
  </OText>
718
749
  </Table>
719
750
 
720
- {order?.tax_type !== 1 && (
721
- <Table>
722
- <OText style={{ marginBottom: 5 }}>
723
- {t('TAX', 'Tax')}
724
- {`(${verifyDecimals(
725
- order?.summary?.tax_rate,
726
- parseNumber,
727
- )}%)`}
728
- </OText>
729
-
730
- <OText style={{ marginBottom: 5 }}>
731
- {parsePrice(order?.summary?.tax ?? 0)}
732
- </OText>
733
- </Table>
734
- )}
735
-
736
- {order?.summary?.discount > 0 && (
751
+ {(order?.summary?.discount > 0 ?? order?.discount > 0) && order?.offers?.length === 0 && (
737
752
  <Table>
738
753
  {order?.offer_type === 1 ? (
739
754
  <OText style={{ marginBottom: 5 }}>
740
755
  <OText>{t('DISCOUNT', 'Discount')}</OText>
741
-
742
756
  <OText>
743
- {`(${verifyDecimals(order?.offer_rate, parsePrice)}%)`}
757
+ {`(${verifyDecimals(order?.offer_rate, parsePrice)} %)`}
744
758
  </OText>
745
759
  </OText>
746
760
  ) : (
@@ -750,18 +764,75 @@ export const OrderSummary = ({ order, navigation, orderStatus, askBluetoothPermi
750
764
  )}
751
765
 
752
766
  <OText style={{ marginBottom: 5 }}>
753
- - {parsePrice(order?.summary?.discount)}
767
+ - {parsePrice(order?.summary?.discount ?? order?.discount, { currency: getCurrenySymbol(order?.currency) })}
754
768
  </OText>
755
769
  </Table>
756
770
  )}
757
771
 
758
- {order?.summary?.delivery_price > 0 && order.delivery_type !== 2 && (
772
+ {order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
773
+ <Table key={offer.id}>
774
+ <OText mBottom={4}>
775
+ {t(offer.name?.toUpperCase?.()?.replace(/ /g, '_'), offer.name)}
776
+ {offer.rate_type === 1 && (
777
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)} %)`}</OText>
778
+ )}
779
+ </OText>
780
+ <OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: getCurrenySymbol(order?.currency) })}</OText>
781
+ </Table>
782
+ ))}
783
+
784
+ {order?.taxes?.length === 0 && order?.tax_type === 2 && order?.summary?.tax > 0 && (
759
785
  <Table>
760
- <OText style={{ marginBottom: 5 }}>
786
+ <OText mBottom={4}>
787
+ {t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)} %)`}
788
+ </OText>
789
+ <OText mBottom={4}>
790
+ {parsePrice(order?.summary?.tax ?? 0, { currency: getCurrenySymbol(order?.currency) })}
791
+ </OText>
792
+ </Table>
793
+ )}
794
+
795
+ {order?.fees?.length === 0 && order?.summary?.service_fee > 0 && (
796
+ <Table>
797
+ <OText mBottom={4}>
798
+ {t('SERVICE_FEE', 'Service fee')}
799
+ {`(${verifyDecimals(order?.service_fee, parseNumber)} %)`}
800
+ </OText>
801
+ <OText mBottom={4}>{parsePrice(order?.summary?.service_fee ?? 0, { currency: getCurrenySymbol(order?.currency) })}</OText>
802
+ </Table>
803
+ )}
804
+
805
+ {order?.taxes?.length > 0 && order?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0 && tax?.target === 'product').map((tax: any) => (
806
+ <Table key={tax.id}>
807
+ <OText mBottom={4}>
808
+ {t(tax?.name?.toUpperCase?.()?.replace(/ /g, '_'), tax?.name) || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
809
+ {`(${verifyDecimals(tax?.rate, parseNumber)} %)`}{' '}
810
+ </OText>
811
+ <OText mBottom={4}>
812
+ {parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0, { currency: getCurrenySymbol(order?.currency) })}
813
+ </OText>
814
+ </Table>
815
+ ))}
816
+
817
+ {order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
818
+ <Table key={offer.id}>
819
+ <OText mBottom={4}>
820
+ {t(offer.name?.toUpperCase?.()?.replace(/ /g, '_'), offer.name)}
821
+ {offer.rate_type === 1 && (
822
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)} %)`}</OText>
823
+ )}
824
+ </OText>
825
+ <OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: getCurrenySymbol(order?.currency) })}</OText>
826
+ </Table>
827
+ ))}
828
+
829
+ {typeof order?.summary?.delivery_price === 'number' && order.delivery_type !== 2 && (
830
+ <Table>
831
+ <OText mBottom={4}>
761
832
  {t('DELIVERY_FEE', 'Delivery Fee')}
762
833
  </OText>
763
834
 
764
- <OText>
835
+ <OText mBottom={4}>
765
836
  {parsePrice(order?.summary?.delivery_price + getIncludedTaxes(true), { currency: getCurrenySymbol(order?.currency) })}
766
837
  </OText>
767
838
  </Table>
@@ -769,38 +840,41 @@ export const OrderSummary = ({ order, navigation, orderStatus, askBluetoothPermi
769
840
 
770
841
  {(order?.summary?.driver_tip > 0 || order?.driver_tip > 0) && order.delivery_type !== 2 && (
771
842
  <Table>
772
- <OText style={{ marginBottom: 5 }}>
843
+ <OText mBottom={4}>
773
844
  {t('DRIVER_TIP', 'Driver tip')}
774
- {order?.summary?.driver_tip > 0 &&
775
- parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
845
+ {order?.driver_tip > 0 && parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
776
846
  !parseInt(configs?.driver_tip_use_custom?.value, 10) &&
777
- `(${verifyDecimals(
778
- order?.summary?.driver_tip,
779
- parseNumber,
780
- )}%)`}
847
+ (
848
+ `(${verifyDecimals(order?.driver_tip, parseNumber)} %)`
849
+ )}
781
850
  </OText>
782
-
783
- <OText style={{ marginBottom: 5 }}>
784
- {parsePrice(order?.summary?.driver_tip ?? 0)}
851
+ <OText mBottom={4}>
852
+ {parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip, { currency: getCurrenySymbol(order?.currency) })}
785
853
  </OText>
786
854
  </Table>
787
855
  )}
788
856
 
789
- {order?.summary?.service_fee > 0 && (
790
- <Table>
791
- <OText style={{ marginBottom: 5 }}>
792
- {t('SERVICE_FEE', 'Service Fee')}
793
- {`(${verifyDecimals(
794
- order?.summary?.service_fee,
795
- parseNumber,
796
- )}%)`}
857
+ {order?.taxes?.length > 0 && order?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0 && tax?.target === 'delivery_fee').map((tax: any, i: number) => (
858
+ <Table key={`${tax.description}_${i} `}>
859
+ <OText mBottom={4}>
860
+ {tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
861
+ {`(${verifyDecimals(tax?.rate, parseNumber)} %)`}
797
862
  </OText>
798
-
799
- <OText style={{ marginBottom: 5 }}>
800
- {parsePrice(order?.summary?.service_fee)}
863
+ <OText mBottom={4}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0, { currency: getCurrenySymbol(order?.currency) })}</OText>
864
+ </Table>
865
+ ))}
866
+
867
+ {order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
868
+ <Table key={offer.id}>
869
+ <OText mBottom={4}>
870
+ {t(offer.name?.toUpperCase?.()?.replace(/ /g, '_'), offer.name)}
871
+ {offer.rate_type === 1 && (
872
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice, { currency: getCurrenySymbol(order?.currency) })}%)`}</OText>
873
+ )}
801
874
  </OText>
875
+ <OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: getCurrenySymbol(order?.currency) })}</OText>
802
876
  </Table>
803
- )}
877
+ ))}
804
878
 
805
879
  <Total>
806
880
  <Table>
@@ -59,7 +59,7 @@ const OrderSummaryUI = (props: any) => {
59
59
  const [{ parsePrice, parseNumber }] = useUtils();
60
60
  const commentRef = useRef()
61
61
  const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null, type: '' })
62
- const [comment] = useState<any>(orderState?.carts?.[`businessId:${props.cart.business_id}`].comment ?? '')
62
+ const [comment] = useState<any>(orderState?.carts?.[`businessId:${props.cart.business_id}`]?.comment ?? '')
63
63
  const hideCartDiscount = hideCouponByValidationCheckout
64
64
  const hideCartComments = hideCommentsByValidationCheckout
65
65