ordering-ui-react-native 0.14.47 → 0.14.48

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.47",
3
+ "version": "0.14.48",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -8,7 +8,7 @@ import {
8
8
  useValidationFields,
9
9
  } from 'ordering-components/native';
10
10
  import { useTheme } from 'styled-components/native';
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
 
@@ -23,6 +23,7 @@ import { ActivityIndicator, TouchableOpacity, View } from 'react-native';
23
23
  import AntIcon from 'react-native-vector-icons/AntDesign'
24
24
  import { TaxInformation } from '../TaxInformation';
25
25
  import { CartStoresListing } from '../CartStoresListing';
26
+ import { OAlert } from '../../../../../src/components/shared'
26
27
 
27
28
  const CartUI = (props: any) => {
28
29
  const {
@@ -36,7 +37,8 @@ const CartUI = (props: any) => {
36
37
  setIsCartsLoading,
37
38
  handleChangeComment,
38
39
  commentState,
39
- onNavigationRedirect
40
+ onNavigationRedirect,
41
+ handleRemoveOfferClick
40
42
  } = props
41
43
 
42
44
  const theme = useTheme();
@@ -50,7 +52,8 @@ const CartUI = (props: any) => {
50
52
  const [openUpselling, setOpenUpselling] = useState(false)
51
53
  const [openChangeStore, setOpenChangeStore] = useState(false)
52
54
  const [canOpenUpselling, setCanOpenUpselling] = useState(false)
53
- const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
55
+ const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null, type: '' })
56
+ const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
54
57
 
55
58
  const isCartPending = cart?.status === 2
56
59
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
@@ -69,12 +72,12 @@ const CartUI = (props: any) => {
69
72
  const handleEditProduct = (product: any) => {
70
73
  onNavigationRedirect('ProductDetails', {
71
74
  businessId,
72
- isCartProduct: true,
75
+ isCartProduct: true,
73
76
  productCart: product,
74
77
  businessSlug: cart?.business?.slug,
75
78
  categoryId: product?.category_id,
76
79
  productId: product?.id,
77
- })
80
+ })
78
81
  }
79
82
 
80
83
  const handleClearProducts = async () => {
@@ -109,6 +112,22 @@ const CartUI = (props: any) => {
109
112
  }
110
113
  }
111
114
 
115
+ const getIncludedTaxesDiscounts = () => {
116
+ return cart?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
117
+ }
118
+
119
+ const onRemoveOffer = (id: number) => {
120
+ setConfirm({
121
+ open: true,
122
+ content: [t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')],
123
+ title: t('OFFER', 'Offer'),
124
+ handleOnAccept: () => {
125
+ setConfirm({ ...confirm, open: false })
126
+ handleRemoveOfferClick(id)
127
+ }
128
+ })
129
+ }
130
+
112
131
  const walletName: any = {
113
132
  cash: {
114
133
  name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet'),
@@ -166,7 +185,7 @@ const CartUI = (props: any) => {
166
185
  {parsePrice(cart?.subtotal + getIncludedTaxes())}
167
186
  </OText>
168
187
  </OSTable>
169
- {cart?.discount > 0 && cart?.total >= 0 && (
188
+ {cart?.discount > 0 && cart?.total >= 0 && cart?.offers?.length === 0 && (
170
189
  <OSTable>
171
190
  {cart?.discount_type === 1 ? (
172
191
  <OText size={12} lineHeight={18}>
@@ -179,19 +198,51 @@ const CartUI = (props: any) => {
179
198
  <OText size={12} lineHeight={18}>- {parsePrice(cart?.discount || 0)}</OText>
180
199
  </OSTable>
181
200
  )}
201
+ {
202
+ cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
203
+ <OSTable key={offer.id}>
204
+ <OSRow>
205
+ <OText size={12} lineHeight={18}>{offer.name}</OText>
206
+ {offer.rate_type === 1 && (
207
+ <OText size={12} lineHeight={18}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
208
+ )}
209
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
210
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
211
+ </TouchableOpacity>
212
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
213
+ <AntIcon name='closecircle' size={18} color={theme.colors.primary} />
214
+ </TouchableOpacity>
215
+ </OSRow>
216
+ <OText size={12} lineHeight={18}>
217
+ - {parsePrice(offer?.summary?.discount)}
218
+ </OText>
219
+ </OSTable>
220
+ ))
221
+ }
222
+ <Divider />
223
+ {cart?.subtotal_with_discount > 0 && cart?.discount > 0 && cart?.total >= 0 && (
224
+ <OSTable>
225
+ <OText size={12} lineHeight={18} numberOfLines={1}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
226
+ {cart?.business?.tax_type === 1 ? (
227
+ <OText size={12} lineHeight={18}>{parsePrice(cart?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0)}</OText>
228
+ ) : (
229
+ <OText size={12} lineHeight={18}>{parsePrice(cart?.subtotal_with_discount ?? 0)}</OText>
230
+ )}
231
+ </OSTable>
232
+ )}
182
233
  {
183
234
  cart.taxes?.length > 0 && cart.taxes.filter((tax: any) => tax.type === 2 && tax?.rate !== 0).map((tax: any) => (
184
235
  <OSTable key={tax.id}>
185
236
  <OSRow>
186
- <OText numberOfLines={1} >
237
+ <OText size={12} lineHeight={18} numberOfLines={1} >
187
238
  {tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
188
239
  {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
189
240
  </OText>
190
- <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
241
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax, type: 'tax' })} >
191
242
  <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
192
243
  </TouchableOpacity>
193
244
  </OSRow>
194
- <OText>{parsePrice(tax?.summary?.tax || 0)}</OText>
245
+ <OText size={12} lineHeight={18}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
195
246
  </OSTable>
196
247
  ))
197
248
  }
@@ -199,33 +250,66 @@ const CartUI = (props: any) => {
199
250
  cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any) => (
200
251
  <OSTable key={fee?.id}>
201
252
  <OSRow>
202
- <OText numberOfLines={1} size={12} lineHeight={18}>
253
+ <OText size={12} lineHeight={18} numberOfLines={1}>
203
254
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
204
255
  ({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
205
256
  </OText>
206
- <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
257
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
207
258
  <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
208
259
  </TouchableOpacity>
209
260
  </OSRow>
210
- <OText>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
261
+ <OText size={12} lineHeight={18}>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
262
+ </OSTable>
263
+ ))
264
+ }
265
+ {
266
+ cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
267
+ <OSTable key={offer.id}>
268
+ <OSRow>
269
+ <OText size={12} lineHeight={18}>{offer.name}</OText>
270
+ {offer.rate_type === 1 && (
271
+ <OText size={12} lineHeight={18}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
272
+ )}
273
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
274
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
275
+ </TouchableOpacity>
276
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
277
+ <AntIcon name='closecircle' size={18} color={theme.colors.primary} />
278
+ </TouchableOpacity>
279
+ </OSRow>
280
+ <OText size={12} lineHeight={18}>
281
+ - {parsePrice(offer?.summary?.discount)}
282
+ </OText>
211
283
  </OSTable>
212
284
  ))
213
285
  }
214
- {cart?.service_fee > 0 && !cart?.fees?.length && (
215
- <OSTable>
216
- <OText size={12} lineHeight={18}>
217
- {t('SERVICE_FEE', 'Service Fee')}
218
- {`(${verifyDecimals(cart?.business?.service_fee, parseNumber)}%)`}
219
- </OText>
220
- <OText size={12} lineHeight={18}>{parsePrice(cart?.service_fee)}</OText>
221
- </OSTable>
222
- )}
223
286
  {orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
224
287
  <OSTable>
225
288
  <OText size={12} lineHeight={18}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
226
289
  <OText size={12} lineHeight={18}>{parsePrice(cart?.delivery_price)}</OText>
227
290
  </OSTable>
228
291
  )}
292
+ {
293
+ cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
294
+ <OSTable key={offer.id}>
295
+ <OSRow>
296
+ <OText size={12} lineHeight={18}>{offer.name}</OText>
297
+ {offer.rate_type === 1 && (
298
+ <OText size={12} lineHeight={18}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
299
+ )}
300
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
301
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
302
+ </TouchableOpacity>
303
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
304
+ <AntIcon name='closecircle' size={18} color={theme.colors.primary} />
305
+ </TouchableOpacity>
306
+ </OSRow>
307
+ <OText size={12} lineHeight={18}>
308
+ - {parsePrice(offer?.summary?.discount)}
309
+ </OText>
310
+ </OSTable>
311
+ ))
312
+ }
229
313
  {cart?.driver_tip > 0 && (
230
314
  <OSTable>
231
315
  <OText size={12} lineHeight={18}>
@@ -265,7 +349,7 @@ const CartUI = (props: any) => {
265
349
  {t('TOTAL', 'Total')}
266
350
  </OText>
267
351
  <OText size={14} lineHeight={21} weight={'600'}>
268
- {parsePrice(cart?.balance ?? cart?.total)}
352
+ {parsePrice(cart?.total >= 0 ? cart?.total : 0)}
269
353
  </OText>
270
354
  </OSTable>
271
355
  </OSTotal>
@@ -339,11 +423,25 @@ const CartUI = (props: any) => {
339
423
  </OModal>
340
424
  <OModal
341
425
  open={openTaxModal.open}
342
- onClose={() => setOpenTaxModal({ open: false, data: null })}
426
+ onClose={() => setOpenTaxModal({ open: false, data: null, type: '' })}
343
427
  entireModal
428
+ title={`${openTaxModal.data?.name ||
429
+ 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}%`})` : ''} `}
344
430
  >
345
- <TaxInformation data={openTaxModal.data} products={cart.products} />
431
+ <TaxInformation
432
+ type={openTaxModal.type}
433
+ data={openTaxModal.data}
434
+ products={cart?.products}
435
+ />
346
436
  </OModal>
437
+ <OAlert
438
+ open={confirm.open}
439
+ title={confirm.title}
440
+ content={confirm.content}
441
+ onAccept={confirm.handleOnAccept}
442
+ onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
443
+ onClose={() => setConfirm({ ...confirm, open: false, title: null })}
444
+ />
347
445
  </CContainer>
348
446
  )
349
447
  }
@@ -1,4 +1,4 @@
1
- import styled, { css } from 'styled-components/native';
1
+ import styled from 'styled-components/native';
2
2
 
3
3
  export const CContainer = styled.View`
4
4
  /* border-bottom: 1px solid #F0F0F0; */
@@ -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
+ `
@@ -35,6 +35,7 @@ import {
35
35
  Icons,
36
36
  OrderDriver,
37
37
  Map,
38
+ Divider,
38
39
  } from './styles';
39
40
  import { OButton, OIcon, OModal, OText } from '../shared';
40
41
  import { ProductItemAccordion } from '../ProductItemAccordion';
@@ -100,7 +101,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
100
101
  business: false,
101
102
  driver: false,
102
103
  });
103
- const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
104
+ const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, tax: null, type: '' })
104
105
 
105
106
  const { order, businessData } = props.order;
106
107
 
@@ -349,6 +350,10 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
349
350
  }
350
351
  }
351
352
 
353
+ const getIncludedTaxesDiscounts = () => {
354
+ return order?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
355
+ }
356
+
352
357
  const handleClickOrderReview = (order: any) => {
353
358
  navigation.navigate(
354
359
  'ReviewOrder',
@@ -527,7 +532,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
527
532
  onPress={() => order?.business?.cellphone &&
528
533
  Linking.openURL(`tel:${order?.business?.cellphone}`)
529
534
  }
530
- style={{ paddingEnd: 5 }}>
535
+ style={{ paddingEnd: 5 }}
536
+ >
531
537
  <OIcon
532
538
  src={theme.images.general.phone}
533
539
  width={16}
@@ -730,10 +736,10 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
730
736
  <Table>
731
737
  <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{t('SUBTOTAL', 'Subtotal')}</OText>
732
738
  <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
733
- {parsePrice(((order?.summary?.subtotal || order?.subtotal) + getIncludedTaxes()))}
739
+ {parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()))}
734
740
  </OText>
735
741
  </Table>
736
- {(order?.summary?.discount > 0 || order?.discount > 0) && (
742
+ {(order?.summary?.discount > 0 ?? order?.discount > 0) && order?.offers?.length === 0 && (
737
743
  <Table>
738
744
  {order?.offer_type === 1 ? (
739
745
  <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
@@ -751,24 +757,53 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
751
757
  </OText>
752
758
  </Table>
753
759
  )}
760
+ {
761
+ order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
762
+ <Table key={offer.id}>
763
+ <OSRow>
764
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal} numberOfLines={1}>
765
+ {offer.name}
766
+ {offer.rate_type === 1 && (
767
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
768
+ )}
769
+ </OText>
770
+ <TouchableOpacity style={{ marginLeft: 5 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
771
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
772
+ </TouchableOpacity>
773
+ </OSRow>
774
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>- {parsePrice(offer?.summary?.discount)}</OText>
775
+ </Table>
776
+ ))
777
+ }
778
+ <Divider />
779
+ {order?.summary?.subtotal_with_discount > 0 && order?.summary?.discount > 0 && order?.summary?.total >= 0 && (
780
+ <Table>
781
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
782
+ {order?.tax_type === 1 ? (
783
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{parsePrice((order?.summary?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0))}</OText>
784
+ ) : (
785
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{parsePrice(order?.summary?.subtotal_with_discount ?? 0)}</OText>
786
+ )}
787
+ </Table>
788
+ )}
754
789
  {
755
790
  order?.taxes?.length === 0 && order?.tax_type === 2 && (
756
791
  <Table>
757
- <OText size={12}>
792
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
758
793
  {t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
759
794
  </OText>
760
- <OText size={12}>{parsePrice(order?.summary?.tax || 0)}</OText>
795
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{parsePrice(order?.summary?.tax || 0)}</OText>
761
796
  </Table>
762
797
  )
763
798
  }
764
799
  {
765
800
  order?.fees?.length === 0 && (
766
801
  <Table>
767
- <OText size={12}>
802
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
768
803
  {t('SERVICE_FEE', 'Service fee')}
769
804
  {`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
770
805
  </OText>
771
- <OText size={12}>{parsePrice(order?.summary?.service_fee || 0)}</OText>
806
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{parsePrice(order?.summary?.service_fee || 0)}</OText>
772
807
  </Table>
773
808
  )
774
809
  }
@@ -776,15 +811,15 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
776
811
  order?.taxes?.length > 0 && order?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
777
812
  <Table key={tax.id}>
778
813
  <OSRow>
779
- <OText size={12} numberOfLines={1}>
814
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal} numberOfLines={1}>
780
815
  {tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
781
816
  {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
782
817
  </OText>
783
- <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })}>
818
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax, type: 'tax' })}>
784
819
  <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
785
820
  </TouchableOpacity>
786
821
  </OSRow>
787
- <OText size={12}>{parsePrice(tax?.summary?.tax || 0)}</OText>
822
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
788
823
  </Table>
789
824
  ))
790
825
  }
@@ -792,53 +827,84 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
792
827
  order?.fees?.length > 0 && order?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
793
828
  <Table key={fee.id}>
794
829
  <OSRow>
795
- <OText size={12} numberOfLines={1}>
830
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal} numberOfLines={1}>
796
831
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
797
832
  ({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
798
833
  </OText>
799
- <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })}>
834
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })}>
800
835
  <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
801
836
  </TouchableOpacity>
802
837
  </OSRow>
803
- <OText size={12}>{parsePrice(fee?.fixed + fee?.summary?.percentage || 0)}</OText>
838
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
804
839
  </Table>
805
840
  ))
806
841
  }
807
- {(order?.summary?.delivery_price > 0 ||
808
- order?.deliveryFee > 0) && (
809
- <Table>
810
- <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
811
- <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
812
- {parsePrice(
813
- order?.summary?.delivery_price || order?.deliveryFee,
814
- )}
815
- </OText>
842
+ {
843
+ order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
844
+ <Table key={offer.id}>
845
+ <OSRow>
846
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal} numberOfLines={1}>
847
+ {offer.name}
848
+ {offer.rate_type === 1 && (
849
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
850
+ )}
851
+ </OText>
852
+ <TouchableOpacity style={{ marginLeft: 5 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
853
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
854
+ </TouchableOpacity>
855
+ </OSRow>
856
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>- {parsePrice(offer?.summary?.discount)}</OText>
816
857
  </Table>
817
- )}
818
- <Table>
819
- <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
820
- {t('DRIVER_TIP', 'Driver tip')}
821
- {(order?.summary?.driver_tip > 0 || order?.driver_tip > 0) &&
822
- parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
823
- !parseInt(configs?.driver_tip_use_custom?.value, 10) &&
824
- `(${verifyDecimals(order?.driver_tip, parseNumber)}%)`}
825
- </OText>
826
- <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
827
- {parsePrice(
828
- order?.summary?.driver_tip || order?.totalDriverTip,
829
- )}
830
- </OText>
831
- </Table>
858
+ ))
859
+ }
860
+ {order?.summary?.delivery_price > 0 && (
861
+ <Table>
862
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
863
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{parsePrice(order?.summary?.delivery_price)}</OText>
864
+ </Table>
865
+ )}
866
+ {
867
+ order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
868
+ <Table key={offer.id}>
869
+ <OSRow>
870
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal} numberOfLines={1}>
871
+ {offer.name}
872
+ {offer.rate_type === 1 && (
873
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
874
+ )}
875
+ </OText>
876
+ <TouchableOpacity style={{ marginLeft: 5 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
877
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
878
+ </TouchableOpacity>
879
+ </OSRow>
880
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>- {parsePrice(offer?.summary?.discount)}</OText>
881
+ </Table>
882
+ ))
883
+ }
884
+ {order?.summary?.driver_tip > 0 && (
885
+ <Table>
886
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>
887
+ {t('DRIVER_TIP', 'Driver tip')}
888
+ {order?.summary?.driver_tip > 0 &&
889
+ parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
890
+ !parseInt(configs?.driver_tip_use_custom?.value, 10) &&
891
+ (
892
+ `(${verifyDecimals(order?.summary?.driver_tip, parseNumber)}%)`
893
+ )}
894
+ </OText>
895
+ <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal}>{parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip)}</OText>
896
+ </Table>
897
+ )}
832
898
  <Total>
833
899
  <Table>
834
900
  <OText size={20} lineHeight={30} weight={'600'} color={theme.colors.textNormal}>{t('TOTAL', 'Total')}</OText>
835
901
  <OText size={20} lineHeight={30} weight={'600'} color={theme.colors.textNormal}>
836
- {parsePrice(order?.summary?.total || order?.total)}
902
+ {parsePrice(order?.summary?.total ?? order?.total)}
837
903
  </OText>
838
904
  </Table>
839
905
  </Total>
840
906
  {order?.payment_events?.length > 0 && (
841
- <View style={{marginTop: 10}}>
907
+ <View style={{ marginTop: 10 }}>
842
908
  <OText size={20} weight='bold' color={theme.colors.textNormal}>{t('PAYMENTS', 'Payments')}</OText>
843
909
  <View
844
910
  style={{
@@ -904,10 +970,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
904
970
  </OModal>
905
971
  <OModal
906
972
  open={openTaxModal.open}
907
- onClose={() => setOpenTaxModal({ open: false, data: null })}
973
+ onClose={() => setOpenTaxModal({ open: false, data: null, type: '' })}
908
974
  entireModal
975
+ title={`${openTaxModal.data?.name ||
976
+ 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}%`})` : ''} `}
909
977
  >
910
- <TaxInformation data={openTaxModal.data} products={order?.products} />
978
+ <TaxInformation
979
+ type={openTaxModal.type}
980
+ data={openTaxModal.data}
981
+ products={order?.products}
982
+ />
911
983
  </OModal>
912
984
  </OrderDetailsContainer>
913
985
  );
@@ -116,5 +116,12 @@ export const Map = styled.View`
116
116
  width: 100%;
117
117
  height: 250px;
118
118
  margin-top: 20px;
119
- border-radius: 20px
119
+ border-radius: 20px;
120
+ `
121
+
122
+ export const Divider = styled.View`
123
+ border-color: #EAEAEA;
124
+ border-width: 1px;
125
+ margin-top: 5px;
126
+ margin-bottom: 5px;
120
127
  `
@@ -14,7 +14,8 @@ 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';
@@ -24,6 +25,7 @@ import { verifyDecimals } from '../../utils';
24
25
  import AntIcon from 'react-native-vector-icons/AntDesign'
25
26
  import { TaxInformation } from '../TaxInformation';
26
27
  import { TouchableOpacity } from 'react-native';
28
+ import { OAlert } from '../../../../../src/components/shared'
27
29
 
28
30
  const OrderSummaryUI = (props: any) => {
29
31
  const {
@@ -35,7 +37,8 @@ const OrderSummaryUI = (props: any) => {
35
37
  isFromCheckout,
36
38
  commentState,
37
39
  handleChangeComment,
38
- onNavigationRedirect
40
+ onNavigationRedirect,
41
+ handleRemoveOfferClick
39
42
  } = props;
40
43
 
41
44
  const theme = useTheme()
@@ -44,8 +47,8 @@ const OrderSummaryUI = (props: any) => {
44
47
  const [orderState] = useOrder();
45
48
  const [{ parsePrice, parseNumber }] = useUtils();
46
49
  const [validationFields] = useValidationFields();
47
- const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
48
-
50
+ const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null, type: '' })
51
+ const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
49
52
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
50
53
 
51
54
  const handleDeleteClick = (product: any) => {
@@ -61,7 +64,7 @@ const OrderSummaryUI = (props: any) => {
61
64
  categoryId: product?.category_id,
62
65
  productId: product?.id,
63
66
  isFromCheckout: isFromCheckout,
64
- })
67
+ })
65
68
  }
66
69
 
67
70
  const getIncludedTaxes = () => {
@@ -74,6 +77,22 @@ const OrderSummaryUI = (props: any) => {
74
77
  }
75
78
  }
76
79
 
80
+ const getIncludedTaxesDiscounts = () => {
81
+ return cart?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
82
+ }
83
+
84
+ const onRemoveOffer = (id: number) => {
85
+ setConfirm({
86
+ open: true,
87
+ content: [t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')],
88
+ title: t('OFFER', 'Offer'),
89
+ handleOnAccept: () => {
90
+ setConfirm({ ...confirm, open: false })
91
+ handleRemoveOfferClick(id)
92
+ }
93
+ })
94
+ }
95
+
77
96
  const cart = orderState?.carts?.[`businessId:${props.cart.business_id}`]
78
97
 
79
98
  const walletName: any = {
@@ -109,9 +128,11 @@ const OrderSummaryUI = (props: any) => {
109
128
  <OSBill>
110
129
  <OSTable>
111
130
  <OText size={12}>{t('SUBTOTAL', 'Subtotal')}</OText>
112
- <OText size={12}>{parsePrice(cart?.subtotal + getIncludedTaxes())}</OText>
131
+ <OText size={12}>
132
+ {parsePrice(cart?.subtotal + getIncludedTaxes())}
133
+ </OText>
113
134
  </OSTable>
114
- {cart?.discount > 0 && cart?.total >= 0 && (
135
+ {cart?.discount > 0 && cart?.total >= 0 && cart?.offers?.length === 0 && (
115
136
  <OSTable>
116
137
  {cart?.discount_type === 1 ? (
117
138
  <OText size={12}>
@@ -125,34 +146,87 @@ const OrderSummaryUI = (props: any) => {
125
146
  </OSTable>
126
147
  )}
127
148
  {
128
- cart?.taxes?.length > 0 && cart?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
129
- <OSTable key={tax?.id}>
149
+ cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
150
+ <OSTable key={offer.id}>
130
151
  <OSRow>
131
- <OText size={12} numberOfLines={1}>
132
- {tax?.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
152
+ <OText size={12}>{offer.name}</OText>
153
+ {offer.rate_type === 1 && (
154
+ <OText size={12}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
155
+ )}
156
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
157
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
158
+ </TouchableOpacity>
159
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
160
+ <AntIcon name='closecircle' size={18} color={theme.colors.primary} />
161
+ </TouchableOpacity>
162
+ </OSRow>
163
+ <OText size={12}>
164
+ - {parsePrice(offer?.summary?.discount)}
165
+ </OText>
166
+ </OSTable>
167
+ ))
168
+ }
169
+ <Divider />
170
+ {cart?.subtotal_with_discount > 0 && cart?.discount > 0 && cart?.total >= 0 && (
171
+ <OSTable>
172
+ <OText size={12} numberOfLines={1}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
173
+ {cart?.business?.tax_type === 1 ? (
174
+ <OText size={12}>{parsePrice(cart?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0)}</OText>
175
+ ) : (
176
+ <OText size={12}>{parsePrice(cart?.subtotal_with_discount ?? 0)}</OText>
177
+ )}
178
+ </OSTable>
179
+ )}
180
+ {
181
+ cart.taxes?.length > 0 && cart.taxes.filter((tax: any) => tax.type === 2 && tax?.rate !== 0).map((tax: any) => (
182
+ <OSTable key={tax.id}>
183
+ <OSRow>
184
+ <OText size={12} numberOfLines={1} >
185
+ {tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
133
186
  {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
134
187
  </OText>
135
- <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
136
- <AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
188
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax, type: 'tax' })} >
189
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
137
190
  </TouchableOpacity>
138
191
  </OSRow>
139
- <OText size={12}>{parsePrice(tax?.summary?.tax || 0)}</OText>
192
+ <OText size={12}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
140
193
  </OSTable>
141
194
  ))
142
195
  }
143
196
  {
144
- cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
145
- <OSTable key={fee.id}>
197
+ cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any) => (
198
+ <OSTable key={fee?.id}>
146
199
  <OSRow>
147
200
  <OText size={12} numberOfLines={1}>
148
201
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
149
- ({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
202
+ ({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
150
203
  </OText>
151
- <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
152
- <AntIcon name='exclamationcircleo' size={20} color={theme.colors.primary} />
204
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
205
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
153
206
  </TouchableOpacity>
154
207
  </OSRow>
155
- <OText size={12}>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
208
+ <OText size={12}>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
209
+ </OSTable>
210
+ ))
211
+ }
212
+ {
213
+ cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
214
+ <OSTable key={offer.id}>
215
+ <OSRow>
216
+ <OText size={12}>{offer.name}</OText>
217
+ {offer.rate_type === 1 && (
218
+ <OText size={12}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
219
+ )}
220
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
221
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
222
+ </TouchableOpacity>
223
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
224
+ <AntIcon name='closecircle' size={18} color={theme.colors.primary} />
225
+ </TouchableOpacity>
226
+ </OSRow>
227
+ <OText size={12}>
228
+ - {parsePrice(offer?.summary?.discount)}
229
+ </OText>
156
230
  </OSTable>
157
231
  ))
158
232
  }
@@ -162,6 +236,27 @@ const OrderSummaryUI = (props: any) => {
162
236
  <OText size={12}>{parsePrice(cart?.delivery_price)}</OText>
163
237
  </OSTable>
164
238
  )}
239
+ {
240
+ cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
241
+ <OSTable key={offer.id}>
242
+ <OSRow>
243
+ <OText size={12}>{offer.name}</OText>
244
+ {offer.rate_type === 1 && (
245
+ <OText size={12}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
246
+ )}
247
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
248
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
249
+ </TouchableOpacity>
250
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
251
+ <AntIcon name='closecircle' size={18} color={theme.colors.primary} />
252
+ </TouchableOpacity>
253
+ </OSRow>
254
+ <OText size={12}>
255
+ - {parsePrice(offer?.summary?.discount)}
256
+ </OText>
257
+ </OSTable>
258
+ ))
259
+ }
165
260
  {cart?.driver_tip > 0 && (
166
261
  <OSTable>
167
262
  <OText size={12}>
@@ -201,7 +296,7 @@ const OrderSummaryUI = (props: any) => {
201
296
  {t('TOTAL', 'Total')}
202
297
  </OText>
203
298
  <OText size={14} style={{ fontWeight: 'bold' }} >
204
- {parsePrice(cart?.balance ?? cart?.total)}
299
+ {parsePrice(cart?.total >= 0 ? cart?.total : 0)}
205
300
  </OText>
206
301
  </OSTable>
207
302
  </View>
@@ -243,11 +338,25 @@ const OrderSummaryUI = (props: any) => {
243
338
  )}
244
339
  <OModal
245
340
  open={openTaxModal.open}
246
- onClose={() => setOpenTaxModal({ open: false, data: null })}
341
+ onClose={() => setOpenTaxModal({ open: false, data: null, type: '' })}
247
342
  entireModal
343
+ title={`${openTaxModal.data?.name ||
344
+ 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}%`})` : ''} `}
248
345
  >
249
- <TaxInformation data={openTaxModal.data} products={cart.products} />
346
+ <TaxInformation
347
+ type={openTaxModal.type}
348
+ data={openTaxModal.data}
349
+ products={cart?.products}
350
+ />
250
351
  </OModal>
352
+ <OAlert
353
+ open={confirm.open}
354
+ title={confirm.title}
355
+ content={confirm.content}
356
+ onAccept={confirm.handleOnAccept}
357
+ onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
358
+ onClose={() => setConfirm({ ...confirm, open: false, title: null })}
359
+ />
251
360
  </>
252
361
  )}
253
362
  </OSContainer>
@@ -39,3 +39,10 @@ export const OSRow = styled.View`
39
39
  overflow: hidden;
40
40
  width: 80%;
41
41
  `
42
+
43
+ export const Divider = styled.View`
44
+ border-color: #EAEAEA;
45
+ border-width: 1px;
46
+ margin-top: 5px;
47
+ margin-bottom: 10px;
48
+ `
@@ -1,51 +1,83 @@
1
- import React from 'react'
2
- import { useLanguage, useUtils } from 'ordering-components/native'
1
+ import React, { Mixin } from 'react'
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: { name: string, description?: string, rate: string | number, type: number, fixed?: number, percentage?: number, id: number },
9
- products: Array<any>
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
+ } | null,
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
- <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 && (
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('DESCRIPTION', 'Description')}: {data?.description} {data?.type && includedOnPriceString}
61
+ {t('WITHOUT_DESCRIPTION', 'Without description')}
34
62
  </OText>
35
63
  )}
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>
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
  }