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,19 +1,20 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { View } from 'react-native'
2
+ import { TouchableOpacity, View } from 'react-native'
3
3
  import {
4
- Cart,
5
- useOrder,
6
- useLanguage,
7
- useUtils,
8
- useConfig,
9
- useValidationFields,
4
+ Cart,
5
+ useOrder,
6
+ useLanguage,
7
+ useUtils,
8
+ useConfig,
9
+ useValidationFields,
10
10
  } from 'ordering-components/native';
11
11
 
12
12
  import {
13
- OSContainer,
14
- OSProductList,
15
- OSBill,
16
- OSTable
13
+ OSContainer,
14
+ OSProductList,
15
+ OSBill,
16
+ OSTable,
17
+ OSRow
17
18
  } from './styles';
18
19
 
19
20
  import { ProductItemAccordion } from '../ProductItemAccordion';
@@ -23,200 +24,241 @@ import { ProductForm } from '../ProductForm';
23
24
  import { verifyDecimals } from '../../utils';
24
25
  import { useTheme } from 'styled-components/native';
25
26
  import { DriverTips } from '../DriverTips';
27
+ import AntIcon from 'react-native-vector-icons/AntDesign'
28
+ import { TaxInformation } from '../TaxInformation';
26
29
 
27
30
  const OrderSummaryUI = (props: any) => {
28
- const {
29
- cart,
30
- changeQuantity,
31
- getProductMax,
32
- offsetDisabled,
33
- removeProduct,
34
- isCartPending,
35
- isFromCheckout,
36
- isDriverTips,
37
- handleProductDelete,
38
- handleProductEdit
39
- } = props;
31
+ const {
32
+ cart,
33
+ changeQuantity,
34
+ getProductMax,
35
+ offsetDisabled,
36
+ removeProduct,
37
+ isCartPending,
38
+ isFromCheckout,
39
+ isDriverTips,
40
+ handleProductDelete,
41
+ handleProductEdit
42
+ } = props;
40
43
 
41
- const theme = useTheme();
42
- const [, t] = useLanguage();
43
- const [{ configs }] = useConfig();
44
- const [orderState] = useOrder();
45
- const [{ parsePrice, parseNumber }] = useUtils();
46
- const [validationFields] = useValidationFields();
47
- const [openProduct, setModalIsOpen] = useState(false)
48
- const [curProduct, setCurProduct] = useState<any>(null)
44
+ const theme = useTheme();
45
+ const [, t] = useLanguage();
46
+ const [{ configs }] = useConfig();
47
+ const [orderState] = useOrder();
48
+ const [{ parsePrice, parseNumber }] = useUtils();
49
+ const [validationFields] = useValidationFields();
50
+ const [openProduct, setModalIsOpen] = useState(false)
51
+ const [curProduct, setCurProduct] = useState<any>(null)
52
+ const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
49
53
 
50
- const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
54
+ const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
51
55
 
52
- const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
53
- ? JSON.parse(configs?.driver_tip_options?.value) || []
54
- : configs?.driver_tip_options?.value || []
56
+ const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
57
+ ? JSON.parse(configs?.driver_tip_options?.value) || []
58
+ : configs?.driver_tip_options?.value || []
55
59
 
56
- const handlerProductAction = (product: any) => {
57
- if (Object.keys(product).length) {
58
- setModalIsOpen(false)
59
- }
60
- }
60
+ const handlerProductAction = (product: any) => {
61
+ if (Object.keys(product).length) {
62
+ setModalIsOpen(false)
63
+ }
64
+ }
61
65
 
62
- return (
63
- <OSContainer>
64
- {cart?.products?.length > 0 && (
65
- <>
66
- <OSProductList>
67
- {cart?.products.map((product: any) => (
68
- <ProductItemAccordion
69
- key={product.code}
70
- product={product}
71
- isCartPending={isCartPending}
72
- isCartProduct
73
- changeQuantity={changeQuantity}
74
- getProductMax={getProductMax}
75
- offsetDisabled={offsetDisabled}
76
- onDeleteProduct={handleProductDelete}
77
- onEditProduct={handleProductEdit}
78
- isFromCheckout={isFromCheckout}
79
- isExpanded
80
- />
81
- ))}
82
- </OSProductList>
83
- {isDriverTips && driverTipsOptions && driverTipsOptions?.length > 0 && (
84
- <View style={{ flexDirection: 'column', paddingVertical: 10, paddingBottom: 17, borderBottomWidth: 1, borderBottomColor: theme.colors.border }}>
85
- <View style={{ flexDirection: 'row', alignItems: 'center' }}>
86
- <OIcon src={theme.images.general.bicycle} color={theme.colors.primary} width={16} style={{ marginEnd: 7 }} />
87
- <OText style={{ ...theme.labels.middle, fontWeight: '600', marginBottom: 3 }}>
88
- {t('DRIVER_TIPS', 'Driver Tips')}
89
- </OText>
90
- </View>
91
- <DriverTips
92
- businessId={cart?.business_id}
93
- driverTipsOptions={driverTipsOptions}
94
- isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)}
95
- isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
96
- driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)
97
- ? cart?.driver_tip
98
- : cart?.driver_tip_rate}
99
- useOrderContext
100
- wrapStyle={{ alignSelf: 'stretch' }}
101
- />
102
- </View>
103
- )}
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
+ }
104
75
 
105
- {cart?.valid && (
106
- <OSBill>
107
- <OSTable>
108
- <OText style={theme.labels.normal} color={theme.colors.textPrimary}>{t('SUBTOTAL', 'Subtotal')}</OText>
109
- <OText style={theme.labels.normal} color={theme.colors.textPrimary}>{cart.business.tax_type === 1
110
- ? parsePrice((cart?.subtotal + cart?.tax) || 0)
111
- : parsePrice(cart?.subtotal || 0)}</OText>
112
- </OSTable>
113
- {cart?.discount > 0 && cart?.total >= 0 && (
114
- <OSTable>
115
- {cart?.discount_type === 1 ? (
116
- <OText style={theme.labels.normal} color={theme.colors.textPrimary}>
117
- {t('DISCOUNT', 'Discount')}
118
- <OText style={theme.labels.normal} color={theme.colors.textPrimary}>{`(${verifyDecimals(cart?.discount_rate, parsePrice)}%)`}</OText>
119
- </OText>
120
- ) : (
121
- <OText style={theme.labels.normal} color={theme.colors.textPrimary}>{t('DISCOUNT', 'Discount')}</OText>
122
- )}
123
- <OText style={theme.labels.normal} color={theme.colors.textPrimary}>- {parsePrice(cart?.discount || 0)}</OText>
124
- </OSTable>
125
- )}
126
- {cart.business.tax_type !== 1 && (
127
- <OSTable>
128
- <OText style={theme.labels.normal} color={theme.colors.textPrimary}>
129
- {t('TAX', 'Tax')}
130
- {`(${verifyDecimals(cart?.business?.tax, parseNumber)}%)`}
131
- </OText>
132
- <OText style={theme.labels.normal} color={theme.colors.textPrimary}>{parsePrice(cart?.tax || 0)}</OText>
133
- </OSTable>
134
- )}
135
- {orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
136
- <OSTable>
137
- <OText style={theme.labels.normal} color={theme.colors.textPrimary}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
138
- <OText style={theme.labels.normal} color={theme.colors.textPrimary}>{parsePrice(cart?.delivery_price)}</OText>
139
- </OSTable>
140
- )}
141
- {cart?.driver_tip > 0 && (
142
- <OSTable>
143
- <OText style={theme.labels.normal} color={theme.colors.textPrimary}>
144
- {t('DRIVER_TIP', 'Driver tip')}
145
- {cart?.driver_tip_rate > 0 &&
146
- parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
147
- !parseInt(configs?.driver_tip_use_custom?.value, 10) &&
148
- (
149
- `(${verifyDecimals(cart?.driver_tip_rate, parseNumber)}%)`
150
- )}
151
- </OText>
152
- <OText style={theme.labels.normal} color={theme.colors.textPrimary}>{parsePrice(cart?.driver_tip)}</OText>
153
- </OSTable>
154
- )}
155
- {cart?.service_fee > 0 && (
156
- <OSTable>
157
- <OText style={theme.labels.normal} color={theme.colors.textPrimary}>
158
- {t('SERVICE_FEE', 'Service Fee')}
159
- {`(${verifyDecimals(cart?.business?.service_fee, parseNumber)}%)`}
160
- </OText>
161
- <OText style={theme.labels.normal} color={theme.colors.textPrimary}>{parsePrice(cart?.service_fee)}</OText>
162
- </OSTable>
163
- )}
164
- {cart?.total >= 1 && (
165
- <View style={{}}>
166
- <OSTable>
167
- <OText size={12} lineHeight={18} weight={'600'} color={theme.colors.textPrimary}>
168
- {t('TOTAL', 'Total')}
169
- </OText>
170
- <OText size={12} lineHeight={18} weight={'600'} color={theme.colors.textPrimary}>
171
- {parsePrice(cart?.total)}
172
- </OText>
173
- </OSTable>
174
- </View>
175
- )}
176
- {isCouponEnabled && !isCartPending && (
177
- <View>
178
- <View style={{ paddingVertical: 5 }}>
179
- <CouponControl
180
- businessId={cart.business_id}
181
- price={cart.total}
182
- />
183
- </View>
184
- </View>
185
- )}
76
+ return (
77
+ <OSContainer>
78
+ {cart?.products?.length > 0 && (
79
+ <>
80
+ <OSProductList>
81
+ {cart?.products.map((product: any) => (
82
+ <ProductItemAccordion
83
+ key={product.code}
84
+ product={product}
85
+ isCartPending={isCartPending}
86
+ isCartProduct
87
+ changeQuantity={changeQuantity}
88
+ getProductMax={getProductMax}
89
+ offsetDisabled={offsetDisabled}
90
+ onDeleteProduct={handleProductDelete}
91
+ onEditProduct={handleProductEdit}
92
+ isFromCheckout={isFromCheckout}
93
+ isExpanded
94
+ />
95
+ ))}
96
+ </OSProductList>
97
+ {isDriverTips && driverTipsOptions && driverTipsOptions?.length > 0 && (
98
+ <View style={{ flexDirection: 'column', paddingVertical: 10, paddingBottom: 17, borderBottomWidth: 1, borderBottomColor: theme.colors.border }}>
99
+ <View style={{ flexDirection: 'row', alignItems: 'center' }}>
100
+ <OIcon src={theme.images.general.bicycle} color={theme.colors.primary} width={16} style={{ marginEnd: 7 }} />
101
+ <OText style={{ ...theme.labels.middle, fontWeight: '600', marginBottom: 3 }}>
102
+ {t('DRIVER_TIPS', 'Driver Tips')}
103
+ </OText>
104
+ </View>
105
+ <DriverTips
106
+ businessId={cart?.business_id}
107
+ driverTipsOptions={driverTipsOptions}
108
+ isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)}
109
+ isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
110
+ driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)
111
+ ? cart?.driver_tip
112
+ : cart?.driver_tip_rate}
113
+ useOrderContext
114
+ wrapStyle={{ alignSelf: 'stretch' }}
115
+ />
116
+ </View>
117
+ )}
186
118
 
187
- </OSBill>
188
- )}
189
- <OModal
190
- open={openProduct}
191
- entireModal
192
- customClose
193
- onClose={() => setModalIsOpen(false)}
194
- >
195
- <ProductForm
196
- isCartProduct
197
- productCart={curProduct}
198
- businessSlug={cart?.business?.slug}
199
- businessId={cart?.business_id}
200
- categoryId={curProduct?.category_id}
201
- productId={curProduct?.id}
202
- onSave={handlerProductAction}
203
- onClose={() => setModalIsOpen(false)}
204
- isFromCheckout={isFromCheckout}
205
- />
206
- </OModal>
207
- </>
208
- )}
209
- </OSContainer>
210
- )
119
+ {cart?.valid && (
120
+ <OSBill>
121
+ <OSTable>
122
+ <OText style={theme.labels.normal} color={theme.colors.textPrimary}>{t('SUBTOTAL', 'Subtotal')}</OText>
123
+ <OText style={theme.labels.normal} color={theme.colors.textPrimary}>{parsePrice(cart?.subtotal + getIncludedTaxes())}</OText>
124
+ </OSTable>
125
+ {cart?.discount > 0 && cart?.total >= 0 && (
126
+ <OSTable>
127
+ {cart?.discount_type === 1 ? (
128
+ <OText style={theme.labels.normal} color={theme.colors.textPrimary}>
129
+ {t('DISCOUNT', 'Discount')}
130
+ <OText style={theme.labels.normal} color={theme.colors.textPrimary}>{`(${verifyDecimals(cart?.discount_rate, parsePrice)}%)`}</OText>
131
+ </OText>
132
+ ) : (
133
+ <OText style={theme.labels.normal} color={theme.colors.textPrimary}>{t('DISCOUNT', 'Discount')}</OText>
134
+ )}
135
+ <OText style={theme.labels.normal} color={theme.colors.textPrimary}>- {parsePrice(cart?.discount || 0)}</OText>
136
+ </OSTable>
137
+ )}
138
+ {
139
+ cart?.taxes?.length > 0 && cart?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
140
+ <OSTable key={tax?.id}>
141
+ <OSRow>
142
+ <OText numberOfLines={1}>
143
+ {tax?.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
144
+ {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
145
+ </OText>
146
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
147
+ <AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
148
+ </TouchableOpacity>
149
+ </OSRow>
150
+ <OText >{parsePrice(tax?.summary?.tax || 0)}</OText>
151
+ </OSTable>
152
+ ))
153
+ }
154
+ {
155
+ cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
156
+ <OSTable key={fee.id}>
157
+ <OSRow>
158
+ <OText numberOfLines={1}>
159
+ {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
160
+ ({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
161
+ </OText>
162
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
163
+ <AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
164
+ </TouchableOpacity>
165
+ </OSRow>
166
+ <OText>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
167
+ </OSTable>
168
+ ))
169
+ }
170
+ {orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
171
+ <OSTable>
172
+ <OText style={theme.labels.normal} color={theme.colors.textPrimary}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
173
+ <OText style={theme.labels.normal} color={theme.colors.textPrimary}>{parsePrice(cart?.delivery_price)}</OText>
174
+ </OSTable>
175
+ )}
176
+ {cart?.driver_tip > 0 && (
177
+ <OSTable>
178
+ <OText style={theme.labels.normal} color={theme.colors.textPrimary}>
179
+ {t('DRIVER_TIP', 'Driver tip')}
180
+ {cart?.driver_tip_rate > 0 &&
181
+ parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
182
+ !parseInt(configs?.driver_tip_use_custom?.value, 10) &&
183
+ (
184
+ `(${verifyDecimals(cart?.driver_tip_rate, parseNumber)}%)`
185
+ )}
186
+ </OText>
187
+ <OText style={theme.labels.normal} color={theme.colors.textPrimary}>{parsePrice(cart?.driver_tip)}</OText>
188
+ </OSTable>
189
+ )}
190
+ {cart?.service_fee > 0 && (
191
+ <OSTable>
192
+ <OText style={theme.labels.normal} color={theme.colors.textPrimary}>
193
+ {t('SERVICE_FEE', 'Service Fee')}
194
+ {`(${verifyDecimals(cart?.business?.service_fee, parseNumber)}%)`}
195
+ </OText>
196
+ <OText style={theme.labels.normal} color={theme.colors.textPrimary}>{parsePrice(cart?.service_fee)}</OText>
197
+ </OSTable>
198
+ )}
199
+ {cart?.total >= 1 && (
200
+ <View style={{}}>
201
+ <OSTable>
202
+ <OText size={12} lineHeight={18} weight={'600'} color={theme.colors.textPrimary}>
203
+ {t('TOTAL', 'Total')}
204
+ </OText>
205
+ <OText size={12} lineHeight={18} weight={'600'} color={theme.colors.textPrimary}>
206
+ {parsePrice(cart?.total)}
207
+ </OText>
208
+ </OSTable>
209
+ </View>
210
+ )}
211
+ {isCouponEnabled && !isCartPending && (
212
+ <View>
213
+ <View style={{ paddingVertical: 5 }}>
214
+ <CouponControl
215
+ businessId={cart.business_id}
216
+ price={cart.total}
217
+ />
218
+ </View>
219
+ </View>
220
+ )}
221
+
222
+ </OSBill>
223
+ )}
224
+ <OModal
225
+ open={openProduct}
226
+ entireModal
227
+ customClose
228
+ onClose={() => setModalIsOpen(false)}
229
+ >
230
+ <ProductForm
231
+ isCartProduct
232
+ productCart={curProduct}
233
+ businessSlug={cart?.business?.slug}
234
+ businessId={cart?.business_id}
235
+ categoryId={curProduct?.category_id}
236
+ productId={curProduct?.id}
237
+ onSave={handlerProductAction}
238
+ onClose={() => setModalIsOpen(false)}
239
+ isFromCheckout={isFromCheckout}
240
+ />
241
+ </OModal>
242
+ <OModal
243
+ open={openTaxModal.open}
244
+ onClose={() => setOpenTaxModal({ open: false, data: null })}
245
+ entireModal
246
+ >
247
+ <TaxInformation data={openTaxModal.data} products={cart.products} />
248
+ </OModal>
249
+ </>
250
+ )}
251
+ </OSContainer>
252
+ )
211
253
  }
212
254
 
213
255
  export const OrderSummary = (props: any) => {
214
- const orderSummaryProps = {
215
- ...props,
216
- UIComponent: OrderSummaryUI
217
- }
256
+ const orderSummaryProps = {
257
+ ...props,
258
+ UIComponent: OrderSummaryUI
259
+ }
218
260
 
219
- return (
220
- <Cart {...orderSummaryProps} />
221
- )
261
+ return (
262
+ <Cart {...orderSummaryProps} />
263
+ )
222
264
  }
@@ -34,3 +34,9 @@ export const OSCoupon = styled.View`
34
34
  width: 100%;
35
35
  padding: 5px 0px;
36
36
  `
37
+
38
+ export const OSRow = styled.View`
39
+ flex-direction: row;
40
+ overflow: hidden;
41
+ width: 80%;
42
+ `
@@ -76,7 +76,7 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
76
76
 
77
77
  return (
78
78
  <CardContainer style={styles.container}
79
- onPress={() => onProductClick(product)}
79
+ onPress={() => onProductClick?.(product)}
80
80
  activeOpacity={0.8}
81
81
  >
82
82
  <OIcon
@@ -90,7 +90,7 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
90
90
  <OText color={theme.colors.textSecondary} size={9} numberOfLines={2} ellipsizeMode='tail' style={{...styles.textStyle, ...theme.labels.small}}>{product?.description}</OText>
91
91
  </CardInfo>
92
92
 
93
- <TouchableOpacity style={styles.addBtn} onPress={() => onProductClick(product)} activeOpacity={0.7}>
93
+ <TouchableOpacity style={styles.addBtn} onPress={() => onProductClick?.(product)} activeOpacity={0.7}>
94
94
  <OIcon src={theme.images.general.plus_circle} />
95
95
  </TouchableOpacity>
96
96
 
@@ -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
+ `