ordering-ui-react-native 0.12.42 → 0.12.46

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 (59) hide show
  1. package/package.json +1 -1
  2. package/src/components/AppleLogin/index.tsx +145 -0
  3. package/src/components/AppleLogin/styles.tsx +22 -0
  4. package/src/components/BusinessesListing/index.tsx +1 -1
  5. package/src/components/Cart/index.tsx +64 -31
  6. package/src/components/LoginForm/index.tsx +34 -17
  7. package/src/components/OrderDetails/index.tsx +90 -35
  8. package/src/components/OrderSummary/index.tsx +59 -27
  9. package/src/components/OrderSummary/styles.tsx +6 -0
  10. package/src/components/SignupForm/index.tsx +52 -35
  11. package/src/components/SingleProductCard/index.tsx +1 -1
  12. package/src/components/TaxInformation/index.tsx +51 -0
  13. package/src/components/TaxInformation/styles.tsx +9 -0
  14. package/src/components/UserFormDetails/index.tsx +0 -2
  15. package/src/navigators/BottomNavigator.tsx +1 -1
  16. package/src/types/index.tsx +7 -1
  17. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +12 -7
  18. package/themes/doordash/src/components/Cart/index.tsx +55 -22
  19. package/themes/doordash/src/components/OrderDetails/index.tsx +444 -386
  20. package/themes/doordash/src/components/OrderSummary/index.tsx +252 -221
  21. package/themes/doordash/src/components/OrderSummary/styles.tsx +6 -0
  22. package/themes/doordash/src/components/SingleProductCard/index.tsx +1 -1
  23. package/themes/doordash/src/components/TaxInformation/index.tsx +51 -0
  24. package/themes/doordash/src/components/TaxInformation/styles.tsx +9 -0
  25. package/themes/franchises/src/components/Cart/index.tsx +55 -23
  26. package/themes/franchises/src/components/OrderDetails/index.tsx +77 -23
  27. package/themes/franchises/src/components/OrderSummary/index.tsx +58 -24
  28. package/themes/franchises/src/components/OrderSummary/styles.tsx +6 -0
  29. package/themes/franchises/src/components/SingleProductCard/index.tsx +1 -1
  30. package/themes/franchises/src/components/TaxInformation/index.tsx +51 -0
  31. package/themes/franchises/src/components/TaxInformation/styles.tsx +9 -0
  32. package/themes/instacart/src/components/Cart/index.tsx +57 -17
  33. package/themes/instacart/src/components/OrderDetails/index.tsx +490 -433
  34. package/themes/instacart/src/components/OrderSummary/index.tsx +236 -194
  35. package/themes/instacart/src/components/OrderSummary/styles.tsx +6 -0
  36. package/themes/instacart/src/components/SingleProductCard/index.tsx +2 -2
  37. package/themes/instacart/src/components/TaxInformation/index.tsx +51 -0
  38. package/themes/instacart/src/components/TaxInformation/styles.tsx +9 -0
  39. package/themes/original/src/components/Cart/index.tsx +55 -13
  40. package/themes/original/src/components/OrderDetails/index.tsx +76 -23
  41. package/themes/original/src/components/OrderSummary/index.tsx +208 -173
  42. package/themes/original/src/components/OrderSummary/styles.tsx +6 -0
  43. package/themes/original/src/components/SingleProductCard/index.tsx +1 -1
  44. package/themes/original/src/components/TaxInformation/index.tsx +51 -0
  45. package/themes/original/src/components/TaxInformation/styles.tsx +9 -0
  46. package/themes/single-business/src/components/Cart/index.tsx +57 -24
  47. package/themes/single-business/src/components/OrderDetails/index.tsx +77 -23
  48. package/themes/single-business/src/components/OrderSummary/index.tsx +58 -24
  49. package/themes/single-business/src/components/OrderSummary/styles.tsx +6 -0
  50. package/themes/single-business/src/components/SingleProductCard/index.tsx +1 -1
  51. package/themes/single-business/src/components/TaxInformation/index.tsx +51 -0
  52. package/themes/single-business/src/components/TaxInformation/styles.tsx +9 -0
  53. package/themes/uber-eats/src/components/Cart/index.tsx +56 -14
  54. package/themes/uber-eats/src/components/OrderDetails/index.tsx +81 -22
  55. package/themes/uber-eats/src/components/OrderSummary/index.tsx +56 -23
  56. package/themes/uber-eats/src/components/OrderSummary/styles.tsx +6 -0
  57. package/themes/uber-eats/src/components/SingleProductCard/index.tsx +1 -1
  58. package/themes/uber-eats/src/components/TaxInformation/index.tsx +51 -0
  59. package/themes/uber-eats/src/components/TaxInformation/styles.tsx +9 -0
@@ -1,19 +1,20 @@
1
1
  import React, { useState } from 'react';
2
- import { TextStyle, View } from 'react-native'
2
+ import { TextStyle, 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,229 +24,259 @@ import { useTheme } from 'styled-components/native';
23
24
  import { ProductForm } from '../ProductForm';
24
25
  import { verifyDecimals } from '../../utils';
25
26
  import { UpsellingProducts } from '../UpsellingProducts';
26
-
27
+ import { TaxInformation } from '../TaxInformation';
28
+ import AntIcon from 'react-native-vector-icons/AntDesign'
27
29
 
28
30
  const OrderSummaryUI = (props: any) => {
29
- const {
30
- cart,
31
- changeQuantity,
32
- getProductMax,
33
- offsetDisabled,
34
- removeProduct,
35
- isCartPending,
36
- isFromCheckout,
37
- hasUpSelling,
38
- title,
39
- paddingH,
40
- isMini,
41
- } = props;
31
+ const {
32
+ cart,
33
+ changeQuantity,
34
+ getProductMax,
35
+ offsetDisabled,
36
+ removeProduct,
37
+ isCartPending,
38
+ isFromCheckout,
39
+ hasUpSelling,
40
+ title,
41
+ paddingH,
42
+ isMini,
43
+ } = props;
42
44
 
43
- const theme = useTheme();
45
+ const theme = useTheme();
44
46
 
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)
47
+ const [, t] = useLanguage();
48
+ const [{ configs }] = useConfig();
49
+ const [orderState] = useOrder();
50
+ const [{ parsePrice, parseNumber }] = useUtils();
51
+ const [validationFields] = useValidationFields();
52
+ const [openProduct, setModalIsOpen] = useState(false)
53
+ const [curProduct, setCurProduct] = useState<any>(null)
54
+ const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
52
55
 
53
- const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
56
+ const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
54
57
 
55
- const handleDeleteClick = (product: any) => {
56
- removeProduct(product, cart)
57
- }
58
+ const handleDeleteClick = (product: any) => {
59
+ removeProduct(product, cart)
60
+ }
58
61
 
59
- const handleEditProduct = (product: any) => {
60
- setCurProduct(product)
61
- setModalIsOpen(true)
62
- }
62
+ const handleEditProduct = (product: any) => {
63
+ setCurProduct(product)
64
+ setModalIsOpen(true)
65
+ }
63
66
 
64
- const handlerProductAction = (product: any) => {
65
- if (Object.keys(product).length) {
66
- setModalIsOpen(false)
67
- }
68
- }
67
+ const handlerProductAction = (product: any) => {
68
+ if (Object.keys(product).length) {
69
+ setModalIsOpen(false)
70
+ }
71
+ }
69
72
 
70
- return (
71
- <OSContainer>
72
- {cart?.products?.length > 0 && (
73
- <>
74
- <OSProductList style={{ paddingHorizontal: paddingH }}>
75
- {title && <OText style={{ ...theme.labels.middle, marginVertical: 12 } as TextStyle}>{title}</OText>}
76
- {cart?.products.map((product: any) => (
77
- <ProductItemAccordion
78
- key={product.code}
79
- product={product}
80
- isCartPending={isCartPending}
81
- isCartProduct
82
- changeQuantity={changeQuantity}
83
- getProductMax={getProductMax}
84
- offsetDisabled={offsetDisabled}
85
- onDeleteProduct={handleDeleteClick}
86
- onEditProduct={handleEditProduct}
87
- isFromCheckout={isFromCheckout}
88
- isMini={isMini}
89
- />
90
- ))}
91
- </OSProductList>
92
- {hasUpSelling && (
93
- <View style={{ marginVertical: 28, paddingBottom: 36, borderBottomWidth: 8, borderBottomColor: theme.colors.inputDisabled }}>
94
- <UpsellingProducts
95
- businessId={cart?.business_id}
96
- business={cart?.business}
97
- cartProducts={cart?.products}
98
- handleUpsellingPage={() => { }}
99
- openUpselling={true}
100
- canOpenUpselling={true}
101
- isCustomMode
102
- scrollContainerStyle={{ paddingHorizontal: paddingH }}
103
- />
104
- </View>
105
- )}
106
- {cart?.valid && (
107
- <OSBill style={{ paddingHorizontal: paddingH }}>
108
- {!isMini ? (
109
- <View>
110
- {cart?.total >= 1 && (
111
- <View style={{ borderBottomWidth: 1, borderBottomColor: theme.colors.border, paddingBottom: 12, marginBottom: 4 }}>
112
- <OSTable>
113
- <OText style={theme.labels.middle as TextStyle}>
114
- {t('TOTAL', 'Total')}
115
- </OText>
116
- <OText style={theme.labels.middle as TextStyle}>
117
- {parsePrice(cart?.total)}
118
- </OText>
119
- </OSTable>
120
- </View>
121
- )}
122
- {isCouponEnabled && !isCartPending && (
123
- <View style={{ paddingVertical: 5, marginBottom: 7 }}>
124
- <CouponControl
125
- businessId={cart.business_id}
126
- price={cart.total}
127
- />
128
- </View>
129
- )}
130
- </View>
131
- ) : null}
132
- <OSTable>
133
- <OText style={theme.labels.normal as TextStyle}>{t('SUBTOTAL', 'Subtotal')}</OText>
134
- <OText style={theme.labels.normal as TextStyle}>{cart.business.tax_type === 1
135
- ? parsePrice((cart?.subtotal + cart?.tax) || 0)
136
- : parsePrice(cart?.subtotal || 0)}</OText>
137
- </OSTable>
138
- {cart?.discount > 0 && cart?.total >= 0 && (
139
- <OSTable>
140
- {cart?.discount_type === 1 ? (
141
- <OText style={theme.labels.normal as TextStyle}>
142
- {t('DISCOUNT', 'Discount')}
143
- <OText style={theme.labels.normal as TextStyle}>{`(${verifyDecimals(cart?.discount_rate, parsePrice)}%)`}</OText>
144
- </OText>
145
- ) : (
146
- <OText style={theme.labels.normal as TextStyle}>{t('DISCOUNT', 'Discount')}</OText>
147
- )}
148
- <OText style={theme.labels.normal as TextStyle}>- {parsePrice(cart?.discount || 0)}</OText>
149
- </OSTable>
150
- )}
151
- {cart.business.tax_type !== 1 && (
152
- <OSTable>
153
- <OText style={theme.labels.normal as TextStyle}>
154
- {t('TAX', 'Tax')}
155
- {`(${verifyDecimals(cart?.business?.tax, parseNumber)}%)`}
156
- </OText>
157
- <OText style={theme.labels.normal as TextStyle}>{parsePrice(cart?.tax || 0)}</OText>
158
- </OSTable>
159
- )}
160
- {orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
161
- <OSTable>
162
- <OText style={theme.labels.normal as TextStyle}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
163
- <OText style={theme.labels.normal as TextStyle}>{parsePrice(cart?.delivery_price)}</OText>
164
- </OSTable>
165
- )}
166
- {cart?.driver_tip > 0 && (
167
- <OSTable>
168
- <OText style={theme.labels.normal as TextStyle}>
169
- {t('DRIVER_TIP', 'Driver tip')}
170
- {cart?.driver_tip_rate > 0 &&
171
- parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
172
- !parseInt(configs?.driver_tip_use_custom?.value, 10) &&
173
- (
174
- `(${verifyDecimals(cart?.driver_tip_rate, parseNumber)}%)`
175
- )}
176
- </OText>
177
- <OText style={theme.labels.normal as TextStyle}>{parsePrice(cart?.driver_tip)}</OText>
178
- </OSTable>
179
- )}
180
- {cart?.service_fee > 0 && (
181
- <OSTable>
182
- <OText style={theme.labels.normal as TextStyle}>
183
- {t('SERVICE_FEE', 'Service Fee')}
184
- {`(${verifyDecimals(cart?.business?.service_fee, parseNumber)}%)`}
185
- </OText>
186
- <OText style={theme.labels.normal as TextStyle}>{parsePrice(cart?.service_fee)}</OText>
187
- </OSTable>
188
- )}
73
+ const getIncludedTaxes = () => {
74
+ if (cart?.taxes === null) {
75
+ return cart.business.tax_type === 1 ? cart?.tax : 0
76
+ } else {
77
+ return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
78
+ return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
79
+ }, 0)
80
+ }
81
+ }
189
82
 
190
- {isMini ? (
191
- <View style={{ marginTop: 10 }}>
192
- {cart?.total >= 1 && (
193
- <View style={{ borderTopWidth: 1, borderTopColor: theme.colors.border, paddingTop: 12, marginBottom: 4 }}>
194
- <OSTable>
195
- <OText style={theme.labels.middle as TextStyle}>
196
- {t('TOTAL', 'Total')}
197
- </OText>
198
- <OText style={theme.labels.middle as TextStyle}>
199
- {parsePrice(cart?.total)}
200
- </OText>
201
- </OSTable>
202
- </View>
203
- )}
204
- {isCouponEnabled && !isCartPending && (
205
- <View style={{ paddingVertical: 5, marginBottom: 7 }}>
206
- <CouponControl
207
- businessId={cart.business_id}
208
- price={cart.total}
209
- />
210
- </View>
211
- )}
212
- </View>
213
- ) : null}
83
+ return (
84
+ <OSContainer>
85
+ {cart?.products?.length > 0 && (
86
+ <>
87
+ <OSProductList style={{ paddingHorizontal: paddingH }}>
88
+ {title && <OText style={{ ...theme.labels.middle, marginVertical: 12 } as TextStyle}>{title}</OText>}
89
+ {cart?.products.map((product: any) => (
90
+ <ProductItemAccordion
91
+ key={product.code}
92
+ product={product}
93
+ isCartPending={isCartPending}
94
+ isCartProduct
95
+ changeQuantity={changeQuantity}
96
+ getProductMax={getProductMax}
97
+ offsetDisabled={offsetDisabled}
98
+ onDeleteProduct={handleDeleteClick}
99
+ onEditProduct={handleEditProduct}
100
+ isFromCheckout={isFromCheckout}
101
+ isMini={isMini}
102
+ />
103
+ ))}
104
+ </OSProductList>
105
+ {hasUpSelling && (
106
+ <View style={{ marginVertical: 28, paddingBottom: 36, borderBottomWidth: 8, borderBottomColor: theme.colors.inputDisabled }}>
107
+ <UpsellingProducts
108
+ businessId={cart?.business_id}
109
+ business={cart?.business}
110
+ cartProducts={cart?.products}
111
+ handleUpsellingPage={() => { }}
112
+ openUpselling={true}
113
+ canOpenUpselling={true}
114
+ isCustomMode
115
+ scrollContainerStyle={{ paddingHorizontal: paddingH }}
116
+ />
117
+ </View>
118
+ )}
119
+ {cart?.valid && (
120
+ <OSBill style={{ paddingHorizontal: paddingH }}>
121
+ {!isMini ? (
122
+ <View>
123
+ {cart?.total >= 1 && (
124
+ <View style={{ borderBottomWidth: 1, borderBottomColor: theme.colors.border, paddingBottom: 12, marginBottom: 4 }}>
125
+ <OSTable>
126
+ <OText style={theme.labels.middle as TextStyle}>
127
+ {t('TOTAL', 'Total')}
128
+ </OText>
129
+ <OText style={theme.labels.middle as TextStyle}>
130
+ {parsePrice(cart?.total)}
131
+ </OText>
132
+ </OSTable>
133
+ </View>
134
+ )}
135
+ {isCouponEnabled && !isCartPending && (
136
+ <View style={{ paddingVertical: 5, marginBottom: 7 }}>
137
+ <CouponControl
138
+ businessId={cart.business_id}
139
+ price={cart.total}
140
+ />
141
+ </View>
142
+ )}
143
+ </View>
144
+ ) : null}
145
+ <OSTable>
146
+ <OText style={theme.labels.normal as TextStyle}>{t('SUBTOTAL', 'Subtotal')}</OText>
147
+ <OText style={theme.labels.normal as TextStyle}>{parsePrice(cart?.subtotal + getIncludedTaxes())}</OText>
148
+ </OSTable>
149
+ {cart?.discount > 0 && cart?.total >= 0 && (
150
+ <OSTable>
151
+ {cart?.discount_type === 1 ? (
152
+ <OText style={theme.labels.normal as TextStyle}>
153
+ {t('DISCOUNT', 'Discount')}
154
+ <OText style={theme.labels.normal as TextStyle}>{`(${verifyDecimals(cart?.discount_rate, parsePrice)}%)`}</OText>
155
+ </OText>
156
+ ) : (
157
+ <OText style={theme.labels.normal as TextStyle}>{t('DISCOUNT', 'Discount')}</OText>
158
+ )}
159
+ <OText style={theme.labels.normal as TextStyle}>- {parsePrice(cart?.discount || 0)}</OText>
160
+ </OSTable>
161
+ )}
162
+ {
163
+ cart?.taxes?.length > 0 && cart?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
164
+ <OSTable key={tax?.id}>
165
+ <OSRow>
166
+ <OText numberOfLines={1}>
167
+ {tax?.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
168
+ {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
169
+ </OText>
170
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
171
+ <AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
172
+ </TouchableOpacity>
173
+ </OSRow>
174
+ <OText>{parsePrice(tax?.summary?.tax || 0)}</OText>
175
+ </OSTable>
176
+ ))
177
+ }
178
+ {
179
+ cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
180
+ <OSTable key={fee.id}>
181
+ <OSRow>
182
+ <OText numberOfLines={1}>
183
+ {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
184
+ ({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
185
+ </OText>
186
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
187
+ <AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
188
+ </TouchableOpacity>
189
+ </OSRow>
190
+ <OText>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
191
+ </OSTable>
192
+ ))
193
+ }
194
+ {orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
195
+ <OSTable>
196
+ <OText style={theme.labels.normal as TextStyle}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
197
+ <OText style={theme.labels.normal as TextStyle}>{parsePrice(cart?.delivery_price)}</OText>
198
+ </OSTable>
199
+ )}
200
+ {cart?.driver_tip > 0 && (
201
+ <OSTable>
202
+ <OText style={theme.labels.normal as TextStyle}>
203
+ {t('DRIVER_TIP', 'Driver tip')}
204
+ {cart?.driver_tip_rate > 0 &&
205
+ parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
206
+ !parseInt(configs?.driver_tip_use_custom?.value, 10) &&
207
+ (
208
+ `(${verifyDecimals(cart?.driver_tip_rate, parseNumber)}%)`
209
+ )}
210
+ </OText>
211
+ <OText style={theme.labels.normal as TextStyle}>{parsePrice(cart?.driver_tip)}</OText>
212
+ </OSTable>
213
+ )}
214
+ {isMini ? (
215
+ <View style={{ marginTop: 10 }}>
216
+ {cart?.total >= 1 && (
217
+ <View style={{ borderTopWidth: 1, borderTopColor: theme.colors.border, paddingTop: 12, marginBottom: 4 }}>
218
+ <OSTable>
219
+ <OText style={theme.labels.middle as TextStyle}>
220
+ {t('TOTAL', 'Total')}
221
+ </OText>
222
+ <OText style={theme.labels.middle as TextStyle}>
223
+ {parsePrice(cart?.total)}
224
+ </OText>
225
+ </OSTable>
226
+ </View>
227
+ )}
228
+ {isCouponEnabled && !isCartPending && (
229
+ <View style={{ paddingVertical: 5, marginBottom: 7 }}>
230
+ <CouponControl
231
+ businessId={cart.business_id}
232
+ price={cart.total}
233
+ />
234
+ </View>
235
+ )}
236
+ </View>
237
+ ) : null}
214
238
 
215
- </OSBill>
216
- )}
217
- <OModal
218
- open={openProduct}
219
- entireModal
220
- customClose
221
- onClose={() => setModalIsOpen(false)}
222
- overScreen
223
- >
224
- <ProductForm
225
- isCartProduct
226
- productCart={curProduct}
227
- businessSlug={cart?.business?.slug}
228
- businessId={cart?.business_id}
229
- categoryId={curProduct?.category_id}
230
- productId={curProduct?.id}
231
- onSave={handlerProductAction}
232
- onClose={() => setModalIsOpen(false)}
233
- isFromCheckout={isFromCheckout}
234
- />
235
- </OModal>
236
- </>
237
- )}
238
- </OSContainer>
239
- )
239
+ </OSBill>
240
+ )}
241
+ <OModal
242
+ open={openProduct}
243
+ entireModal
244
+ customClose
245
+ onClose={() => setModalIsOpen(false)}
246
+ overScreen
247
+ >
248
+ <ProductForm
249
+ isCartProduct
250
+ productCart={curProduct}
251
+ businessSlug={cart?.business?.slug}
252
+ businessId={cart?.business_id}
253
+ categoryId={curProduct?.category_id}
254
+ productId={curProduct?.id}
255
+ onSave={handlerProductAction}
256
+ onClose={() => setModalIsOpen(false)}
257
+ isFromCheckout={isFromCheckout}
258
+ />
259
+ </OModal>
260
+ <OModal
261
+ open={openTaxModal.open}
262
+ onClose={() => setOpenTaxModal({ open: false, data: null })}
263
+ entireModal
264
+ >
265
+ <TaxInformation data={openTaxModal.data} products={cart.products} />
266
+ </OModal>
267
+ </>
268
+ )}
269
+ </OSContainer>
270
+ )
240
271
  }
241
272
 
242
273
  export const OrderSummary = (props: any) => {
243
- const orderSummaryProps = {
244
- ...props,
245
- UIComponent: OrderSummaryUI
246
- }
274
+ const orderSummaryProps = {
275
+ ...props,
276
+ UIComponent: OrderSummaryUI
277
+ }
247
278
 
248
- return (
249
- <Cart {...orderSummaryProps} />
250
- )
279
+ return (
280
+ <Cart {...orderSummaryProps} />
281
+ )
251
282
  }
@@ -30,3 +30,9 @@ export const OSCoupon = styled.View`
30
30
  width: 100%;
31
31
  padding: 5px 0px;
32
32
  `
33
+
34
+ export const OSRow = styled.View`
35
+ flex-direction: row;
36
+ overflow: hidden;
37
+ width: 80%;
38
+ `
@@ -73,7 +73,7 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
73
73
 
74
74
  return (
75
75
  <CardContainer style={styles.container}
76
- onPress={() => onProductClick(product)}
76
+ onPress={() => onProductClick?.(product)}
77
77
  activeOpacity={0.8}
78
78
  >
79
79
  <CardInfo>
@@ -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
+ `