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
@@ -10,7 +10,7 @@ import {
10
10
  import { useTheme } from 'styled-components/native';
11
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';
@@ -20,6 +20,9 @@ import { OButton, OModal, OText } from '../shared';
20
20
  import { ProductForm } from '../ProductForm';
21
21
  import { UpsellingProducts } from '../UpsellingProducts';
22
22
  import { verifyDecimals } from '../../utils';
23
+ import { TouchableOpacity } from 'react-native';
24
+ import AntIcon from 'react-native-vector-icons/AntDesign'
25
+ import { TaxInformation } from '../TaxInformation';
23
26
 
24
27
  const CartUI = (props: any) => {
25
28
  const {
@@ -47,6 +50,7 @@ const CartUI = (props: any) => {
47
50
  const [curProduct, setCurProduct] = useState<any>(null)
48
51
  const [openUpselling, setOpenUpselling] = useState(false)
49
52
  const [canOpenUpselling, setCanOpenUpselling] = useState(false)
53
+ const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
50
54
 
51
55
  const isCartPending = cart?.status === 2
52
56
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
@@ -92,6 +96,16 @@ const CartUI = (props: any) => {
92
96
  })
93
97
  }
94
98
 
99
+ const getIncludedTaxes = () => {
100
+ if (cart?.taxes === null) {
101
+ return cart.business.tax_type === 1 ? cart?.tax : 0
102
+ } else {
103
+ return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
104
+ return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
105
+ }, 0)
106
+ }
107
+ }
108
+
95
109
  return (
96
110
  <CContainer>
97
111
  <BusinessItemAccordion
@@ -120,9 +134,7 @@ const CartUI = (props: any) => {
120
134
  <OSTable>
121
135
  <OText size={12} lineHeight={18}>{t('SUBTOTAL', 'Subtotal')}</OText>
122
136
  <OText size={12} lineHeight={18}>
123
- {cart.business.tax_type === 1
124
- ? parsePrice((cart?.subtotal + cart?.tax) || 0)
125
- : parsePrice(cart?.subtotal || 0)}
137
+ {parsePrice(cart?.subtotal + getIncludedTaxes())}
126
138
  </OText>
127
139
  </OSTable>
128
140
  {cart?.discount > 0 && cart?.total >= 0 && (
@@ -138,15 +150,38 @@ const CartUI = (props: any) => {
138
150
  <OText size={12} lineHeight={18}>- {parsePrice(cart?.discount || 0)}</OText>
139
151
  </OSTable>
140
152
  )}
141
- {cart.business.tax_type !== 1 && (
142
- <OSTable>
143
- <OText size={12} lineHeight={18}>
144
- {t('TAX', 'Tax')}
145
- {`(${verifyDecimals(cart?.business?.tax, parseNumber)}%)`}
146
- </OText>
147
- <OText size={12} lineHeight={18}>{parsePrice(cart?.tax || 0)}</OText>
148
- </OSTable>
149
- )}
153
+ {
154
+ cart.taxes?.length > 0 && cart.taxes.filter((tax: any) => tax.type === 2 && tax?.rate !== 0).map((tax: any) => (
155
+ <OSTable key={tax.id}>
156
+ <OSRow>
157
+ <OText numberOfLines={1} >
158
+ {tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
159
+ {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
160
+ </OText>
161
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
162
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
163
+ </TouchableOpacity>
164
+ </OSRow>
165
+ <OText>{parsePrice(tax?.summary?.tax || 0)}</OText>
166
+ </OSTable>
167
+ ))
168
+ }
169
+ {
170
+ cart?.fees?.length > 0 && cart?.fees?.filter((fee : any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any) => (
171
+ <OSTable key={fee?.id}>
172
+ <OSRow>
173
+ <OText numberOfLines={1}>
174
+ {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
175
+ ({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
176
+ </OText>
177
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
178
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
179
+ </TouchableOpacity>
180
+ </OSRow>
181
+ <OText>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
182
+ </OSTable>
183
+ ))
184
+ }
150
185
  {orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
151
186
  <OSTable>
152
187
  <OText size={12} lineHeight={18}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
@@ -252,6 +287,13 @@ const CartUI = (props: any) => {
252
287
  isFromCart
253
288
  />
254
289
  )}
290
+ <OModal
291
+ open={openTaxModal.open}
292
+ onClose={() => setOpenTaxModal({ open: false, data: null })}
293
+ entireModal
294
+ >
295
+ <TaxInformation data={openTaxModal.data} products={cart.products} />
296
+ </OModal>
255
297
  </CContainer>
256
298
  )
257
299
  }
@@ -43,6 +43,9 @@ import { OrderDetailsParams } from '../../types';
43
43
  import { USER_TYPE } from '../../config/constants';
44
44
  import { GoogleMap } from '../GoogleMap';
45
45
  import { verifyDecimals } from '../../utils';
46
+ import { OSRow } from '../OrderSummary/styles';
47
+ import AntIcon from 'react-native-vector-icons/AntDesign'
48
+ import { TaxInformation } from '../TaxInformation';
46
49
 
47
50
  export const OrderDetailsUI = (props: OrderDetailsParams) => {
48
51
  const {
@@ -96,6 +99,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
96
99
  business: false,
97
100
  driver: false,
98
101
  });
102
+ const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
103
+
99
104
  const { order, businessData } = props.order;
100
105
 
101
106
  const getOrderStatus = (s: string) => {
@@ -324,6 +329,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
324
329
  navigation.navigate('BottomTab');
325
330
  };
326
331
 
332
+ const getIncludedTaxes = () => {
333
+ if (order?.taxes?.length === 0) {
334
+ return order.tax_type === 1 ? order?.summary?.tax ?? 0 : 0
335
+ } else {
336
+ return order?.taxes.reduce((taxIncluded: number, tax: any) => {
337
+ return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
338
+ }, 0)
339
+ }
340
+ }
341
+
327
342
  useEffect(() => {
328
343
  BackHandler.addEventListener('hardwareBackPress', handleArrowBack);
329
344
  return () => {
@@ -658,7 +673,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
658
673
  <Table>
659
674
  <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{t('SUBTOTAL', 'Subtotal')}</OText>
660
675
  <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
661
- {parsePrice(order?.summary?.subtotal || order?.subtotal)}
676
+ {parsePrice(((order?.summary?.subtotal || order?.subtotal) + getIncludedTaxes()))}
662
677
  </OText>
663
678
  </Table>
664
679
  {(order?.summary?.discount > 0 || order?.discount > 0) && (
@@ -679,17 +694,59 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
679
694
  </OText>
680
695
  </Table>
681
696
  )}
682
- {order?.tax_type !== 1 && (
683
- <Table>
684
- <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
685
- {t('TAX', 'Tax')}
686
- {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
687
- </OText>
688
- <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
689
- {parsePrice(order?.summary?.tax || order?.totalTax)}
690
- </OText>
691
- </Table>
692
- )}
697
+ {
698
+ order?.taxes?.length === 0 && order?.tax_type === 2 && (
699
+ <Table>
700
+ <OText size={12}>
701
+ {t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
702
+ </OText>
703
+ <OText size={12}>{parsePrice(order?.summary?.tax || 0)}</OText>
704
+ </Table>
705
+ )
706
+ }
707
+ {
708
+ order?.fees?.length === 0 && (
709
+ <Table>
710
+ <OText size={12}>
711
+ {t('SERVICE_FEE', 'Service fee')}
712
+ {`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
713
+ </OText>
714
+ <OText size={12}>{parsePrice(order?.summary?.service_fee || 0)}</OText>
715
+ </Table>
716
+ )
717
+ }
718
+ {
719
+ order?.taxes?.length > 0 && order?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
720
+ <Table key={tax.id}>
721
+ <OSRow>
722
+ <OText size={12} numberOfLines={1}>
723
+ {tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
724
+ {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
725
+ </OText>
726
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })}>
727
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
728
+ </TouchableOpacity>
729
+ </OSRow>
730
+ <OText size={12}>{parsePrice(tax?.summary?.tax || 0)}</OText>
731
+ </Table>
732
+ ))
733
+ }
734
+ {
735
+ order?.fees?.length > 0 && order?.fees?.filter((fee : any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
736
+ <Table key={fee.id}>
737
+ <OSRow>
738
+ <OText size={12} numberOfLines={1}>
739
+ {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
740
+ ({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
741
+ </OText>
742
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })}>
743
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
744
+ </TouchableOpacity>
745
+ </OSRow>
746
+ <OText size={12}>{parsePrice(fee?.fixed + fee?.summary?.percentage || 0)}</OText>
747
+ </Table>
748
+ ))
749
+ }
693
750
  {(order?.summary?.delivery_price > 0 ||
694
751
  order?.deliveryFee > 0) && (
695
752
  <Table>
@@ -715,17 +772,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
715
772
  )}
716
773
  </OText>
717
774
  </Table>
718
- <Table>
719
- <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
720
- {t('SERVICE_FEE', 'Service Fee')}
721
- {`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
722
- </OText>
723
- <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
724
- {parsePrice(
725
- order?.summary?.service_fee || order?.serviceFee || 0,
726
- )}
727
- </OText>
728
- </Table>
729
775
  <Total>
730
776
  <Table>
731
777
  <OText size={20} lineHeight={30} weight={'600'} color={theme.colors.textNormal}>{t('TOTAL', 'Total')}</OText>
@@ -752,6 +798,13 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
752
798
  onClose={handleCloseModal}
753
799
  />
754
800
  </OModal>
801
+ <OModal
802
+ open={openTaxModal.open}
803
+ onClose={() => setOpenTaxModal({ open: false, data: null })}
804
+ entireModal
805
+ >
806
+ <TaxInformation data={openTaxModal.data} products={order?.products} />
807
+ </OModal>
755
808
  </OrderDetailsContainer>
756
809
  );
757
810
  };