ordering-ui-react-native 0.14.40 → 0.14.42-release

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/package.json +2 -2
  2. package/src/components/BusinessItemAccordion/index.tsx +2 -2
  3. package/src/components/Cart/index.tsx +135 -42
  4. package/src/components/Cart/styles.tsx +7 -0
  5. package/src/components/Checkout/index.tsx +28 -166
  6. package/src/components/OrderDetails/index.tsx +102 -34
  7. package/src/components/OrderDetails/styles.tsx +7 -0
  8. package/src/components/OrderSummary/index.tsx +140 -37
  9. package/src/components/OrderSummary/styles.tsx +10 -2
  10. package/src/components/PaymentOptions/index.tsx +3 -1
  11. package/src/components/PaymentOptionsWebView/index.tsx +150 -0
  12. package/src/components/ProductForm/index.tsx +6 -6
  13. package/src/components/SingleProductCard/index.tsx +1 -1
  14. package/src/components/StripeElementsForm/index.tsx +28 -13
  15. package/src/components/TaxInformation/index.tsx +58 -26
  16. package/src/components/VerifyPhone/styles.tsx +1 -2
  17. package/src/components/shared/OIcon.tsx +4 -1
  18. package/src/index.tsx +2 -0
  19. package/src/navigators/HomeNavigator.tsx +6 -0
  20. package/src/pages/ProductDetails.tsx +55 -0
  21. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  22. package/themes/kiosk/src/components/Cart/index.tsx +14 -21
  23. package/themes/kiosk/src/components/CartItem/index.tsx +9 -7
  24. package/themes/kiosk/src/components/CustomerName/index.tsx +2 -1
  25. package/themes/kiosk/src/components/Intro/index.tsx +4 -4
  26. package/themes/kiosk/src/components/OptionCard/index.tsx +11 -6
  27. package/themes/kiosk/src/components/PaymentOptions/index.tsx +46 -44
  28. package/themes/original/src/components/BusinessController/index.tsx +3 -3
  29. package/themes/original/src/components/BusinessFeaturedController/index.tsx +2 -2
  30. package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -9
  31. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -2
  32. package/themes/original/src/components/BusinessProductsListing/index.tsx +8 -4
  33. package/themes/original/src/components/BusinessesListing/index.tsx +129 -94
  34. package/themes/original/src/components/Cart/index.tsx +122 -24
  35. package/themes/original/src/components/Cart/styles.tsx +8 -1
  36. package/themes/original/src/components/Checkout/index.tsx +38 -3
  37. package/themes/original/src/components/Help/index.tsx +1 -1
  38. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -0
  39. package/themes/original/src/components/MessageListing/index.tsx +4 -2
  40. package/themes/original/src/components/MomentOption/index.tsx +150 -158
  41. package/themes/original/src/components/OrderDetails/index.tsx +114 -42
  42. package/themes/original/src/components/OrderDetails/styles.tsx +8 -1
  43. package/themes/original/src/components/OrderProgress/index.tsx +2 -1
  44. package/themes/original/src/components/OrderSummary/index.tsx +132 -23
  45. package/themes/original/src/components/OrderSummary/styles.tsx +7 -0
  46. package/themes/original/src/components/PaymentOptionWallet/index.tsx +6 -2
  47. package/themes/original/src/components/PaymentOptions/index.tsx +8 -2
  48. package/themes/original/src/components/ProductForm/index.tsx +63 -56
  49. package/themes/original/src/components/ProductOptionSubOption/index.tsx +54 -51
  50. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +8 -1
  51. package/themes/original/src/components/SingleProductCard/index.tsx +36 -19
  52. package/themes/original/src/components/SingleProductCard/styles.tsx +4 -0
  53. package/themes/original/src/components/StripeElementsForm/index.tsx +28 -13
  54. package/themes/original/src/components/TaxInformation/index.tsx +59 -27
  55. package/themes/original/src/components/UpsellingProducts/index.tsx +26 -18
  56. package/themes/original/src/types/index.tsx +2 -0
@@ -155,7 +155,7 @@ export const ProductOptionsUI = (props: any) => {
155
155
  const { product, loading, error } = productObject;
156
156
  const [gallery, setGallery] = useState([])
157
157
  const [thumbsSwiper, setThumbsSwiper] = useState(0)
158
-
158
+ const [indexGallery, setIndexGallery] = useState(0)
159
159
  const [selOpt, setSelectedOpt] = useState(0);
160
160
  const [isHaveWeight, setIsHaveWeight] = useState(false)
161
161
  const [qtyBy, setQtyBy] = useState({
@@ -208,11 +208,16 @@ export const ProductOptionsUI = (props: any) => {
208
208
  }
209
209
 
210
210
  const handleClickThumb = (index: number) => {
211
- swiperRef?.current.scrollBy(index - thumbsSwiper, true);
211
+ if (index !== indexGallery) {
212
+ swiperRef?.current.scrollBy(index - thumbsSwiper, true);
213
+ setIndexGallery(index)
214
+ }
212
215
  }
213
216
 
214
217
  const handleRedirectLogin = () => {
215
- navigation.navigate('Login');
218
+ navigation.navigate('Login', {
219
+ store_slug: props.businessSlug
220
+ });
216
221
  };
217
222
 
218
223
  const handleSwitchQtyUnit = (val: string) => {
@@ -289,16 +294,16 @@ export const ProductOptionsUI = (props: any) => {
289
294
  </>
290
295
  );
291
296
 
292
- const handleGoBack = navigation?.canGoBack()
293
- ? () => navigation.goBack()
294
- : () => navigation.navigate('Business', { store: props.businessSlug })
297
+ const handleGoBack = navigation?.canGoBack()
298
+ ? () => navigation.goBack()
299
+ : () => navigation.navigate('Business', { store: props.businessSlug })
295
300
 
296
301
  return (
297
- <SafeAreaView style={{ flex: 1 }}>
298
- <TopHeader>
299
- <TopActions onPress={() => handleGoBack()}>
300
- <OIcon src={theme.images.general.arrow_left} width={15} />
301
- </TopActions>
302
+ <SafeAreaView style={{ flex: 1 }}>
303
+ <TopHeader>
304
+ <TopActions onPress={() => handleGoBack()}>
305
+ <OIcon src={theme.images.general.arrow_left} width={15} />
306
+ </TopActions>
302
307
  </TopHeader>
303
308
  <ScrollView>
304
309
  {!error && (
@@ -349,13 +354,13 @@ export const ProductOptionsUI = (props: any) => {
349
354
  style={styles.slide1}
350
355
  key={i}
351
356
  >
352
- <FastImage
353
- style={{ height: '100%', opacity: isSoldOut ? 0.5 : 1 }}
354
- source={{
355
- uri: optimizeImage(img, 'h_258,c_limit'),
356
- priority: FastImage.priority.normal,
357
- }}
358
- />
357
+ <FastImage
358
+ style={{ height: '100%', opacity: isSoldOut ? 0.5 : 1 }}
359
+ source={{
360
+ uri: optimizeImage(img, 'h_258,c_limit'),
361
+ priority: FastImage.priority.normal,
362
+ }}
363
+ />
359
364
  </View>
360
365
  ))}
361
366
  </Swiper>
@@ -379,18 +384,18 @@ export const ProductOptionsUI = (props: any) => {
379
384
  opacity: index === thumbsSwiper ? 1 : 0.8
380
385
  }}
381
386
  >
382
- <OIcon
383
- url={img}
384
- style={{
385
- borderColor: theme.colors.lightGray,
386
- borderRadius: 8,
387
- minHeight: '100%',
388
- opacity: isSoldOut ? 0.5 : 1
389
- }}
390
- width={56}
391
- height={56}
392
- cover
393
- />
387
+ <OIcon
388
+ url={img}
389
+ style={{
390
+ borderColor: theme.colors.lightGray,
391
+ borderRadius: 8,
392
+ minHeight: '100%',
393
+ opacity: isSoldOut ? 0.5 : 1
394
+ }}
395
+ width={56}
396
+ height={56}
397
+ cover
398
+ />
394
399
  </View>
395
400
  </TouchableOpacity>
396
401
 
@@ -446,21 +451,21 @@ export const ProductOptionsUI = (props: any) => {
446
451
  ) : (
447
452
  <View style={{ flexDirection: 'row', marginBottom: 10 }}>
448
453
  <OText size={16} style={{ flex: I18nManager.isRTL ? 1 : 0 }} color={theme.colors.primary}>{productCart.price ? parsePrice(productCart.price) : ''}</OText>
449
- {!!product?.offer_price && (
454
+ {product?.offer_price !== null && product?.in_offer && (
450
455
  <OText style={{
451
456
  fontSize: 14,
452
457
  color: '#808080',
453
458
  textDecorationLine: 'line-through',
454
459
  marginLeft: 7,
455
460
  marginRight: 7
456
- }}>{parsePrice(product?.offer_price)}</OText>
461
+ }}>{product?.offer_price ? parsePrice(product?.offer_price) : ''}</OText>
457
462
  )}
458
463
  </View>
459
464
  )}
460
465
  </>
461
466
  )}
462
467
  </ProductTitle>
463
- <ProductDescription>
468
+ <ProductDescription>
464
469
  <OText color={theme.colors.textSecondary} size={12} lineHeight={18}>
465
470
  {product?.description || productCart?.description}
466
471
  </OText>
@@ -785,7 +790,7 @@ export const ProductOptionsUI = (props: any) => {
785
790
  <OText
786
791
  size={12}
787
792
  lineHeight={18}
788
- style={{ minWidth: 29, textAlign: 'center' }}
793
+ style={{ minWidth: 40, textAlign: 'center' }}
789
794
  >
790
795
  {qtyBy?.pieces && productCart.quantity}
791
796
  {qtyBy?.weight_unit && productCart.quantity * product?.weight}
@@ -809,36 +814,38 @@ export const ProductOptionsUI = (props: any) => {
809
814
  }
810
815
  />
811
816
  </TouchableOpacity>
812
- <WeightUnitSwitch>
813
- <TouchableOpacity
814
- onPress={() => handleSwitchQtyUnit('pieces')}
815
- >
816
- <WeightUnitItem active={qtyBy?.pieces}>
817
- <OText
818
- size={12}
819
- lineHeight={18}
820
- color={qtyBy?.pieces ? theme.colors.primary : theme.colors.textNormal}
821
- >
822
- {t('PIECES', 'pieces')}
823
- </OText>
824
- </WeightUnitItem>
825
- </TouchableOpacity>
826
- <View style={{ alignItems: 'flex-start' }}>
817
+ {isHaveWeight && (
818
+ <WeightUnitSwitch>
827
819
  <TouchableOpacity
828
- onPress={() => handleSwitchQtyUnit('weight_unit')}
820
+ onPress={() => handleSwitchQtyUnit('pieces')}
829
821
  >
830
- <WeightUnitItem active={qtyBy?.weight_unit}>
822
+ <WeightUnitItem active={qtyBy?.pieces}>
831
823
  <OText
832
824
  size={12}
833
825
  lineHeight={18}
834
- color={qtyBy?.weight_unit ? theme.colors.primary : theme.colors.textNormal}
826
+ color={qtyBy?.pieces ? theme.colors.primary : theme.colors.textNormal}
835
827
  >
836
- {product?.weight_unit}
828
+ {t('PIECES', 'pcs')}
837
829
  </OText>
838
830
  </WeightUnitItem>
839
831
  </TouchableOpacity>
840
- </View>
841
- </WeightUnitSwitch>
832
+ <View style={{ alignItems: 'flex-start' }}>
833
+ <TouchableOpacity
834
+ onPress={() => handleSwitchQtyUnit('weight_unit')}
835
+ >
836
+ <WeightUnitItem active={qtyBy?.weight_unit}>
837
+ <OText
838
+ size={12}
839
+ lineHeight={18}
840
+ color={qtyBy?.weight_unit ? theme.colors.primary : theme.colors.textNormal}
841
+ >
842
+ {product?.weight_unit}
843
+ </OText>
844
+ </WeightUnitItem>
845
+ </TouchableOpacity>
846
+ </View>
847
+ </WeightUnitSwitch>
848
+ )}
842
849
  </View>
843
850
  )}
844
851
  <View
@@ -907,7 +914,7 @@ export const ProductOptionsUI = (props: any) => {
907
914
  </View>
908
915
  </ProductActions>
909
916
  )}
910
- </SafeAreaView>
917
+ </SafeAreaView>
911
918
  );
912
919
  };
913
920
 
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'
2
2
  import {
3
3
  useUtils,
4
4
  useLanguage,
5
- ProductOptionSuboption as ProductSubOptionController,
5
+ ProductOptionSuboption as ProductSubOptionController
6
6
  } from 'ordering-components/native'
7
7
  import { useTheme } from 'styled-components/native';
8
8
  import { StyleSheet } from 'react-native'
@@ -51,7 +51,6 @@ export const ProductOptionSubOptionUI = (props: any) => {
51
51
 
52
52
  const disableIncrement = option?.limit_suboptions_by_max ? balance === option?.max : state.quantity === suboption?.max || (!state.selected && balance === option?.max)
53
53
  const price = option?.with_half_option && suboption?.half_price && state.position !== 'whole' ? suboption?.half_price : suboption?.price
54
-
55
54
  return (
56
55
  <Container>
57
56
  <IconControl disabled={disabled} onPress={() => handleSuboptionClick()}>
@@ -73,54 +72,57 @@ export const ProductOptionSubOptionUI = (props: any) => {
73
72
  </OText>
74
73
  </IconControl>
75
74
  {showMessage && <OText size={10} mLeft={4} mRight={4} style={{ flex: 1, textAlign: 'center' }} color={theme.colors.primary}>{`${t('OPTIONS_MAX_LIMIT', 'Maximum options to choose')}: ${option?.max}`}</OText>}
76
- {option?.allow_suboption_quantity && state?.selected && (
77
- <QuantityControl>
78
- <Checkbox disabled={disabled || state.quantity === 0} onPress={decrement}>
79
- <OIcon
80
- src={theme.images.general.minus}
81
- width={16}
82
- color={state.quantity === 0 || disabled ? theme.colors.disabled : theme.colors.primary}
83
- />
84
- </Checkbox>
85
- <OText mLeft={5} mRight={5}>
86
- {state.quantity}
87
- </OText>
88
- <Checkbox disabled={disabled || disableIncrement} onPress={increment}>
89
- <OIcon
90
- src={theme.images.general.plus}
91
- width={16}
92
- color={disableIncrement || disabled ? theme.colors.disabled : theme.colors.primary}
93
- />
94
- </Checkbox>
95
- </QuantityControl>
96
- )}
97
- {option?.with_half_option && state?.selected && (
98
- <PositionControl>
99
- <Circle disabled={disabled} onPress={() => changePosition('left')}>
100
- <OIcon
101
- src={theme.images.general.half_l}
102
- color={state.selected && state.position === 'left' ? theme.colors.primary : '#cbcbcb'}
103
- width={16}
104
- style={styles.inverse}
105
- />
106
- </Circle>
107
- <Circle disabled={disabled} onPress={() => changePosition('whole')}>
108
- <OIcon
109
- src={theme.images.general.half_f}
110
- color={state.selected && state.position === 'whole' ? theme.colors.primary : '#cbcbcb'}
111
- width={16}
112
- />
113
- </Circle>
114
- <Circle disabled={disabled} onPress={() => changePosition('right')}>
115
- <OIcon
116
- src={theme.images.general.half_r}
117
- color={state.selected && state.position === 'right' ? theme.colors.primary : '#cbcbcb'}
118
- width={16}
119
- />
120
- </Circle>
121
- </PositionControl>
122
- )
123
- }
75
+ <QuantityControl>
76
+ {option?.allow_suboption_quantity && state?.selected && (
77
+ <>
78
+ <Checkbox disabled={disabled || state.quantity === 0} onPress={decrement}>
79
+ <OIcon
80
+ src={theme.images.general.minus}
81
+ width={16}
82
+ color={state.quantity === 0 || disabled ? theme.colors.disabled : theme.colors.primary}
83
+ />
84
+ </Checkbox>
85
+ <OText size={12} mLeft={5} mRight={5}>
86
+ {state.quantity}
87
+ </OText>
88
+ <Checkbox disabled={disabled || disableIncrement} onPress={increment}>
89
+ <OIcon
90
+ src={theme.images.general.plus}
91
+ width={16}
92
+ color={disableIncrement || disabled ? theme.colors.disabled : theme.colors.primary}
93
+ />
94
+ </Checkbox>
95
+ </>
96
+ )}
97
+ </QuantityControl>
98
+ <PositionControl>
99
+ {option?.with_half_option && state?.selected && (
100
+ <>
101
+ <Circle disabled={disabled} onPress={() => changePosition('left')}>
102
+ <OIcon
103
+ src={theme.images.general.half_l}
104
+ color={state.selected && state.position === 'left' ? theme.colors.primary : '#cbcbcb'}
105
+ width={16}
106
+ style={styles.inverse}
107
+ />
108
+ </Circle>
109
+ <Circle disabled={disabled} onPress={() => changePosition('whole')}>
110
+ <OIcon
111
+ src={theme.images.general.half_f}
112
+ color={state.selected && state.position === 'whole' ? theme.colors.primary : '#cbcbcb'}
113
+ width={16}
114
+ />
115
+ </Circle>
116
+ <Circle disabled={disabled} onPress={() => changePosition('right')}>
117
+ <OIcon
118
+ src={theme.images.general.half_r}
119
+ color={state.selected && state.position === 'right' ? theme.colors.primary : '#cbcbcb'}
120
+ width={16}
121
+ />
122
+ </Circle>
123
+ </>
124
+ )}
125
+ </PositionControl>
124
126
  <OText size={12} lineHeight={18} color={theme.colors.textSecondary}>
125
127
  + {parsePrice(price)}
126
128
  </OText>
@@ -137,7 +139,8 @@ const styles = StyleSheet.create({
137
139
  export const ProductOptionSubOption = (props: any) => {
138
140
  const productOptionSubOptionProps = {
139
141
  ...props,
140
- UIComponent: ProductOptionSubOptionUI
142
+ UIComponent: ProductOptionSubOptionUI,
143
+ isOrigin: true
141
144
  }
142
145
 
143
146
  return (
@@ -5,28 +5,35 @@ export const Container = styled.View`
5
5
  align-items: center;
6
6
  justify-content: space-between;
7
7
  padding: 10px;
8
+ width: 100%;
8
9
  `
9
10
 
10
11
  export const IconControl = styled.TouchableOpacity`
11
12
  flex-direction: row;
12
- flex: 1;
13
+ width: 45%;
13
14
  align-items: center;
14
15
  `
15
16
 
16
17
  export const QuantityControl = styled.View`
17
18
  flex-direction: row;
18
19
  align-items: center;
20
+ justify-content: flex-start;
19
21
  margin-horizontal: 5px;
22
+ flex: 1;
23
+ width: 60px;
24
+
20
25
  `
21
26
 
22
27
  export const PositionControl = styled.View`
23
28
  flex-direction: row;
24
29
  align-items: center;
25
30
  margin-right: 5px;
31
+ flex: 1;
26
32
  `
27
33
 
28
34
  export const Checkbox = styled.TouchableOpacity`
29
35
  `
30
36
 
31
37
  export const Circle = styled.TouchableOpacity`
38
+ margin: 0 1px;
32
39
  `
@@ -7,7 +7,7 @@ import {
7
7
  } from 'ordering-components/native';
8
8
  import { useTheme } from 'styled-components/native';
9
9
  import { SingleProductCardParams } from '../../types';
10
- import { CardContainer, CardInfo, SoldOut, QuantityContainer } from './styles';
10
+ import { CardContainer, CardInfo, SoldOut, QuantityContainer, PricesContainer } from './styles';
11
11
  import { StyleSheet } from 'react-native';
12
12
  import { OText, OIcon } from '../shared';
13
13
  import FastImage from 'react-native-fast-image'
@@ -51,6 +51,13 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
51
51
  textAlign: 'center',
52
52
  borderRadius: 25,
53
53
  alignItems: 'center'
54
+ },
55
+ regularPriceStyle: {
56
+ fontSize: 12,
57
+ color: '#808080',
58
+ textDecorationLine: 'line-through',
59
+ marginLeft: 7,
60
+ marginRight: 7
54
61
  }
55
62
  });
56
63
 
@@ -97,13 +104,13 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
97
104
  (isSoldOut || maxProductQuantity <= 0) && styles.soldOutBackgroundStyle,
98
105
  ]}
99
106
  onPress={() => onProductClick?.(product)}>
100
- {productAddedToCartLength > 0 && (
101
- <QuantityContainer style={[styles.quantityContainer, {
102
- transform: [{ translateX: 10 }, { translateY: -10 }],
103
- }]}>
104
- <OText size={12} color={theme.colors.white}>{productAddedToCartLength.toString()}</OText>
105
- </QuantityContainer>
106
- )}
107
+ {productAddedToCartLength > 0 && (
108
+ <QuantityContainer style={[styles.quantityContainer, {
109
+ transform: [{ translateX: 10 }, { translateY: -10 }],
110
+ }]}>
111
+ <OText size={12} color={theme.colors.white}>{productAddedToCartLength.toString()}</OText>
112
+ </QuantityContainer>
113
+ )}
107
114
  <CardInfo>
108
115
  <OText
109
116
  size={12}
@@ -113,9 +120,12 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
113
120
  style={styles.line18}>
114
121
  {product?.name}
115
122
  </OText>
116
- <OText size={12} weight={'400'} style={styles.line18} color={theme.colors.textNormal}>
117
- {parsePrice(product?.price)}
118
- </OText>
123
+ <PricesContainer>
124
+ <OText color={theme.colors.primary}>{product?.price ? parsePrice(product?.price) : ''}</OText>
125
+ {product?.offer_price !== null && product?.in_offer && (
126
+ <OText style={styles.regularPriceStyle}>{product?.offer_price ? parsePrice(product?.offer_price) : ''}</OText>
127
+ )}
128
+ </PricesContainer>
119
129
  <OText
120
130
  size={10}
121
131
  numberOfLines={2}
@@ -125,14 +135,21 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
125
135
  {product?.description}
126
136
  </OText>
127
137
  </CardInfo>
128
- <FastImage
129
- style={styles.productStyle}
130
- source={{
131
- uri: optimizeImage(product?.images, 'h_75,c_limit'),
132
- priority: FastImage.priority.normal,
133
- }}
134
- resizeMode={FastImage.resizeMode.cover}
135
- />
138
+ {product?.images ? (
139
+ <FastImage
140
+ style={styles.productStyle}
141
+ source={{
142
+ uri: optimizeImage(product?.images, 'h_75,c_limit'),
143
+ priority: FastImage.priority.normal,
144
+ }}
145
+ resizeMode={FastImage.resizeMode.cover}
146
+ />
147
+ ) : (
148
+ <OIcon
149
+ src={theme?.images?.dummies?.product}
150
+ style={styles.productStyle}
151
+ />
152
+ )}
136
153
  {(isSoldOut || maxProductQuantity <= 0) && (
137
154
  <SoldOut>
138
155
  <OText size={12} weight="bold" color={theme.colors.textSecondary} style={styles.soldOutTextStyle}>
@@ -27,3 +27,7 @@ export const QuantityContainer = styled.View`
27
27
  align-items: center;
28
28
  justify-content: center;
29
29
  `
30
+ export const PricesContainer = styled.View`
31
+ flex-direction: row;
32
+ align-items: center;
33
+ `
@@ -37,19 +37,33 @@ const StripeElementsFormUI = (props: any) => {
37
37
  const { top, bottom } = useSafeAreaInsets();
38
38
  const [isKeyboardShow, setIsKeyboardShow] = useState(false);
39
39
 
40
- const billingDetails = {
41
- name: `${user.name} ${user.lastname}`,
42
- email: user.email,
43
- addressLine1: user.address
44
- };
40
+ let billingDetails: any = {}
41
+
42
+ if (user?.name || user?.lastname) {
43
+ if (user?.name) {
44
+ billingDetails.name = user?.name
45
+ }
46
+ if (user?.lastname) {
47
+ billingDetails.name = `${billingDetails?.name} ${user?.lastname}`
48
+ }
49
+ }
50
+
51
+ if (user?.email) {
52
+ billingDetails.email = user?.email
53
+ }
54
+
55
+ if (user?.address) {
56
+ billingDetails.addressLine1 = user?.address
57
+ }
45
58
 
46
59
  const createPayMethod = async () => {
60
+ const params: any = { type: 'Card' }
61
+ if (Object.keys(billingDetails).length > 0) {
62
+ params.billingDetails = billingDetails
63
+ }
47
64
  try {
48
65
  setCreatePmLoading(true)
49
- const { paymentMethod } = await createPaymentMethod({
50
- type: 'Card',
51
- billingDetails,
52
- });
66
+ const { paymentMethod } = await createPaymentMethod(params);
53
67
 
54
68
  setCreatePmLoading(false)
55
69
  handleSource && handleSource({
@@ -79,11 +93,12 @@ const StripeElementsFormUI = (props: any) => {
79
93
  createPayMethod();
80
94
  return
81
95
  }
96
+ const params: any = { type: 'Card' }
97
+ if (Object.keys(billingDetails).length > 0) {
98
+ params.billingDetails = billingDetails
99
+ }
82
100
  try {
83
- const { setupIntent, error } = await confirmSetupIntent(requirements, {
84
- type: 'Card',
85
- billingDetails,
86
- });
101
+ const { setupIntent, error } = await confirmSetupIntent(requirements, params);
87
102
 
88
103
  if (setupIntent?.status === 'Succeeded') {
89
104
  stripeTokenHandler(setupIntent?.paymentMethodId, user, businessId);
@@ -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)) && product?.offers?.find((offer : any) => offer?.name === data?.name)
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
  }