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
@@ -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,6 +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';
26
+ import AntIcon from 'react-native-vector-icons/AntDesign'
27
+ import { TaxInformation } from '../TaxInformation';
25
28
 
26
29
  const OrderSummaryUI = (props: any) => {
27
30
  const {
@@ -42,6 +45,7 @@ const OrderSummaryUI = (props: any) => {
42
45
  const [validationFields] = useValidationFields();
43
46
  const [openProduct, setModalIsOpen] = useState(false)
44
47
  const [curProduct, setCurProduct] = useState<any>(null)
48
+ const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
45
49
 
46
50
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
47
51
 
@@ -60,6 +64,16 @@ const OrderSummaryUI = (props: any) => {
60
64
  }
61
65
  }
62
66
 
67
+ const getIncludedTaxes = () => {
68
+ if (cart?.taxes === null) {
69
+ return cart.business.tax_type === 1 ? cart?.tax : 0
70
+ } else {
71
+ return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
72
+ return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
73
+ }, 0)
74
+ }
75
+ }
76
+
63
77
  return (
64
78
  <OSContainer>
65
79
  {cart?.products?.length > 0 && (
@@ -84,9 +98,7 @@ const OrderSummaryUI = (props: any) => {
84
98
  <OSBill>
85
99
  <OSTable>
86
100
  <OText size={16}>{t('SUBTOTAL', 'Subtotal')}</OText>
87
- <OText size={16}>{cart.business.tax_type === 1
88
- ? parsePrice((cart?.subtotal + cart?.tax) || 0)
89
- : parsePrice(cart?.subtotal || 0)}</OText>
101
+ <OText size={16}>{parsePrice(cart?.subtotal + getIncludedTaxes())}</OText>
90
102
  </OSTable>
91
103
  {cart?.discount > 0 && cart?.total >= 0 && (
92
104
  <OSTable>
@@ -101,15 +113,38 @@ const OrderSummaryUI = (props: any) => {
101
113
  <OText size={16}>- {parsePrice(cart?.discount || 0)}</OText>
102
114
  </OSTable>
103
115
  )}
104
- {cart.business.tax_type !== 1 && (
105
- <OSTable>
106
- <OText size={16}>
107
- {t('TAX', 'Tax')}
108
- {`(${verifyDecimals(cart?.business?.tax, parseNumber)}%)`}
109
- </OText>
110
- <OText size={16}>{parsePrice(cart?.tax || 0)}</OText>
111
- </OSTable>
112
- )}
116
+ {
117
+ cart?.taxes?.length > 0 && cart?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
118
+ <OSTable key={tax?.id}>
119
+ <OSRow>
120
+ <OText size={16} numberOfLines={1}>
121
+ {tax?.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
122
+ {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
123
+ </OText>
124
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
125
+ <AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
126
+ </TouchableOpacity>
127
+ </OSRow>
128
+ <OText size={16}>{parsePrice(tax?.summary?.tax || 0)}</OText>
129
+ </OSTable>
130
+ ))
131
+ }
132
+ {
133
+ cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
134
+ <OSTable key={fee.id}>
135
+ <OSRow>
136
+ <OText size={16} numberOfLines={1}>
137
+ {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
138
+ ({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
139
+ </OText>
140
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
141
+ <AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
142
+ </TouchableOpacity>
143
+ </OSRow>
144
+ <OText size={16}>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
145
+ </OSTable>
146
+ ))
147
+ }
113
148
  {orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
114
149
  <OSTable>
115
150
  <OText size={16}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
@@ -130,15 +165,6 @@ const OrderSummaryUI = (props: any) => {
130
165
  <OText size={16}>{parsePrice(cart?.driver_tip)}</OText>
131
166
  </OSTable>
132
167
  )}
133
- {cart?.service_fee > 0 && (
134
- <OSTable>
135
- <OText size={16}>
136
- {t('SERVICE_FEE', 'Service Fee')}
137
- {`(${verifyDecimals(cart?.business?.service_fee, parseNumber)}%)`}
138
- </OText>
139
- <OText size={16}>{parsePrice(cart?.service_fee)}</OText>
140
- </OSTable>
141
- )}
142
168
  {isCouponEnabled && !isCartPending && (
143
169
  <View>
144
170
  <View style={{ paddingVertical: 5 }}>
@@ -181,6 +207,13 @@ const OrderSummaryUI = (props: any) => {
181
207
  isFromCheckout={isFromCheckout}
182
208
  />
183
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>
184
217
  </>
185
218
  )}
186
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
+ `
@@ -59,7 +59,7 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
59
59
 
60
60
  return (
61
61
  <CardContainer style={[(isSoldOut || maxProductQuantity <= 0) && styles.soldOutBackgroundStyle]}
62
- onPress={() => onProductClick(product)}
62
+ onPress={() => onProductClick?.(product)}
63
63
  >
64
64
  <CardInfo>
65
65
  <OText weight={500} numberOfLines={1} ellipsizeMode='tail' style={styles.textStyle}>{product?.name}</OText>
@@ -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
+ `