ordering-ui-react-native 0.12.44 → 0.12.45

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.
Files changed (51) hide show
  1. package/package.json +1 -1
  2. package/src/components/Cart/index.tsx +56 -23
  3. package/src/components/OrderDetails/index.tsx +90 -35
  4. package/src/components/OrderSummary/index.tsx +59 -27
  5. package/src/components/OrderSummary/styles.tsx +6 -0
  6. package/src/components/SingleProductCard/index.tsx +1 -1
  7. package/src/components/TaxInformation/index.tsx +51 -0
  8. package/src/components/TaxInformation/styles.tsx +9 -0
  9. package/src/types/index.tsx +1 -1
  10. package/themes/doordash/src/components/Cart/index.tsx +55 -22
  11. package/themes/doordash/src/components/OrderDetails/index.tsx +444 -386
  12. package/themes/doordash/src/components/OrderSummary/index.tsx +252 -221
  13. package/themes/doordash/src/components/OrderSummary/styles.tsx +6 -0
  14. package/themes/doordash/src/components/SingleProductCard/index.tsx +1 -1
  15. package/themes/doordash/src/components/TaxInformation/index.tsx +51 -0
  16. package/themes/doordash/src/components/TaxInformation/styles.tsx +9 -0
  17. package/themes/franchises/src/components/Cart/index.tsx +55 -23
  18. package/themes/franchises/src/components/OrderDetails/index.tsx +77 -23
  19. package/themes/franchises/src/components/OrderSummary/index.tsx +58 -24
  20. package/themes/franchises/src/components/OrderSummary/styles.tsx +6 -0
  21. package/themes/franchises/src/components/SingleProductCard/index.tsx +1 -1
  22. package/themes/franchises/src/components/TaxInformation/index.tsx +51 -0
  23. package/themes/franchises/src/components/TaxInformation/styles.tsx +9 -0
  24. package/themes/instacart/src/components/Cart/index.tsx +57 -17
  25. package/themes/instacart/src/components/OrderDetails/index.tsx +490 -433
  26. package/themes/instacart/src/components/OrderSummary/index.tsx +236 -194
  27. package/themes/instacart/src/components/OrderSummary/styles.tsx +6 -0
  28. package/themes/instacart/src/components/SingleProductCard/index.tsx +2 -2
  29. package/themes/instacart/src/components/TaxInformation/index.tsx +51 -0
  30. package/themes/instacart/src/components/TaxInformation/styles.tsx +9 -0
  31. package/themes/original/src/components/Cart/index.tsx +55 -13
  32. package/themes/original/src/components/OrderDetails/index.tsx +76 -23
  33. package/themes/original/src/components/OrderSummary/index.tsx +208 -173
  34. package/themes/original/src/components/OrderSummary/styles.tsx +6 -0
  35. package/themes/original/src/components/SingleProductCard/index.tsx +1 -1
  36. package/themes/original/src/components/TaxInformation/index.tsx +51 -0
  37. package/themes/original/src/components/TaxInformation/styles.tsx +9 -0
  38. package/themes/single-business/src/components/Cart/index.tsx +57 -24
  39. package/themes/single-business/src/components/OrderDetails/index.tsx +77 -23
  40. package/themes/single-business/src/components/OrderSummary/index.tsx +58 -24
  41. package/themes/single-business/src/components/OrderSummary/styles.tsx +6 -0
  42. package/themes/single-business/src/components/SingleProductCard/index.tsx +1 -1
  43. package/themes/single-business/src/components/TaxInformation/index.tsx +51 -0
  44. package/themes/single-business/src/components/TaxInformation/styles.tsx +9 -0
  45. package/themes/uber-eats/src/components/Cart/index.tsx +56 -14
  46. package/themes/uber-eats/src/components/OrderDetails/index.tsx +81 -22
  47. package/themes/uber-eats/src/components/OrderSummary/index.tsx +56 -23
  48. package/themes/uber-eats/src/components/OrderSummary/styles.tsx +6 -0
  49. package/themes/uber-eats/src/components/SingleProductCard/index.tsx +1 -1
  50. package/themes/uber-eats/src/components/TaxInformation/index.tsx +51 -0
  51. package/themes/uber-eats/src/components/TaxInformation/styles.tsx +9 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.12.44",
3
+ "version": "0.12.45",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -8,9 +8,9 @@ import {
8
8
  useValidationFields,
9
9
  } from 'ordering-components/native';
10
10
 
11
- import { CContainer, CheckoutAction } from './styles';
11
+ import { CContainer, CheckoutAction, } from './styles';
12
12
 
13
- import { OSBill, OSTable, OSCoupon, OSTotal } from '../OrderSummary/styles';
13
+ import { OSBill, OSTable, OSCoupon, OSTotal, OSRow } from '../OrderSummary/styles';
14
14
 
15
15
  import { ProductItemAccordion } from '../ProductItemAccordion';
16
16
  import { BusinessItemAccordion } from '../BusinessItemAccordion';
@@ -21,6 +21,9 @@ import { ProductForm } from '../ProductForm';
21
21
  import { UpsellingProducts } from '../UpsellingProducts';
22
22
  import { verifyDecimals } from '../../utils';
23
23
  import { useTheme } from 'styled-components/native';
24
+ import AntIcon from 'react-native-vector-icons/AntDesign'
25
+ import { TaxInformation } from '../TaxInformation';
26
+ import { TouchableOpacity } from 'react-native';
24
27
 
25
28
  const CartUI = (props: any) => {
26
29
  const {
@@ -45,6 +48,7 @@ const CartUI = (props: any) => {
45
48
  const [curProduct, setCurProduct] = useState<any>(null)
46
49
  const [openUpselling, setOpenUpselling] = useState(false)
47
50
  const [canOpenUpselling, setCanOpenUpselling] = useState(false)
51
+ const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
48
52
 
49
53
  const isCartPending = cart?.status === 2
50
54
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
@@ -90,6 +94,16 @@ const CartUI = (props: any) => {
90
94
  })
91
95
  }
92
96
 
97
+ const getIncludedTaxes = () => {
98
+ if (cart?.taxes === null) {
99
+ return cart.business.tax_type === 1 ? cart?.tax : 0
100
+ } else {
101
+ return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
102
+ return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
103
+ }, 0)
104
+ }
105
+ }
106
+
93
107
  return (
94
108
  <CContainer>
95
109
  <BusinessItemAccordion
@@ -118,9 +132,7 @@ const CartUI = (props: any) => {
118
132
  <OSTable>
119
133
  <OText>{t('SUBTOTAL', 'Subtotal')}</OText>
120
134
  <OText>
121
- {cart.business.tax_type === 1
122
- ? parsePrice((cart?.subtotal + cart?.tax) || 0)
123
- : parsePrice(cart?.subtotal || 0)}
135
+ {parsePrice(cart?.subtotal + getIncludedTaxes())}
124
136
  </OText>
125
137
  </OSTable>
126
138
  {cart?.discount > 0 && cart?.total >= 0 && (
@@ -151,15 +163,38 @@ const CartUI = (props: any) => {
151
163
  )}
152
164
  </OSTable>
153
165
  )}
154
- {cart.business.tax_type !== 1 && (
155
- <OSTable>
156
- <OText>
157
- {t('TAX', 'Tax')}
158
- {`(${verifyDecimals(cart?.business?.tax, parseNumber)}%)`}
159
- </OText>
160
- <OText>{parsePrice(cart?.tax || 0)}</OText>
161
- </OSTable>
162
- )}
166
+ {
167
+ cart.taxes?.length > 0 && cart.taxes.filter((tax: any) => tax.type === 2 && tax?.rate !== 0).map((tax: any) => (
168
+ <OSTable key={tax.id}>
169
+ <OSRow>
170
+ <OText numberOfLines={1} >
171
+ {tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
172
+ {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
173
+ </OText>
174
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
175
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
176
+ </TouchableOpacity>
177
+ </OSRow>
178
+ <OText>{parsePrice(tax?.summary?.tax || 0)}</OText>
179
+ </OSTable>
180
+ ))
181
+ }
182
+ {
183
+ cart?.fees?.length > 0 && cart?.fees?.filter((fee : any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any) => (
184
+ <OSTable key={fee?.id}>
185
+ <OSRow>
186
+ <OText numberOfLines={1}>
187
+ {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
188
+ ({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
189
+ </OText>
190
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
191
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
192
+ </TouchableOpacity>
193
+ </OSRow>
194
+ <OText>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
195
+ </OSTable>
196
+ ))
197
+ }
163
198
  {orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
164
199
  <OSTable>
165
200
  <OText>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
@@ -180,15 +215,6 @@ const CartUI = (props: any) => {
180
215
  <OText>{parsePrice(cart?.driver_tip)}</OText>
181
216
  </OSTable>
182
217
  )}
183
- {cart?.service_fee > 0 && (
184
- <OSTable>
185
- <OText>
186
- {t('SERVICE_FEE', 'Service Fee')}
187
- {`(${verifyDecimals(cart?.business?.service_fee, parseNumber)}%)`}
188
- </OText>
189
- <OText>{parsePrice(cart?.service_fee)}</OText>
190
- </OSTable>
191
- )}
192
218
  {isCouponEnabled && !isCartPending && (
193
219
  <OSTable>
194
220
  <OSCoupon>
@@ -263,6 +289,13 @@ const CartUI = (props: any) => {
263
289
  setCanOpenUpselling={setCanOpenUpselling}
264
290
  />
265
291
  )}
292
+ <OModal
293
+ open={openTaxModal.open}
294
+ onClose={() => setOpenTaxModal({ open: false, data: null })}
295
+ entireModal
296
+ >
297
+ <TaxInformation data={openTaxModal.data} products={cart.products} />
298
+ </OModal>
266
299
  </CContainer>
267
300
  )
268
301
  }
@@ -3,6 +3,7 @@ import { View, StyleSheet, BackHandler, TouchableOpacity, I18nManager } from 're
3
3
  import LinearGradient from 'react-native-linear-gradient'
4
4
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
5
5
  import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
6
+ import AntIcon from 'react-native-vector-icons/AntDesign'
6
7
  import { Messages } from '../Messages'
7
8
  import { ShareComponent } from '../ShareComponent'
8
9
  import AsyncStorage from '@react-native-async-storage/async-storage';
@@ -48,6 +49,8 @@ import { verifyDecimals } from '../../utils'
48
49
  import { useTheme } from 'styled-components/native'
49
50
  import { NotFoundSource } from '../NotFoundSource'
50
51
  import { OrderCreating } from '../OrderCreating';
52
+ import { OSRow } from '../OrderSummary/styles';
53
+ import { TaxInformation } from '../TaxInformation';
51
54
 
52
55
  export const OrderDetailsUI = (props: OrderDetailsParams) => {
53
56
  const {
@@ -103,6 +106,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
103
106
  const [unreadAlert, setUnreadAlert] = useState({ business: false, driver: false })
104
107
  const [isReviewed, setIsReviewed] = useState(false)
105
108
  const [openOrderCreating, setOpenOrderCreating] = useState(true)
109
+ const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
106
110
  const { order, loading, businessData, error } = props.order
107
111
  const isTaxIncluded = order?.tax_type === 1
108
112
 
@@ -195,6 +199,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
195
199
  )
196
200
  }
197
201
 
202
+ const getIncludedTaxes = () => {
203
+ if (order?.taxes?.length === 0) {
204
+ return order.tax_type === 1 ? order?.summary?.tax ?? 0 : 0
205
+ } else {
206
+ return order?.taxes.reduce((taxIncluded: number, tax: any) => {
207
+ return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
208
+ }, 0)
209
+ }
210
+ }
211
+
198
212
  useEffect(() => {
199
213
  BackHandler.addEventListener('hardwareBackPress', handleArrowBack);
200
214
  return () => {
@@ -216,7 +230,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
216
230
 
217
231
  useEffect(() => {
218
232
  if (driverLocation) {
219
- locations[0] = {...locations[0], lat: driverLocation.lat, lng: driverLocation.lng}
233
+ locations[0] = { ...locations[0], lat: driverLocation.lat, lng: driverLocation.lng }
220
234
  }
221
235
  }, [driverLocation])
222
236
 
@@ -341,7 +355,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
341
355
  </OrderStatus>
342
356
  </View>
343
357
  <OrderCustomer>
344
- <OText size={18} style={{textAlign: 'left'}}>{t('CUSTOMER', 'Customer')}</OText>
358
+ <OText size={18} style={{ textAlign: 'left' }}>{t('CUSTOMER', 'Customer')}</OText>
345
359
  <Customer>
346
360
  <CustomerPhoto>
347
361
  <OIcon
@@ -352,8 +366,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
352
366
  />
353
367
  </CustomerPhoto>
354
368
  <InfoBlock>
355
- <OText size={18} style={{textAlign: 'left'}} >{order?.customer?.name} {order?.customer?.lastname}</OText>
356
- <OText style={{textAlign: 'left'}}>{order?.customer?.address}</OText>
369
+ <OText size={18} style={{ textAlign: 'left' }} >{order?.customer?.name} {order?.customer?.lastname}</OText>
370
+ <OText style={{ textAlign: 'left' }}>{order?.customer?.address}</OText>
357
371
  </InfoBlock>
358
372
  </Customer>
359
373
  {order?.driver && (
@@ -398,7 +412,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
398
412
  </OrderDriver>
399
413
  )}
400
414
  <OrderProducts>
401
- <OText size={18} style={{textAlign: 'left'}}>{t('YOUR_ORDER', 'Your Order')}</OText>
415
+ <OText size={18} style={{ textAlign: 'left' }}>{t('YOUR_ORDER', 'Your Order')}</OText>
402
416
  {order?.products?.length && order?.products.map((product: any, i: number) => (
403
417
  <ProductItemAccordion
404
418
  key={product?.id || i}
@@ -410,10 +424,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
410
424
  <Table>
411
425
  <OText>{t('SUBTOTAL', 'Subtotal')}</OText>
412
426
  <OText>
413
- {parsePrice(isTaxIncluded
414
- ? (order?.summary?.subtotal + order?.summary?.tax) ?? 0
415
- : order?.summary?.subtotal ?? 0
416
- )}
427
+ {parsePrice(((order?.summary?.subtotal || order?.subtotal) + getIncludedTaxes()))}
417
428
  </OText>
418
429
  </Table>
419
430
  {order?.summary?.discount > 0 && (
@@ -435,40 +446,77 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
435
446
  <OText>{parsePrice(order?.summary?.subtotal_with_discount ?? 0)}</OText>
436
447
  </Table>
437
448
  )}
438
- {order?.tax_type !== 1 && (
439
- <Table>
440
- <OText>
441
- {t('TAX', 'Tax')}
442
- {`(${verifyDecimals(order?.summary?.tax_rate, parseNumber)}%)`}
443
- </OText>
444
- <OText>{parsePrice(order?.summary?.tax)}</OText>
445
- </Table>
446
- )}
449
+ {
450
+ order?.taxes?.length === 0 && order?.tax_type === 2 && (
451
+ <Table>
452
+ <OText>
453
+ {t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
454
+ </OText>
455
+ <OText>{parsePrice(order?.summary?.tax || 0)}</OText>
456
+ </Table>
457
+ )
458
+ }
459
+ {
460
+ order?.fees?.length === 0 && (
461
+ <Table>
462
+ <OText>
463
+ {t('SERVICE_FEE', 'Service fee')}
464
+ {`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
465
+ </OText>
466
+ <OText>{parsePrice(order?.summary?.service_fee || 0)}</OText>
467
+ </Table>
468
+ )
469
+ }
470
+ {
471
+ order?.taxes?.length > 0 && order?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
472
+ <Table key={tax.id}>
473
+ <OSRow>
474
+ <OText numberOfLines={1}>
475
+ {tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
476
+ {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
477
+ </OText>
478
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })}>
479
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
480
+ </TouchableOpacity>
481
+ </OSRow>
482
+ <OText>{parsePrice(tax?.summary?.tax || 0)}</OText>
483
+ </Table>
484
+ ))
485
+ }
486
+ {
487
+ order?.fees?.length > 0 && order?.fees?.filter((fee : any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
488
+ <Table key={fee.id}>
489
+ <OSRow>
490
+ <OText numberOfLines={1}>
491
+ {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
492
+ ({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
493
+ </OText>
494
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })}>
495
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
496
+ </TouchableOpacity>
497
+ </OSRow>
498
+ <OText>{parsePrice(fee?.fixed + fee?.summary?.percentage || 0)}</OText>
499
+ </Table>
500
+ ))
501
+ }
447
502
  {order?.summary?.delivery_price > 0 && (
448
503
  <Table>
449
504
  <OText>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
450
505
  <OText>{parsePrice(order?.summary?.delivery_price)}</OText>
451
506
  </Table>
452
507
  )}
453
- <Table>
454
- <OText>
455
- {t('DRIVER_TIP', 'Driver tip')}
456
- {order?.summary?.driver_tip > 0 &&
457
- parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
458
- !parseInt(configs?.driver_tip_use_custom?.value, 10) &&
459
- (
460
- `(${verifyDecimals(order?.summary?.driver_tip, parseNumber)}%)`
461
- )}
462
- </OText>
463
- <OText>{parsePrice(order?.summary?.driver_tip ?? 0)}</OText>
464
- </Table>
465
- {order?.summary?.service_fee > 0 && (
508
+ {order?.summary?.driver_tip > 0 && (
466
509
  <Table>
467
510
  <OText>
468
- {t('SERVICE_FEE', 'Service Fee')}
469
- {`(${verifyDecimals(order?.summary?.service_fee, parseNumber)}%)`}
511
+ {t('DRIVER_TIP', 'Driver tip')}
512
+ {order?.summary?.driver_tip > 0 &&
513
+ parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
514
+ !parseInt(configs?.driver_tip_use_custom?.value, 10) &&
515
+ (
516
+ `(${verifyDecimals(order?.summary?.driver_tip, parseNumber)}%)`
517
+ )}
470
518
  </OText>
471
- <OText>{parsePrice(order?.summary?.service_fee)}</OText>
519
+ <OText>{parsePrice(order?.summary?.driver_tip ?? 0)}</OText>
472
520
  </Table>
473
521
  )}
474
522
  <Total>
@@ -483,7 +531,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
483
531
  (
484
532
  parseInt(order?.status) === 1 ||
485
533
  parseInt(order?.status) === 11 ||
486
- parseInt(order?.status) === 15
534
+ parseInt(order?.status) === 15
487
535
  ) && !order.review && !isReviewed && (
488
536
  <OButton
489
537
  onClick={() => handleClickOrderReview(order)}
@@ -548,6 +596,13 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
548
596
  isOrderDetail
549
597
  />
550
598
  </OModal>
599
+ <OModal
600
+ open={openTaxModal.open}
601
+ onClose={() => setOpenTaxModal({ open: false, data: null })}
602
+ entireModal
603
+ >
604
+ <TaxInformation data={openTaxModal.data} products={order?.products} />
605
+ </OModal>
551
606
  </OrderDetailsContainer>
552
607
  )
553
608
  }
@@ -1,5 +1,5 @@
1
1
  import React, { useState } from 'react';
2
- import { View } from 'react-native'
2
+ import { TouchableOpacity, View } from 'react-native'
3
3
  import {
4
4
  Cart,
5
5
  useOrder,
@@ -13,7 +13,8 @@ import {
13
13
  OSContainer,
14
14
  OSProductList,
15
15
  OSBill,
16
- OSTable
16
+ OSTable,
17
+ OSRow
17
18
  } from './styles';
18
19
 
19
20
  import { ProductItemAccordion } from '../ProductItemAccordion';
@@ -22,7 +23,8 @@ import { OModal, OText } from '../shared';
22
23
  import { ProductForm } from '../ProductForm';
23
24
  import { verifyDecimals } from '../../utils';
24
25
  import { useTheme } from 'styled-components/native';
25
-
26
+ import { TaxInformation } from '../TaxInformation';
27
+ import AntIcon from 'react-native-vector-icons/AntDesign'
26
28
  const OrderSummaryUI = (props: any) => {
27
29
  const {
28
30
  cart,
@@ -42,6 +44,7 @@ const OrderSummaryUI = (props: any) => {
42
44
  const [validationFields] = useValidationFields();
43
45
  const [openProduct, setModalIsOpen] = useState(false)
44
46
  const [curProduct, setCurProduct] = useState<any>(null)
47
+ const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
45
48
 
46
49
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
47
50
 
@@ -60,6 +63,16 @@ const OrderSummaryUI = (props: any) => {
60
63
  }
61
64
  }
62
65
 
66
+ const getIncludedTaxes = () => {
67
+ if (cart?.taxes === null) {
68
+ return cart.business.tax_type === 1 ? cart?.tax : 0
69
+ } else {
70
+ return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
71
+ return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
72
+ }, 0)
73
+ }
74
+ }
75
+
63
76
  return (
64
77
  <OSContainer>
65
78
  {cart?.products?.length > 0 && (
@@ -84,9 +97,7 @@ const OrderSummaryUI = (props: any) => {
84
97
  <OSBill>
85
98
  <OSTable>
86
99
  <OText size={18}>{t('SUBTOTAL', 'Subtotal')}</OText>
87
- <OText size={18}>{cart.business.tax_type === 1
88
- ? parsePrice((cart?.subtotal + cart?.tax) || 0)
89
- : parsePrice(cart?.subtotal || 0)}</OText>
100
+ <OText size={18}>{parsePrice(cart?.subtotal + getIncludedTaxes())}</OText>
90
101
  </OSTable>
91
102
  {cart?.discount > 0 && cart?.total >= 0 && (
92
103
  <OSTable>
@@ -101,15 +112,38 @@ const OrderSummaryUI = (props: any) => {
101
112
  <OText size={18}>- {parsePrice(cart?.discount || 0)}</OText>
102
113
  </OSTable>
103
114
  )}
104
- {cart.business.tax_type !== 1 && (
105
- <OSTable>
106
- <OText size={18}>
107
- {t('TAX', 'Tax')}
108
- {`(${verifyDecimals(cart?.business?.tax, parseNumber)}%)`}
109
- </OText>
110
- <OText size={18}>{parsePrice(cart?.tax || 0)}</OText>
111
- </OSTable>
112
- )}
115
+ {
116
+ cart?.taxes?.length > 0 && cart?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
117
+ <OSTable key={tax?.id}>
118
+ <OSRow>
119
+ <OText size={18} numberOfLines={1}>
120
+ {tax?.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
121
+ {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
122
+ </OText>
123
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
124
+ <AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
125
+ </TouchableOpacity>
126
+ </OSRow>
127
+ <OText size={18}>{parsePrice(tax?.summary?.tax || 0)}</OText>
128
+ </OSTable>
129
+ ))
130
+ }
131
+ {
132
+ cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
133
+ <OSTable key={fee.id}>
134
+ <OSRow>
135
+ <OText size={18} numberOfLines={1}>
136
+ {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
137
+ ({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
138
+ </OText>
139
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
140
+ <AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
141
+ </TouchableOpacity>
142
+ </OSRow>
143
+ <OText size={18}>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
144
+ </OSTable>
145
+ ))
146
+ }
113
147
  {orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
114
148
  <OSTable>
115
149
  <OText size={18}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
@@ -123,22 +157,13 @@ const OrderSummaryUI = (props: any) => {
123
157
  {cart?.driver_tip_rate > 0 &&
124
158
  parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
125
159
  !parseInt(configs?.driver_tip_use_custom?.value, 10) &&
126
- (
127
- `(${verifyDecimals(cart?.driver_tip_rate, parseNumber)}%)`
128
- )}
160
+ (
161
+ `(${verifyDecimals(cart?.driver_tip_rate, parseNumber)}%)`
162
+ )}
129
163
  </OText>
130
164
  <OText size={18}>{parsePrice(cart?.driver_tip)}</OText>
131
165
  </OSTable>
132
166
  )}
133
- {cart?.service_fee > 0 && (
134
- <OSTable>
135
- <OText size={18}>
136
- {t('SERVICE_FEE', 'Service Fee')}
137
- {`(${verifyDecimals(cart?.business?.service_fee, parseNumber)}%)`}
138
- </OText>
139
- <OText size={18}>{parsePrice(cart?.service_fee)}</OText>
140
- </OSTable>
141
- )}
142
167
  {isCouponEnabled && !isCartPending && (
143
168
  <View>
144
169
  <View style={{ paddingVertical: 5 }}>
@@ -182,6 +207,13 @@ const OrderSummaryUI = (props: any) => {
182
207
  isFromCheckout={isFromCheckout}
183
208
  />
184
209
  </OModal>
210
+ <OModal
211
+ open={openTaxModal.open}
212
+ onClose={() => setOpenTaxModal({ open: false, data: null })}
213
+ entireModal
214
+ >
215
+ <TaxInformation data={openTaxModal.data} products={cart.products} />
216
+ </OModal>
185
217
  </>
186
218
  )}
187
219
  </OSContainer>
@@ -29,3 +29,9 @@ export const OSCoupon = styled.View`
29
29
  width: 100%;
30
30
  padding: 5px 0px;
31
31
  `
32
+
33
+ export const OSRow = styled.View`
34
+ flex-direction: row;
35
+ overflow: hidden;
36
+ width: 80%;
37
+ `
@@ -67,7 +67,7 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
67
67
  <CardContainer
68
68
  style={[styles.container, (isSoldOut || maxProductQuantity <= 0) && styles.soldOutBackgroundStyle]}
69
69
  activeOpacity={1}
70
- onPress={() => onProductClick(product)}
70
+ onPress={() => onProductClick?.(product)}
71
71
  >
72
72
  <OIcon
73
73
  url={optimizeImage(product?.images, 'h_200,c_limit')}
@@ -0,0 +1,51 @@
1
+ import React from 'react'
2
+ import { useLanguage, useUtils } from 'ordering-components/native'
3
+ import { SingleProductCard } from '../SingleProductCard'
4
+ import { TaxInformationContainer, ProductContainer } from './styles'
5
+ import { OText } from '../shared'
6
+
7
+ interface taxInformationParams {
8
+ data: { name: string, description?: string, rate: string | number, type: number, fixed?: number, percentage?: number, id: number },
9
+ products: Array<any>
10
+ }
11
+
12
+ export const TaxInformation = (props: taxInformationParams) => {
13
+ const {
14
+ data,
15
+ products
16
+ } = props
17
+
18
+ const [, t] = useLanguage()
19
+ const [{ parsePrice }] = useUtils()
20
+
21
+ const isTax = typeof data?.rate === 'number'
22
+ const TaxFeeString = isTax ? 'tax' : 'fee'
23
+ const includedOnPriceString = data?.type === 1 ? `(${t('INCLUDED_ON_PRICE', 'Included on price')})` : `(${t('NOT_INCLUDED_ON_PRICE', 'Not included on price')})`
24
+
25
+ return (
26
+ <TaxInformationContainer>
27
+ <OText size={24} style={{ alignSelf: 'center', textAlign: 'center' }} mBottom={10}>
28
+ {`${data?.name ||
29
+ t('INHERIT_FROM_BUSINESS', 'Inherit from business')} (${typeof data?.rate === 'number' ? `${data?.rate}%` : `${parsePrice(data?.fixed ?? 0)} + ${data?.percentage}%`})`}
30
+ </OText>
31
+ {data?.description && (
32
+ <OText mBottom={10} size={18} style={{ alignSelf: 'center', textAlign: 'center' }}>
33
+ {t('DESCRIPTION', 'Description')}: {data?.description} {data?.type && includedOnPriceString}
34
+ </OText>
35
+ )}
36
+ <OText>{t(`OTHER_PRODUCTS_WITH_THIS_${TaxFeeString.toUpperCase()}`, `Other products with this ${TaxFeeString}`)}:</OText>
37
+ <ProductContainer>
38
+ {
39
+ products.filter((product: any) => isTax ? (product.tax?.id ? product.tax?.id === data?.id : product.tax?.id === null && data?.id === null) : (product.fee?.id ? product.fee?.id === data?.id : (product.fee?.id === null && data?.id === null))).map(product => (
40
+ <SingleProductCard
41
+ key={product.id}
42
+ product={product}
43
+ isSoldOut={false}
44
+ businessId={product?.business_id}
45
+ />
46
+ ))
47
+ }
48
+ </ProductContainer>
49
+ </TaxInformationContainer>
50
+ )
51
+ }
@@ -0,0 +1,9 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const TaxInformationContainer = styled.ScrollView`
4
+ padding: 10px;
5
+ `
6
+
7
+ export const ProductContainer = styled.View`
8
+ flex: 1
9
+ `
@@ -202,7 +202,7 @@ export interface SingleProductCardParams {
202
202
  businessId: any,
203
203
  product: any;
204
204
  isSoldOut: boolean;
205
- onProductClick: any;
205
+ onProductClick?: any;
206
206
  }
207
207
  export interface BusinessInformationParams {
208
208
  navigation?: any,