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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.14.39",
3
+ "version": "0.14.42",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -80,9 +80,9 @@ export const BusinessItemAccordion = (props: any) => {
80
80
  </BIContentInfo>
81
81
  </BIInfo>
82
82
 
83
- {!isClosed && !!isProducts && cart?.valid_products && cart?.total > 0 && (
83
+ {!isClosed && !!isProducts && cart?.valid_products && (
84
84
  <BITotal>
85
- <OText color='#000'>{parsePrice(cart?.total)}</OText>
85
+ <OText color='#000'>{parsePrice(cart?.total >= 0 ? cart?.total : 0)}</OText>
86
86
  <OText>{t('CART_TOTAL', 'Total')}</OText>
87
87
  </BITotal>
88
88
  )}
@@ -8,7 +8,7 @@ import {
8
8
  useValidationFields,
9
9
  } from 'ordering-components/native';
10
10
 
11
- import { CContainer, CheckoutAction, } from './styles';
11
+ import { CContainer, CheckoutAction, Divider } from './styles';
12
12
 
13
13
  import { OSBill, OSTable, OSCoupon, OSTotal, OSRow } from '../OrderSummary/styles';
14
14
 
@@ -16,7 +16,7 @@ import { ProductItemAccordion } from '../ProductItemAccordion';
16
16
  import { BusinessItemAccordion } from '../BusinessItemAccordion';
17
17
  import { CouponControl } from '../CouponControl';
18
18
 
19
- import { OButton, OModal, OText, OInput } from '../shared';
19
+ import { OButton, OModal, OText, OInput, OAlert } from '../shared';
20
20
  import { UpsellingProducts } from '../UpsellingProducts';
21
21
  import { verifyDecimals } from '../../utils';
22
22
  import { useTheme } from 'styled-components/native';
@@ -35,7 +35,8 @@ const CartUI = (props: any) => {
35
35
  handleCartOpen,
36
36
  setIsCartsLoading,
37
37
  handleChangeComment,
38
- commentState
38
+ commentState,
39
+ handleRemoveOfferClick
39
40
  } = props
40
41
 
41
42
  const theme = useTheme()
@@ -48,6 +49,7 @@ const CartUI = (props: any) => {
48
49
  const [openUpselling, setOpenUpselling] = useState(false)
49
50
  const [canOpenUpselling, setCanOpenUpselling] = useState(false)
50
51
  const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
52
+ const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
51
53
 
52
54
  const isCartPending = cart?.status === 2
53
55
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
@@ -62,14 +64,14 @@ const CartUI = (props: any) => {
62
64
 
63
65
  const handleEditProduct = (product: any) => {
64
66
  props?.onNavigationRedirect &&
65
- props?.onNavigationRedirect('ProductDetails', {
66
- businessId: cart?.business_id,
67
- isCartProduct: true,
68
- productCart: product,
69
- businessSlug: cart?.business?.slug,
70
- categoryId: product?.category_id,
71
- productId: product?.id,
72
- })
67
+ props?.onNavigationRedirect('ProductDetails', {
68
+ businessId: cart?.business_id,
69
+ isCartProduct: true,
70
+ productCart: product,
71
+ businessSlug: cart?.business?.slug,
72
+ categoryId: product?.category_id,
73
+ productId: product?.id,
74
+ })
73
75
  }
74
76
 
75
77
  const handleClearProducts = async () => {
@@ -104,6 +106,22 @@ const CartUI = (props: any) => {
104
106
  }
105
107
  }
106
108
 
109
+ const getIncludedTaxesDiscounts = () => {
110
+ return cart?.taxes?.filter((tax : any) => tax?.type === 1)?.reduce((carry : number, tax : any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
111
+ }
112
+
113
+ const onRemoveOffer = (id: number) => {
114
+ setConfirm({
115
+ open: true,
116
+ content: [t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')],
117
+ title: t('OFFER', 'Offer'),
118
+ handleOnAccept: () => {
119
+ setConfirm({ ...confirm, open: false })
120
+ handleRemoveOfferClick(id)
121
+ }
122
+ })
123
+ }
124
+
107
125
  return (
108
126
  <CContainer>
109
127
  <BusinessItemAccordion
@@ -135,11 +153,11 @@ const CartUI = (props: any) => {
135
153
  {parsePrice(cart?.subtotal + getIncludedTaxes())}
136
154
  </OText>
137
155
  </OSTable>
138
- {cart?.discount > 0 && cart?.total >= 0 && (
156
+ {cart?.discount > 0 && cart?.total >= 0 && cart?.offers?.length === 0 && (
139
157
  <OSTable>
140
158
  {cart?.discount_type === 1 ? (
141
159
  <OText>
142
- {t('DISCOUNT', 'Discount')}
160
+ {t('DISCOUNT', 'Discount')}{' '}
143
161
  <OText>{`(${verifyDecimals(cart?.discount_rate, parsePrice)}%)`}</OText>
144
162
  </OText>
145
163
  ) : (
@@ -148,18 +166,35 @@ const CartUI = (props: any) => {
148
166
  <OText>- {parsePrice(cart?.discount || 0)}</OText>
149
167
  </OSTable>
150
168
  )}
169
+ {
170
+ cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
171
+ <OSTable key={offer.id}>
172
+ <OSRow>
173
+ <OText>{offer.name}</OText>
174
+ {offer.rate_type === 1 && (
175
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
176
+ )}
177
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
178
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
179
+ </TouchableOpacity>
180
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
181
+ <AntIcon name='closecircle' size={18} color={theme.colors.primary} />
182
+ </TouchableOpacity>
183
+ </OSRow>
184
+ <OText>
185
+ - {parsePrice(offer?.summary?.discount)}
186
+ </OText>
187
+ </OSTable>
188
+ ))
189
+ }
190
+ <Divider />
151
191
  {cart?.subtotal_with_discount > 0 && cart?.discount > 0 && cart?.total >= 0 && (
152
192
  <OSTable>
153
- {cart?.discount_type === 1 ? (
154
- <>
155
- <OText>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
156
- <OText>{parsePrice(cart?.subtotal_with_discount + cart?.tax || 0)}</OText>
157
- </>
193
+ <OText numberOfLines={1}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
194
+ {cart?.business?.tax_type === 1 ? (
195
+ <OText>{parsePrice(cart?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0)}</OText>
158
196
  ) : (
159
- <>
160
- <OText>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
161
- <OText>{parsePrice(cart?.subtotal_with_discount || 0)}</OText>
162
- </>
197
+ <OText>{parsePrice(cart?.subtotal_with_discount ?? 0)}</OText>
163
198
  )}
164
199
  </OSTable>
165
200
  )}
@@ -171,11 +206,11 @@ const CartUI = (props: any) => {
171
206
  {tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
172
207
  {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
173
208
  </OText>
174
- <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
209
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax, type: 'tax' })} >
175
210
  <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
176
211
  </TouchableOpacity>
177
212
  </OSRow>
178
- <OText>{parsePrice(tax?.summary?.tax || 0)}</OText>
213
+ <OText>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
179
214
  </OSTable>
180
215
  ))
181
216
  }
@@ -187,11 +222,32 @@ const CartUI = (props: any) => {
187
222
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
188
223
  ({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
189
224
  </OText>
190
- <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
225
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
191
226
  <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
192
227
  </TouchableOpacity>
193
228
  </OSRow>
194
- <OText>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
229
+ <OText>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
230
+ </OSTable>
231
+ ))
232
+ }
233
+ {
234
+ cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
235
+ <OSTable key={offer.id}>
236
+ <OSRow>
237
+ <OText>{offer.name}</OText>
238
+ {offer.rate_type === 1 && (
239
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
240
+ )}
241
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
242
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
243
+ </TouchableOpacity>
244
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
245
+ <AntIcon name='closecircle' size={18} color={theme.colors.primary} />
246
+ </TouchableOpacity>
247
+ </OSRow>
248
+ <OText>
249
+ - {parsePrice(offer?.summary?.discount)}
250
+ </OText>
195
251
  </OSTable>
196
252
  ))
197
253
  }
@@ -201,6 +257,27 @@ const CartUI = (props: any) => {
201
257
  <OText>{parsePrice(cart?.delivery_price)}</OText>
202
258
  </OSTable>
203
259
  )}
260
+ {
261
+ cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
262
+ <OSTable key={offer.id}>
263
+ <OSRow>
264
+ <OText>{offer.name}</OText>
265
+ {offer.rate_type === 1 && (
266
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
267
+ )}
268
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
269
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
270
+ </TouchableOpacity>
271
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
272
+ <AntIcon name='closecircle' size={18} color={theme.colors.primary} />
273
+ </TouchableOpacity>
274
+ </OSRow>
275
+ <OText>
276
+ - {parsePrice(offer?.summary?.discount)}
277
+ </OText>
278
+ </OSTable>
279
+ ))
280
+ }
204
281
  {cart?.driver_tip > 0 && (
205
282
  <OSTable>
206
283
  <OText>
@@ -231,7 +308,7 @@ const CartUI = (props: any) => {
231
308
  {t('TOTAL', 'Total')}
232
309
  </OText>
233
310
  <OText style={{ fontWeight: 'bold' }} color={theme.colors.primary}>
234
- {cart?.total >= 1 && parsePrice(cart?.total)}
311
+ {parsePrice(cart?.total >= 0 ? cart?.total : 0)}
235
312
  </OText>
236
313
  </OSTable>
237
314
  </OSTotal>
@@ -291,27 +368,43 @@ const CartUI = (props: any) => {
291
368
  )}
292
369
  </BusinessItemAccordion>
293
370
 
294
- {openUpselling && (
295
- <UpsellingProducts
296
- handleUpsellingPage={handleUpsellingPage}
297
- openUpselling={openUpselling}
298
- businessId={cart?.business_id}
299
- business={cart?.business}
300
- cartProducts={cart?.products}
301
- canOpenUpselling={canOpenUpselling}
302
- setCanOpenUpselling={setCanOpenUpselling}
303
- setOpenUpselling={setOpenUpselling}
304
- onRedirect={props.onNavigationRedirect}
305
- />
306
- )}
371
+ {
372
+ openUpselling && (
373
+ <UpsellingProducts
374
+ handleUpsellingPage={handleUpsellingPage}
375
+ openUpselling={openUpselling}
376
+ businessId={cart?.business_id}
377
+ business={cart?.business}
378
+ cartProducts={cart?.products}
379
+ canOpenUpselling={canOpenUpselling}
380
+ setCanOpenUpselling={setCanOpenUpselling}
381
+ setOpenUpselling={setOpenUpselling}
382
+ onRedirect={props.onNavigationRedirect}
383
+ />
384
+ )
385
+ }
307
386
  <OModal
308
387
  open={openTaxModal.open}
309
388
  onClose={() => setOpenTaxModal({ open: false, data: null })}
310
389
  entireModal
390
+ title={`${openTaxModal.data?.name ||
391
+ 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}%`})` : ''} `}
311
392
  >
312
- <TaxInformation data={openTaxModal.data} products={cart?.products} />
393
+ <TaxInformation
394
+ type={openTaxModal.type}
395
+ data={openTaxModal.data}
396
+ products={cart?.products}
397
+ />
313
398
  </OModal>
314
- </CContainer>
399
+ <OAlert
400
+ open={confirm.open}
401
+ title={confirm.title}
402
+ content={confirm.content}
403
+ onAccept={confirm.handleOnAccept}
404
+ onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
405
+ onClose={() => setConfirm({ ...confirm, open: false, title: null })}
406
+ />
407
+ </CContainer >
315
408
  )
316
409
  }
317
410
 
@@ -26,3 +26,10 @@ export const CheckoutAction = styled.View`
26
26
  margin-top: 10px;
27
27
  margin-bottom: 10px;
28
28
  `
29
+
30
+ export const Divider = styled.View`
31
+ border-color: #EAEAEA;
32
+ border-width: 1px;
33
+ margin-top: 5px;
34
+ margin-bottom: 10px;
35
+ `
@@ -309,9 +309,11 @@ const CheckoutUI = (props: any) => {
309
309
  <OText size={22} numberOfLines={2} ellipsizeMode='tail' >
310
310
  {businessName || businessDetails?.business?.name}
311
311
  </OText>
312
- <OText size={22}>
313
- {cart?.total >= 1 && parsePrice(cart?.total) || cartTotal >= 1 && parsePrice(cartTotal)}
314
- </OText>
312
+ {!cartState.loading && (
313
+ <OText size={22}>
314
+ {parsePrice(cart?.total >= 0 ? cart?.total : 0) || parsePrice(cartTotal >= 0 ? cartTotal : 0)}
315
+ </OText>
316
+ )}
315
317
  </View>
316
318
  </ChTotal>
317
319
  </ChSection>
@@ -38,7 +38,8 @@ import {
38
38
  Icons,
39
39
  OrderDriver,
40
40
  Map,
41
- LoadingWrapper
41
+ LoadingWrapper,
42
+ Divider
42
43
  } from './styles'
43
44
  import { OButton, OIcon, OModal, OText } from '../shared'
44
45
  import { ProductItemAccordion } from '../ProductItemAccordion'
@@ -106,10 +107,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
106
107
  const [unreadAlert, setUnreadAlert] = useState({ business: false, driver: false })
107
108
  const [isReviewed, setIsReviewed] = useState(false)
108
109
  const [openOrderCreating, setOpenOrderCreating] = useState(false)
109
- const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
110
+ const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, tax: null, type: '' })
110
111
  const { order, loading, businessData, error } = props.order
111
- const isTaxIncluded = order?.tax_type === 1
112
-
113
112
 
114
113
  const getOrderStatus = (s: string) => {
115
114
  const status = parseInt(s)
@@ -209,6 +208,10 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
209
208
  }
210
209
  }
211
210
 
211
+ const getIncludedTaxesDiscounts = () => {
212
+ return order?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
213
+ }
214
+
212
215
  useEffect(() => {
213
216
  BackHandler.addEventListener('hardwareBackPress', handleArrowBack);
214
217
  return () => {
@@ -277,7 +280,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
277
280
  <OText size={20} color={theme.colors.white} space>
278
281
  {t('TOTAL', 'Total')}
279
282
  </OText>
280
- <OText size={20} color={theme.colors.white}>{parsePrice(order?.summary?.total || order?.total)}</OText>
283
+ <OText size={20} color={theme.colors.white}>{parsePrice(order?.summary?.total ?? order?.total)}</OText>
281
284
  </View>
282
285
  </HeaderInfo>
283
286
  </Header>
@@ -376,18 +379,18 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
376
379
  <OText style={{ textAlign: 'left' }}>{order?.customer?.address}</OText>
377
380
  </InfoBlock>
378
381
  </Customer>
379
- {order?.delivery_option !== undefined && order?.delivery_type === 1 && (
380
- <View>
381
- <OText size={18} style={{ textAlign: 'left' }}>{t('DELIVERY_PREFERENCE', 'Delivery Preference')}</OText>
382
- <OText style={{ textAlign: 'left' }}>{order?.delivery_option?.name}</OText>
383
- </View>
384
- )}
385
- {order?.comment && (
386
- <View>
387
- <OText size={18} style={{ textAlign: 'left' }} >{t('COMMENT', 'Comment')}</OText>
388
- <OText style={{ textAlign: 'left' }}>{order?.comment}</OText>
389
- </View>
390
- )}
382
+ {order?.delivery_option !== undefined && order?.delivery_type === 1 && (
383
+ <View>
384
+ <OText size={18} style={{ textAlign: 'left' }}>{t('DELIVERY_PREFERENCE', 'Delivery Preference')}</OText>
385
+ <OText style={{ textAlign: 'left' }}>{order?.delivery_option?.name}</OText>
386
+ </View>
387
+ )}
388
+ {order?.comment && (
389
+ <View>
390
+ <OText size={18} style={{ textAlign: 'left' }} >{t('COMMENT', 'Comment')}</OText>
391
+ <OText style={{ textAlign: 'left' }}>{order?.comment}</OText>
392
+ </View>
393
+ )}
391
394
  {order?.driver && (
392
395
  <>
393
396
  {order?.driver?.location && parseInt(order?.status) === 9 && (
@@ -442,26 +445,49 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
442
445
  <Table>
443
446
  <OText>{t('SUBTOTAL', 'Subtotal')}</OText>
444
447
  <OText>
445
- {parsePrice(((order?.summary?.subtotal || order?.subtotal) + getIncludedTaxes()))}
448
+ {parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()))}
446
449
  </OText>
447
450
  </Table>
448
- {order?.summary?.discount > 0 && (
451
+ {(order?.summary?.discount > 0 ?? order?.discount > 0) && order?.offers?.length === 0 && (
449
452
  <Table>
450
453
  {order?.offer_type === 1 ? (
451
454
  <OText>
452
- {t('DISCOUNT', 'Discount')}
453
- <OText>{`(${verifyDecimals(order?.offer_rate, parsePrice)}%)`}</OText>
455
+ {t('DISCOUNT', theme?.defaultLanguages?.DISCOUNT || 'Discount')}{' '}
456
+ <span>{`(${verifyDecimals(order?.offer_rate, parsePrice)}%)`}</span>
454
457
  </OText>
455
458
  ) : (
456
- <OText>{t('DISCOUNT', 'Discount')}</OText>
459
+ <OText>{t('DISCOUNT', theme?.defaultLanguages?.DISCOUNT || 'Discount')}</OText>
457
460
  )}
458
- <OText>- {parsePrice(order?.summary?.discount)}</OText>
461
+ <OText>- {parsePrice(order?.summary?.discount ?? order?.discount)}</OText>
459
462
  </Table>
460
463
  )}
464
+ {
465
+ order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
466
+ <Table key={offer.id}>
467
+ <OSRow>
468
+ <OText numberOfLines={1}>
469
+ {offer.name}
470
+ {offer.rate_type === 1 && (
471
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
472
+ )}
473
+ </OText>
474
+ <TouchableOpacity style={{ marginLeft: 5 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
475
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
476
+ </TouchableOpacity>
477
+ </OSRow>
478
+ <OText>- {parsePrice(offer?.summary?.discount)}</OText>
479
+ </Table>
480
+ ))
481
+ }
482
+ <Divider />
461
483
  {order?.summary?.subtotal_with_discount > 0 && order?.summary?.discount > 0 && order?.summary?.total >= 0 && (
462
484
  <Table>
463
485
  <OText>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
464
- <OText>{parsePrice(order?.summary?.subtotal_with_discount ?? 0)}</OText>
486
+ {order?.tax_type === 1 ? (
487
+ <OText>{parsePrice((order?.summary?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0))}</OText>
488
+ ) : (
489
+ <OText>{parsePrice(order?.summary?.subtotal_with_discount ?? 0)}</OText>
490
+ )}
465
491
  </Table>
466
492
  )}
467
493
  {
@@ -470,7 +496,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
470
496
  <OText>
471
497
  {t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
472
498
  </OText>
473
- <OText>{parsePrice(order?.summary?.tax || 0)}</OText>
499
+ <OText>{parsePrice(order?.summary?.tax ?? 0)}</OText>
474
500
  </Table>
475
501
  )
476
502
  }
@@ -481,7 +507,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
481
507
  {t('SERVICE_FEE', 'Service fee')}
482
508
  {`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
483
509
  </OText>
484
- <OText>{parsePrice(order?.summary?.service_fee || 0)}</OText>
510
+ <OText>{parsePrice(order?.summary?.service_fee ?? 0)}</OText>
485
511
  </Table>
486
512
  )
487
513
  }
@@ -493,11 +519,11 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
493
519
  {tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
494
520
  {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
495
521
  </OText>
496
- <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })}>
522
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax, type: 'tax' })}>
497
523
  <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
498
524
  </TouchableOpacity>
499
525
  </OSRow>
500
- <OText>{parsePrice(tax?.summary?.tax || 0)}</OText>
526
+ <OText>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
501
527
  </Table>
502
528
  ))
503
529
  }
@@ -509,11 +535,29 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
509
535
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
510
536
  ({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
511
537
  </OText>
512
- <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })}>
538
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })}>
539
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
540
+ </TouchableOpacity>
541
+ </OSRow>
542
+ <OText>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
543
+ </Table>
544
+ ))
545
+ }
546
+ {
547
+ order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
548
+ <Table key={offer.id}>
549
+ <OSRow>
550
+ <OText numberOfLines={1}>
551
+ {offer.name}
552
+ {offer.rate_type === 1 && (
553
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
554
+ )}
555
+ </OText>
556
+ <TouchableOpacity style={{ marginLeft: 5 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
513
557
  <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
514
558
  </TouchableOpacity>
515
559
  </OSRow>
516
- <OText>{parsePrice(fee?.fixed + fee?.summary?.percentage || 0)}</OText>
560
+ <OText>- {parsePrice(offer?.summary?.discount)}</OText>
517
561
  </Table>
518
562
  ))
519
563
  }
@@ -523,6 +567,24 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
523
567
  <OText>{parsePrice(order?.summary?.delivery_price)}</OText>
524
568
  </Table>
525
569
  )}
570
+ {
571
+ order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
572
+ <Table key={offer.id}>
573
+ <OSRow>
574
+ <OText numberOfLines={1}>
575
+ {offer.name}
576
+ {offer.rate_type === 1 && (
577
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
578
+ )}
579
+ </OText>
580
+ <TouchableOpacity style={{ marginLeft: 5 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
581
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
582
+ </TouchableOpacity>
583
+ </OSRow>
584
+ <OText>- {parsePrice(offer?.summary?.discount)}</OText>
585
+ </Table>
586
+ ))
587
+ }
526
588
  {order?.summary?.driver_tip > 0 && (
527
589
  <Table>
528
590
  <OText>
@@ -534,14 +596,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
534
596
  `(${verifyDecimals(order?.summary?.driver_tip, parseNumber)}%)`
535
597
  )}
536
598
  </OText>
537
- <OText>{parsePrice(order?.summary?.driver_tip ?? 0)}</OText>
599
+ <OText>{parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip)}</OText>
538
600
  </Table>
539
601
  )}
540
602
  <Total>
541
603
  <Table>
542
604
  <OText style={styles.textBold}>{t('TOTAL', 'Total')}</OText>
543
605
  <OText style={styles.textBold} color={theme.colors.primary}>
544
- {parsePrice(order?.summary?.total ?? 0)}
606
+ {parsePrice(order?.summary?.total ?? order?.total)}
545
607
  </OText>
546
608
  </Table>
547
609
  </Total>
@@ -616,10 +678,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
616
678
  </OModal>
617
679
  <OModal
618
680
  open={openTaxModal.open}
619
- onClose={() => setOpenTaxModal({ open: false, data: null })}
681
+ onClose={() => setOpenTaxModal({ open: false, data: null, type: '' })}
620
682
  entireModal
683
+ title={`${openTaxModal.data?.name ||
684
+ 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}%`})` : ''} `}
621
685
  >
622
- <TaxInformation data={openTaxModal.data} products={order?.products} />
686
+ <TaxInformation
687
+ type={openTaxModal.type}
688
+ data={openTaxModal.data}
689
+ products={order?.products}
690
+ />
623
691
  </OModal>
624
692
  </OrderDetailsContainer>
625
693
  )
@@ -119,3 +119,10 @@ export const LoadingWrapper = styled.View`
119
119
  justify-content: flex-start;
120
120
  align-content: flex-start;
121
121
  `
122
+
123
+ export const Divider = styled.View`
124
+ border-color: #EAEAEA;
125
+ border-width: 1px;
126
+ margin-top: 5px;
127
+ margin-bottom: 5px;
128
+ `