ordering-ui-react-native 0.14.39 → 0.14.42
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.
- package/package.json +1 -1
- package/src/components/BusinessItemAccordion/index.tsx +2 -2
- package/src/components/Cart/index.tsx +135 -42
- package/src/components/Cart/styles.tsx +7 -0
- package/src/components/Checkout/index.tsx +5 -3
- package/src/components/OrderDetails/index.tsx +102 -34
- package/src/components/OrderDetails/styles.tsx +7 -0
- package/src/components/OrderSummary/index.tsx +140 -37
- package/src/components/OrderSummary/styles.tsx +10 -2
- package/src/components/ProductForm/index.tsx +5 -5
- package/src/components/SingleProductCard/index.tsx +1 -1
- package/src/components/TaxInformation/index.tsx +58 -26
- package/src/navigators/HomeNavigator.tsx +6 -0
- package/src/pages/ProductDetails.tsx +55 -0
- package/themes/original/src/components/Checkout/index.tsx +1 -0
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +6 -2
- package/themes/original/src/components/ProductForm/index.tsx +25 -28
|
@@ -14,12 +14,13 @@ import {
|
|
|
14
14
|
OSProductList,
|
|
15
15
|
OSBill,
|
|
16
16
|
OSTable,
|
|
17
|
-
OSRow
|
|
17
|
+
OSRow,
|
|
18
|
+
Divider
|
|
18
19
|
} from './styles';
|
|
19
20
|
|
|
20
21
|
import { ProductItemAccordion } from '../ProductItemAccordion';
|
|
21
22
|
import { CouponControl } from '../CouponControl';
|
|
22
|
-
import { OInput, OModal, OText } from '../shared';
|
|
23
|
+
import { OAlert, OInput, OModal, OText } from '../shared';
|
|
23
24
|
import { verifyDecimals } from '../../utils';
|
|
24
25
|
import { useTheme } from 'styled-components/native';
|
|
25
26
|
import { TaxInformation } from '../TaxInformation';
|
|
@@ -36,7 +37,8 @@ const OrderSummaryUI = (props: any) => {
|
|
|
36
37
|
isFromCheckout,
|
|
37
38
|
commentState,
|
|
38
39
|
handleChangeComment,
|
|
39
|
-
onNavigationRedirect
|
|
40
|
+
onNavigationRedirect,
|
|
41
|
+
handleRemoveOfferClick
|
|
40
42
|
} = props;
|
|
41
43
|
|
|
42
44
|
const theme = useTheme();
|
|
@@ -46,6 +48,7 @@ const OrderSummaryUI = (props: any) => {
|
|
|
46
48
|
const [{ parsePrice, parseNumber }] = useUtils();
|
|
47
49
|
const [validationFields] = useValidationFields();
|
|
48
50
|
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
51
|
+
const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
|
|
49
52
|
|
|
50
53
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
|
|
51
54
|
|
|
@@ -55,15 +58,15 @@ const OrderSummaryUI = (props: any) => {
|
|
|
55
58
|
|
|
56
59
|
const handleEditProduct = (product: any) => {
|
|
57
60
|
onNavigationRedirect &&
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
onNavigationRedirect('ProductDetails', {
|
|
62
|
+
isCartProduct: true,
|
|
63
|
+
productCart: product,
|
|
64
|
+
businessSlug: cart?.business?.slug,
|
|
65
|
+
businessId: cart?.business_id,
|
|
66
|
+
categoryId: product?.category_id,
|
|
67
|
+
productId: product?.id,
|
|
68
|
+
isFromCheckout: isFromCheckout,
|
|
69
|
+
})
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
const getIncludedTaxes = () => {
|
|
@@ -76,6 +79,22 @@ const OrderSummaryUI = (props: any) => {
|
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
|
|
82
|
+
const getIncludedTaxesDiscounts = () => {
|
|
83
|
+
return cart?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const onRemoveOffer = (id: number) => {
|
|
87
|
+
setConfirm({
|
|
88
|
+
open: true,
|
|
89
|
+
content: [t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')],
|
|
90
|
+
title: t('OFFER', 'Offer'),
|
|
91
|
+
handleOnAccept: () => {
|
|
92
|
+
setConfirm({ ...confirm, open: false })
|
|
93
|
+
handleRemoveOfferClick(id)
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
|
|
79
98
|
return (
|
|
80
99
|
<OSContainer>
|
|
81
100
|
{cart?.products?.length > 0 && (
|
|
@@ -99,35 +118,65 @@ const OrderSummaryUI = (props: any) => {
|
|
|
99
118
|
{cart?.valid && (
|
|
100
119
|
<OSBill>
|
|
101
120
|
<OSTable>
|
|
102
|
-
<OText size={
|
|
103
|
-
<OText size={
|
|
121
|
+
<OText size={16}>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
122
|
+
<OText size={16}>{parsePrice(cart?.subtotal + getIncludedTaxes())}</OText>
|
|
104
123
|
</OSTable>
|
|
105
|
-
{cart?.discount > 0 && cart?.total >= 0 && (
|
|
124
|
+
{cart?.discount > 0 && cart?.total >= 0 && cart?.offers?.length === 0 && (
|
|
106
125
|
<OSTable>
|
|
107
126
|
{cart?.discount_type === 1 ? (
|
|
108
|
-
<OText size={
|
|
109
|
-
{t('DISCOUNT', 'Discount')}
|
|
110
|
-
<OText size={
|
|
127
|
+
<OText size={16}>
|
|
128
|
+
{t('DISCOUNT', 'Discount')}{' '}
|
|
129
|
+
<OText size={16}>{`(${verifyDecimals(cart?.discount_rate, parsePrice)}%)`}</OText>
|
|
111
130
|
</OText>
|
|
112
131
|
) : (
|
|
113
|
-
<OText size={
|
|
132
|
+
<OText size={16}>{t('DISCOUNT', 'Discount')}</OText>
|
|
133
|
+
)}
|
|
134
|
+
<OText size={16}>- {parsePrice(cart?.discount || 0)}</OText>
|
|
135
|
+
</OSTable>
|
|
136
|
+
)}
|
|
137
|
+
{
|
|
138
|
+
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
|
|
139
|
+
<OSTable key={offer.id}>
|
|
140
|
+
<OSRow>
|
|
141
|
+
<OText size={16}>{offer.name}</OText>
|
|
142
|
+
{offer.rate_type === 1 && (
|
|
143
|
+
<OText size={16}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
144
|
+
)}
|
|
145
|
+
<TouchableOpacity style={{ marginLeft: 5, top: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
|
|
146
|
+
<AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
|
|
147
|
+
</TouchableOpacity>
|
|
148
|
+
<TouchableOpacity style={{ marginLeft: 5, top: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
|
|
149
|
+
<AntIcon name='closecircle' size={20} color={theme.colors.primary} />
|
|
150
|
+
</TouchableOpacity>
|
|
151
|
+
</OSRow>
|
|
152
|
+
<OText size={16} numberOfLines={2}>- {parsePrice(offer?.summary?.discount)}</OText>
|
|
153
|
+
</OSTable>
|
|
154
|
+
))
|
|
155
|
+
}
|
|
156
|
+
<Divider />
|
|
157
|
+
{cart?.subtotal_with_discount > 0 && cart?.discount > 0 && cart?.total >= 0 && (
|
|
158
|
+
<OSTable>
|
|
159
|
+
<OText size={16} numberOfLines={1}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
|
|
160
|
+
{cart?.business?.tax_type === 1 ? (
|
|
161
|
+
<OText size={16}>{parsePrice(cart?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0)}</OText>
|
|
162
|
+
) : (
|
|
163
|
+
<OText size={16}>{parsePrice(cart?.subtotal_with_discount ?? 0)}</OText>
|
|
114
164
|
)}
|
|
115
|
-
<OText size={18}>- {parsePrice(cart?.discount || 0)}</OText>
|
|
116
165
|
</OSTable>
|
|
117
166
|
)}
|
|
118
167
|
{
|
|
119
168
|
cart?.taxes?.length > 0 && cart?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
120
169
|
<OSTable key={tax?.id}>
|
|
121
170
|
<OSRow>
|
|
122
|
-
<OText size={
|
|
171
|
+
<OText size={16} numberOfLines={1}>
|
|
123
172
|
{tax?.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
124
173
|
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
125
174
|
</OText>
|
|
126
|
-
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
|
|
175
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax, type: 'tax' })} >
|
|
127
176
|
<AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
|
|
128
177
|
</TouchableOpacity>
|
|
129
178
|
</OSRow>
|
|
130
|
-
<OText size={
|
|
179
|
+
<OText size={16}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
|
|
131
180
|
</OSTable>
|
|
132
181
|
))
|
|
133
182
|
}
|
|
@@ -135,27 +184,69 @@ const OrderSummaryUI = (props: any) => {
|
|
|
135
184
|
cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
|
|
136
185
|
<OSTable key={fee.id}>
|
|
137
186
|
<OSRow>
|
|
138
|
-
<OText size={
|
|
187
|
+
<OText size={16} numberOfLines={1}>
|
|
139
188
|
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
140
189
|
({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
|
|
141
190
|
</OText>
|
|
142
|
-
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
|
|
191
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
|
|
192
|
+
<AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
|
|
193
|
+
</TouchableOpacity>
|
|
194
|
+
</OSRow>
|
|
195
|
+
<OText size={16}>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
|
|
196
|
+
</OSTable>
|
|
197
|
+
))
|
|
198
|
+
}
|
|
199
|
+
{
|
|
200
|
+
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
|
|
201
|
+
<OSTable key={offer.id}>
|
|
202
|
+
<OSRow>
|
|
203
|
+
<OText size={16}>{offer.name}</OText>
|
|
204
|
+
{offer.rate_type === 1 && (
|
|
205
|
+
<OText size={16}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
206
|
+
)}
|
|
207
|
+
<TouchableOpacity style={{ marginLeft: 5, top: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
|
|
143
208
|
<AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
|
|
144
209
|
</TouchableOpacity>
|
|
210
|
+
<TouchableOpacity style={{ marginLeft: 5, top: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
|
|
211
|
+
<AntIcon name='closecircle' size={20} color={theme.colors.primary} />
|
|
212
|
+
</TouchableOpacity>
|
|
145
213
|
</OSRow>
|
|
146
|
-
<OText size={
|
|
214
|
+
<OText size={16}>
|
|
215
|
+
- {parsePrice(offer?.summary?.discount)}
|
|
216
|
+
</OText>
|
|
147
217
|
</OSTable>
|
|
148
218
|
))
|
|
149
219
|
}
|
|
150
220
|
{orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
|
|
151
221
|
<OSTable>
|
|
152
|
-
<OText size={
|
|
153
|
-
<OText size={
|
|
222
|
+
<OText size={16}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
|
|
223
|
+
<OText size={16}>{parsePrice(cart?.delivery_price)}</OText>
|
|
154
224
|
</OSTable>
|
|
155
225
|
)}
|
|
226
|
+
{
|
|
227
|
+
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
|
|
228
|
+
<OSTable key={offer.id}>
|
|
229
|
+
<OSRow>
|
|
230
|
+
<OText size={16}>{offer.name}</OText>
|
|
231
|
+
{offer.rate_type === 1 && (
|
|
232
|
+
<OText size={16}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
233
|
+
)}
|
|
234
|
+
<TouchableOpacity style={{ marginLeft: 3, top: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
|
|
235
|
+
<AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
|
|
236
|
+
</TouchableOpacity>
|
|
237
|
+
<TouchableOpacity style={{ marginLeft: 3, top: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
|
|
238
|
+
<AntIcon name='closecircle' size={20} color={theme.colors.primary} />
|
|
239
|
+
</TouchableOpacity>
|
|
240
|
+
</OSRow>
|
|
241
|
+
<OText size={16}>
|
|
242
|
+
- {parsePrice(offer?.summary?.discount)}
|
|
243
|
+
</OText>
|
|
244
|
+
</OSTable>
|
|
245
|
+
))
|
|
246
|
+
}
|
|
156
247
|
{cart?.driver_tip > 0 && (
|
|
157
248
|
<OSTable>
|
|
158
|
-
<OText size={
|
|
249
|
+
<OText size={16}>
|
|
159
250
|
{t('DRIVER_TIP', 'Driver tip')}
|
|
160
251
|
{cart?.driver_tip_rate > 0 &&
|
|
161
252
|
parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
|
|
@@ -164,7 +255,7 @@ const OrderSummaryUI = (props: any) => {
|
|
|
164
255
|
`(${verifyDecimals(cart?.driver_tip_rate, parseNumber)}%)`
|
|
165
256
|
)}
|
|
166
257
|
</OText>
|
|
167
|
-
<OText size={
|
|
258
|
+
<OText size={16}>{parsePrice(cart?.driver_tip)}</OText>
|
|
168
259
|
</OSTable>
|
|
169
260
|
)}
|
|
170
261
|
{isCouponEnabled && !isCartPending && (
|
|
@@ -177,22 +268,20 @@ const OrderSummaryUI = (props: any) => {
|
|
|
177
268
|
</View>
|
|
178
269
|
</View>
|
|
179
270
|
)}
|
|
180
|
-
{cart?.total >= 1 && (
|
|
181
271
|
<View style={{ marginTop: 15, borderTopWidth: 1, borderTopColor: '#d9d9d9' }}>
|
|
182
272
|
<OSTable style={{ marginTop: 15 }}>
|
|
183
|
-
<OText size={
|
|
273
|
+
<OText size={16} style={{ fontWeight: 'bold' }}>
|
|
184
274
|
{t('TOTAL', 'Total')}
|
|
185
275
|
</OText>
|
|
186
|
-
<OText size={
|
|
187
|
-
{parsePrice(cart?.total)}
|
|
276
|
+
<OText size={16} style={{ fontWeight: 'bold' }} color={theme.colors.primary}>
|
|
277
|
+
{parsePrice(cart?.total >= 0 ? cart?.total : 0)}
|
|
188
278
|
</OText>
|
|
189
279
|
</OSTable>
|
|
190
280
|
</View>
|
|
191
|
-
)}
|
|
192
281
|
{cart?.status !== 2 && (
|
|
193
282
|
<OSTable>
|
|
194
283
|
<View style={{ width: '100%', marginTop: 20 }}>
|
|
195
|
-
<OText>{t('COMMENTS', 'Comments')}</OText>
|
|
284
|
+
<OText size={16}>{t('COMMENTS', 'Comments')}</OText>
|
|
196
285
|
<View style={{ flex: 1, width: '100%' }}>
|
|
197
286
|
<OInput
|
|
198
287
|
value={cart?.comment}
|
|
@@ -227,9 +316,23 @@ const OrderSummaryUI = (props: any) => {
|
|
|
227
316
|
open={openTaxModal.open}
|
|
228
317
|
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
229
318
|
entireModal
|
|
319
|
+
title={`${openTaxModal.data?.name ||
|
|
320
|
+
t('INHERIT_FROM_BUSINESS', 'Inherit from business')} ${openTaxModal.data?.rate_type !== 2 ? `(${typeof openTaxModal.data?.rate === 'number' ? `${openTaxModal.data?.rate}%` : `${parsePrice(openTaxModal.data?.fixed ?? 0)} + ${openTaxModal.data?.percentage}%`})` : ''} `}
|
|
230
321
|
>
|
|
231
|
-
<TaxInformation
|
|
322
|
+
<TaxInformation
|
|
323
|
+
type={openTaxModal.type}
|
|
324
|
+
data={openTaxModal.data}
|
|
325
|
+
products={cart?.products}
|
|
326
|
+
/>
|
|
232
327
|
</OModal>
|
|
328
|
+
<OAlert
|
|
329
|
+
open={confirm.open}
|
|
330
|
+
title={confirm.title}
|
|
331
|
+
content={confirm.content}
|
|
332
|
+
onAccept={confirm.handleOnAccept}
|
|
333
|
+
onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
|
|
334
|
+
onClose={() => setConfirm({ ...confirm, open: false, title: null })}
|
|
335
|
+
/>
|
|
233
336
|
</>
|
|
234
337
|
)}
|
|
235
338
|
</OSContainer>
|
|
@@ -33,5 +33,13 @@ export const OSCoupon = styled.View`
|
|
|
33
33
|
export const OSRow = styled.View`
|
|
34
34
|
flex-direction: row;
|
|
35
35
|
overflow: hidden;
|
|
36
|
-
width:
|
|
37
|
-
|
|
36
|
+
width: 70%;
|
|
37
|
+
flex-wrap: wrap;
|
|
38
|
+
`
|
|
39
|
+
|
|
40
|
+
export const Divider = styled.View`
|
|
41
|
+
border-color: #EAEAEA;
|
|
42
|
+
border-width: 1px;
|
|
43
|
+
margin-top: 5px;
|
|
44
|
+
margin-bottom: 10px;
|
|
45
|
+
`
|
|
@@ -132,26 +132,26 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
132
132
|
<View style={{ flexDirection: 'column', width: '100%' }}>
|
|
133
133
|
<View style={{ flexDirection: 'row', marginTop: 15 }}>
|
|
134
134
|
<OText size={20} style={{ flex: I18nManager.isRTL ? 0 : 1, marginBottom: 10 }}>{product?.name || productCart.name}{' '}</OText>
|
|
135
|
-
{product?.calories && (
|
|
135
|
+
{!!product?.calories && (
|
|
136
136
|
<OText size={16} style={styles.caloriesStyle}>{product?.calories} cal</OText>
|
|
137
137
|
)}
|
|
138
138
|
</View>
|
|
139
139
|
<View style={{ flexDirection: 'row', marginBottom: 10 }}>
|
|
140
140
|
<OText size={16} style={{ flex: I18nManager.isRTL ? 1 : 0 }} color={theme.colors.primary}>{productCart.price ? parsePrice(productCart.price) : ''}</OText>
|
|
141
|
-
{product?.offer_price && (
|
|
141
|
+
{!!product?.offer_price && (
|
|
142
142
|
<OText style={styles.regularPriceStyle}>{parsePrice(product?.offer_price)}</OText>
|
|
143
143
|
)}
|
|
144
144
|
</View>
|
|
145
|
-
{(product?.estimated_person || (product?.sku && product?.sku !== '-1' && product?.sku !== '1')) && (
|
|
145
|
+
{(!!product?.estimated_person || (!!product?.sku && product?.sku !== '-1' && product?.sku !== '1')) && (
|
|
146
146
|
<OText size={14} style={{ flex: I18nManager.isRTL ? 1 : 0, marginBottom: 10 }} color={'#909BA9'}>
|
|
147
147
|
{
|
|
148
148
|
((product?.sku && product?.sku !== '-1' && product?.sku !== '1') || (productCart?.sku && productCart?.sku !== '-1' && productCart?.sku !== '1'))
|
|
149
149
|
&& <>{t('SKU', 'Sku')}{' '}{product?.sku || productCart?.sku}</>
|
|
150
150
|
}
|
|
151
|
-
{product?.sku && product?.sku !== '-1' && product?.sku !== '1' && product?.estimated_person && (
|
|
151
|
+
{!!product?.sku && product?.sku !== '-1' && product?.sku !== '1' && !!product?.estimated_person && (
|
|
152
152
|
<> · </>
|
|
153
153
|
)}
|
|
154
|
-
{product?.estimated_person
|
|
154
|
+
{!!product?.estimated_person
|
|
155
155
|
&& <>{product?.estimated_person}{' '}{t('ESTIMATED_PERSONS', 'persons')}</>
|
|
156
156
|
}
|
|
157
157
|
</OText>
|
|
@@ -86,7 +86,7 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
|
|
|
86
86
|
<OText size={12} numberOfLines={2} ellipsizeMode='tail' style={styles.textStyle}>{product?.description}</OText>
|
|
87
87
|
<PricesContainer>
|
|
88
88
|
<OText color={theme.colors.primary}>{parsePrice(product?.price)}</OText>
|
|
89
|
-
{product?.offer_price && (
|
|
89
|
+
{!!product?.offer_price && (
|
|
90
90
|
<OText style={styles.regularPriceStyle}>{parsePrice(product?.offer_price)}</OText>
|
|
91
91
|
)}
|
|
92
92
|
</PricesContainer>
|
|
@@ -1,51 +1,83 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { useLanguage
|
|
2
|
+
import { useLanguage } from 'ordering-components/native'
|
|
3
3
|
import { SingleProductCard } from '../SingleProductCard'
|
|
4
4
|
import { TaxInformationContainer, ProductContainer } from './styles'
|
|
5
5
|
import { OText } from '../shared'
|
|
6
6
|
|
|
7
7
|
interface taxInformationParams {
|
|
8
|
-
data: {
|
|
9
|
-
|
|
8
|
+
data: {
|
|
9
|
+
name: string,
|
|
10
|
+
description?: string,
|
|
11
|
+
rate: string | number,
|
|
12
|
+
type: number,
|
|
13
|
+
fixed?: number,
|
|
14
|
+
percentage?: number,
|
|
15
|
+
id: number,
|
|
16
|
+
discounts?: any
|
|
17
|
+
},
|
|
18
|
+
products: Array<any>,
|
|
19
|
+
type: string
|
|
10
20
|
}
|
|
11
21
|
|
|
12
22
|
export const TaxInformation = (props: taxInformationParams) => {
|
|
13
23
|
const {
|
|
14
24
|
data,
|
|
15
|
-
products
|
|
25
|
+
products,
|
|
26
|
+
type
|
|
16
27
|
} = props
|
|
17
28
|
|
|
18
29
|
const [, t] = useLanguage()
|
|
19
|
-
const [{ parsePrice }] = useUtils()
|
|
20
30
|
|
|
21
|
-
const isTax = typeof data?.rate === 'number'
|
|
22
|
-
const TaxFeeString = isTax ? 'tax' : 'fee'
|
|
23
31
|
const includedOnPriceString = data?.type === 1 ? `(${t('INCLUDED_ON_PRICE', 'Included on price')})` : `(${t('NOT_INCLUDED_ON_PRICE', 'Not included on price')})`
|
|
24
32
|
|
|
33
|
+
const getFilterValidation = (product: any) => {
|
|
34
|
+
return (
|
|
35
|
+
type === 'tax'
|
|
36
|
+
? (product.tax?.id ? product.tax?.id === data?.id : product.tax?.id === null && data?.id === null)
|
|
37
|
+
: type === 'fee'
|
|
38
|
+
? (product.fee?.id ? product.fee?.id === data?.id : (product.fee?.id === null && data?.id === null))
|
|
39
|
+
: Object.keys(data?.discounts ?? {}).map(code => code.includes(product?.code))
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const getTypeString = () => {
|
|
44
|
+
return (
|
|
45
|
+
type === 'offer_target_1'
|
|
46
|
+
? t('PRODUCT_DISCOUNT', 'Product discount')
|
|
47
|
+
: type === 'tax'
|
|
48
|
+
? t('TAX', 'Tax')
|
|
49
|
+
: t('Fee', 'Fee')
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
25
53
|
return (
|
|
26
54
|
<TaxInformationContainer>
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
t('
|
|
30
|
-
|
|
31
|
-
|
|
55
|
+
{!!data?.description ? (
|
|
56
|
+
<OText size={24} style={{ alignSelf: 'center', textAlign: 'center' }} mBottom={10}>
|
|
57
|
+
{t('DESCRIPTION', 'Description')}: {data?.description} {data?.type && !type?.includes('offer') && includedOnPriceString}
|
|
58
|
+
</OText>
|
|
59
|
+
) : (
|
|
32
60
|
<OText mBottom={10} size={18} style={{ alignSelf: 'center', textAlign: 'center' }}>
|
|
33
|
-
{t('
|
|
61
|
+
{t('WITHOUT_DESCRIPTION', 'Without description')}
|
|
34
62
|
</OText>
|
|
35
63
|
)}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
64
|
+
{!(type === 'offer_target_2' || type === 'offer_target_3') && (
|
|
65
|
+
<>
|
|
66
|
+
<OText>{t('OTHER_PRODUCTS_WITH_THIS', 'Other products with this')} {getTypeString()}:</OText>
|
|
67
|
+
<ProductContainer>
|
|
68
|
+
{
|
|
69
|
+
products.filter((product: any) => getFilterValidation(product)).map(product => (
|
|
70
|
+
<SingleProductCard
|
|
71
|
+
key={product.id}
|
|
72
|
+
product={product}
|
|
73
|
+
isSoldOut={false}
|
|
74
|
+
businessId={product?.business_id}
|
|
75
|
+
/>
|
|
76
|
+
))
|
|
77
|
+
}
|
|
78
|
+
</ProductContainer>
|
|
79
|
+
</>
|
|
80
|
+
)}
|
|
49
81
|
</TaxInformationContainer>
|
|
50
82
|
)
|
|
51
83
|
}
|
|
@@ -21,6 +21,7 @@ import HelpOrder from '../pages/HelpOrder'
|
|
|
21
21
|
import HelpGuide from '../pages/HelpGuide'
|
|
22
22
|
import HelpAccountAndPayment from '../pages/HelpAccountAndPayment'
|
|
23
23
|
import Splash from '../pages/Splash';
|
|
24
|
+
import ProductDetails from '../pages/ProductDetails';
|
|
24
25
|
const Stack = createStackNavigator();
|
|
25
26
|
|
|
26
27
|
const HomeNavigator = (e : any) => {
|
|
@@ -101,6 +102,11 @@ const HomeNavigator = (e : any) => {
|
|
|
101
102
|
component={BusinessProductsList}
|
|
102
103
|
options={{ headerShown: false }}
|
|
103
104
|
/>
|
|
105
|
+
<Stack.Screen
|
|
106
|
+
name="ProductDetails"
|
|
107
|
+
component={ProductDetails}
|
|
108
|
+
options={{ headerShown: false }}
|
|
109
|
+
/>
|
|
104
110
|
<Stack.Screen
|
|
105
111
|
name="ReviewOrder"
|
|
106
112
|
component={ReviewOrder}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styled, { useTheme } from 'styled-components/native';
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
import { ProductForm as ProductFormController } from '../components/ProductForm';
|
|
5
|
+
interface Props {
|
|
6
|
+
navigation: any;
|
|
7
|
+
route: any;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const ProductDetails = (props: Props) => {
|
|
11
|
+
const theme = useTheme()
|
|
12
|
+
|
|
13
|
+
const productProps = {
|
|
14
|
+
...props,
|
|
15
|
+
isCartProduct: props.route.params?.isCartProduct,
|
|
16
|
+
isFromCheckout: props.route.params?.isFromCheckout,
|
|
17
|
+
productCart: props.route.params?.productCart,
|
|
18
|
+
product: props.route.params?.product,
|
|
19
|
+
businessSlug: props.route.params?.businessSlug,
|
|
20
|
+
businessId: props.route.params?.businessId,
|
|
21
|
+
categoryId: props.route.params?.categoryId,
|
|
22
|
+
productId: props.route.params?.productId,
|
|
23
|
+
onSave: props?.navigation?.canGoBack()
|
|
24
|
+
? () => { props.route.params?.onAction && props.route.params?.onAction(); props?.navigation?.goBack(); }
|
|
25
|
+
: () => { props.route.params?.onAction && props.route.params?.onAction(); props?.navigation?.navigate('BottomTab') }
|
|
26
|
+
,
|
|
27
|
+
handleGoBack: props?.navigation?.canGoBack()
|
|
28
|
+
? () => {
|
|
29
|
+
props.route.params?.onAction &&
|
|
30
|
+
props.route.params?.onAction();
|
|
31
|
+
props?.navigation?.goBack();
|
|
32
|
+
}
|
|
33
|
+
: (businessSlug: any) => {
|
|
34
|
+
props.route.params?.onAction &&
|
|
35
|
+
props.route.params?.onAction();
|
|
36
|
+
businessSlug
|
|
37
|
+
? props?.navigation.navigate('Business', { store: businessSlug })
|
|
38
|
+
: props?.navigation.navigate('BottomTab')
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const BusinessProductsListView = styled.SafeAreaView`
|
|
43
|
+
flex: 1;
|
|
44
|
+
background-color: ${theme.colors.backgroundPage};
|
|
45
|
+
padding-top: ${Platform.OS === 'ios' ? '0px' : '20px'};
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<BusinessProductsListView>
|
|
50
|
+
<ProductFormController {...productProps} />
|
|
51
|
+
</BusinessProductsListView>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default ProductDetails;
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
PaymentOptionWallet as PaymentOptionWalletController,
|
|
8
8
|
useLanguage,
|
|
9
9
|
useUtils,
|
|
10
|
+
useOrder
|
|
10
11
|
} from 'ordering-components/native'
|
|
11
12
|
|
|
12
13
|
import {
|
|
@@ -18,7 +19,7 @@ import { OText } from '../shared'
|
|
|
18
19
|
|
|
19
20
|
const PaymentOptionWalletUI = (props: any) => {
|
|
20
21
|
const {
|
|
21
|
-
|
|
22
|
+
businessId,
|
|
22
23
|
walletsState,
|
|
23
24
|
selectWallet,
|
|
24
25
|
deletetWalletSelected
|
|
@@ -26,8 +27,11 @@ const PaymentOptionWalletUI = (props: any) => {
|
|
|
26
27
|
|
|
27
28
|
const theme = useTheme()
|
|
28
29
|
const [, t] = useLanguage()
|
|
30
|
+
const [{ carts }] = useOrder()
|
|
29
31
|
const [{ parsePrice }] = useUtils()
|
|
30
32
|
|
|
33
|
+
const cart = carts?.[`businessId:${businessId}`] ?? {}
|
|
34
|
+
|
|
31
35
|
const styles = StyleSheet.create({
|
|
32
36
|
checkBoxStyle: {
|
|
33
37
|
width: 25,
|
|
@@ -68,7 +72,7 @@ const PaymentOptionWalletUI = (props: any) => {
|
|
|
68
72
|
if (!walletsState.loading && walletsState.result?.length) {
|
|
69
73
|
setCheckedState(
|
|
70
74
|
walletsState.result?.map((wallet: any) => {
|
|
71
|
-
return !!cart?.
|
|
75
|
+
return !!cart?.payment_events?.find((w: any) => w.wallet_id === wallet.id)
|
|
72
76
|
})
|
|
73
77
|
)
|
|
74
78
|
}
|