ordering-ui-react-native 0.14.36 → 0.14.38-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 (58) hide show
  1. package/package.json +2 -2
  2. package/src/components/BusinessItemAccordion/index.tsx +2 -2
  3. package/src/components/BusinessProductsListing/index.tsx +10 -26
  4. package/src/components/Cart/index.tsx +136 -62
  5. package/src/components/Cart/styles.tsx +7 -0
  6. package/src/components/Checkout/index.tsx +32 -168
  7. package/src/components/OrderDetails/index.tsx +102 -34
  8. package/src/components/OrderDetails/styles.tsx +7 -0
  9. package/src/components/OrderSummary/index.tsx +142 -58
  10. package/src/components/OrderSummary/styles.tsx +10 -2
  11. package/src/components/PaymentOptions/index.tsx +3 -1
  12. package/src/components/PaymentOptionsWebView/index.tsx +150 -0
  13. package/src/components/ProductForm/index.tsx +6 -8
  14. package/src/components/SingleProductCard/index.tsx +1 -1
  15. package/src/components/StripeElementsForm/index.tsx +28 -13
  16. package/src/components/TaxInformation/index.tsx +58 -26
  17. package/src/components/UpsellingProducts/index.tsx +13 -31
  18. package/src/components/VerifyPhone/styles.tsx +1 -2
  19. package/src/components/shared/OIcon.tsx +4 -1
  20. package/src/index.tsx +2 -0
  21. package/src/navigators/HomeNavigator.tsx +6 -0
  22. package/src/pages/ProductDetails.tsx +55 -0
  23. package/src/types/index.tsx +2 -0
  24. package/src/types/react-native-color-matrix-image-filters/index.d.ts +1 -0
  25. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  26. package/themes/kiosk/src/components/Cart/index.tsx +14 -21
  27. package/themes/kiosk/src/components/CartItem/index.tsx +9 -7
  28. package/themes/kiosk/src/components/CustomerName/index.tsx +2 -1
  29. package/themes/kiosk/src/components/Intro/index.tsx +4 -4
  30. package/themes/kiosk/src/components/OptionCard/index.tsx +11 -6
  31. package/themes/kiosk/src/components/PaymentOptions/index.tsx +46 -44
  32. package/themes/original/index.tsx +4 -0
  33. package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -9
  34. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -2
  35. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +35 -0
  36. package/themes/original/src/components/BusinessProductsListing/index.tsx +22 -49
  37. package/themes/original/src/components/BusinessesListing/index.tsx +100 -75
  38. package/themes/original/src/components/Cart/index.tsx +129 -52
  39. package/themes/original/src/components/Cart/styles.tsx +8 -1
  40. package/themes/original/src/components/Checkout/index.tsx +38 -2
  41. package/themes/original/src/components/Help/index.tsx +1 -1
  42. package/themes/original/src/components/Home/index.tsx +5 -3
  43. package/themes/original/src/components/MessageListing/index.tsx +4 -2
  44. package/themes/original/src/components/OrderDetails/index.tsx +117 -43
  45. package/themes/original/src/components/OrderDetails/styles.tsx +8 -1
  46. package/themes/original/src/components/OrderSummary/index.tsx +141 -51
  47. package/themes/original/src/components/OrderSummary/styles.tsx +7 -0
  48. package/themes/original/src/components/PaymentOptionWallet/index.tsx +6 -2
  49. package/themes/original/src/components/PaymentOptions/index.tsx +8 -2
  50. package/themes/original/src/components/ProductForm/index.tsx +67 -77
  51. package/themes/original/src/components/ProductForm/styles.tsx +9 -2
  52. package/themes/original/src/components/ProductOptionSubOption/index.tsx +3 -2
  53. package/themes/original/src/components/SingleProductCard/index.tsx +21 -11
  54. package/themes/original/src/components/SingleProductCard/styles.tsx +4 -0
  55. package/themes/original/src/components/StripeElementsForm/index.tsx +28 -13
  56. package/themes/original/src/components/TaxInformation/index.tsx +59 -27
  57. package/themes/original/src/components/UpsellingProducts/index.tsx +90 -84
  58. package/themes/original/src/types/index.tsx +6 -0
@@ -37,6 +37,8 @@ const stripeOptions: any = ['stripe_direct', 'stripe', 'stripe_connect']
37
37
  // { name: 'iDEAL', value: 'ideal' }
38
38
  // ]
39
39
 
40
+ const webViewPaymentGateway: any = ['paypal', 'square']
41
+
40
42
  const PaymentOptionsUI = (props: any) => {
41
43
  const {
42
44
  cart,
@@ -49,7 +51,8 @@ const PaymentOptionsUI = (props: any) => {
49
51
  onNavigationRedirect,
50
52
  handlePaymethodClick,
51
53
  handlePaymethodDataChange,
52
- isOpenMethod
54
+ isOpenMethod,
55
+ handlePaymentMethodClickCustom
53
56
  } = props
54
57
 
55
58
  const theme = useTheme();
@@ -90,6 +93,9 @@ const PaymentOptionsUI = (props: any) => {
90
93
 
91
94
  const handlePaymentMethodClick = (paymethod: any) => {
92
95
  const isPopupMethod = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect', 'paypal'].includes(paymethod?.gateway)
96
+ if (webViewPaymentGateway.includes(paymethod?.gateway)) {
97
+ handlePaymentMethodClickCustom(paymethod)
98
+ }
93
99
  handlePaymethodClick(paymethod, isPopupMethod)
94
100
  }
95
101
 
@@ -139,7 +145,7 @@ const PaymentOptionsUI = (props: any) => {
139
145
  )
140
146
  }
141
147
 
142
- const excludeIds: any = [3, 32, 66]; //exclude paypal & connect & redirect
148
+ const excludeIds: any = [32, 66]; //exclude paypal & connect & redirect
143
149
 
144
150
  return (
145
151
  <PMContainer>
@@ -16,10 +16,9 @@ import {
16
16
  Grayscale
17
17
  } from 'react-native-color-matrix-image-filters'
18
18
 
19
- import { View, TouchableOpacity, StyleSheet, Dimensions, Platform, AppRegistry, I18nManager } from 'react-native';
19
+ import { View, TouchableOpacity, StyleSheet, Dimensions, I18nManager, SafeAreaView } from 'react-native';
20
20
 
21
21
  import {
22
- ProductHeader,
23
22
  WrapHeader,
24
23
  TopHeader,
25
24
  WrapContent,
@@ -33,16 +32,15 @@ import {
33
32
  ProductActions,
34
33
  ExtraOptionWrap,
35
34
  WeightUnitSwitch,
36
- WeightUnitItem
35
+ WeightUnitItem,
36
+ TopActions
37
37
  } from './styles';
38
38
  import { OButton, OIcon, OInput, OText } from '../shared';
39
39
  import { ScrollView } from 'react-native-gesture-handler';
40
40
  import { ProductOptionSubOption } from '../ProductOptionSubOption';
41
41
  import { NotFoundSource } from '../NotFoundSource';
42
42
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
43
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
44
43
  import { useState } from 'react';
45
- import { useWindowDimensions } from 'react-native';
46
44
 
47
45
  const windowHeight = Dimensions.get('window').height;
48
46
  const windowWidth = Dimensions.get('window').width;
@@ -63,8 +61,6 @@ export const ProductOptionsUI = (props: any) => {
63
61
  handleChangeSuboptionState,
64
62
  handleChangeCommentState,
65
63
  productObject,
66
- onClose,
67
- isFromCheckout,
68
64
  } = props;
69
65
 
70
66
  const theme = useTheme();
@@ -97,7 +93,7 @@ export const ProductOptionsUI = (props: any) => {
97
93
  },
98
94
  btnBackArrow: {
99
95
  borderWidth: 0,
100
- backgroundColor: 'rgba(0,0,0,0.3)',
96
+ backgroundColor: '#FFF',
101
97
  borderRadius: 24,
102
98
  marginRight: 15,
103
99
  },
@@ -160,15 +156,13 @@ export const ProductOptionsUI = (props: any) => {
160
156
  const [gallery, setGallery] = useState([])
161
157
  const [thumbsSwiper, setThumbsSwiper] = useState(0)
162
158
 
163
- const { top, bottom } = useSafeAreaInsets();
164
- const { height } = useWindowDimensions();
165
159
  const [selOpt, setSelectedOpt] = useState(0);
166
160
  const [isHaveWeight, setIsHaveWeight] = useState(false)
167
161
  const [qtyBy, setQtyBy] = useState({
168
162
  weight_unit: false,
169
163
  pieces: true
170
164
  })
171
- const [pricePerWeightUnit, setPricePerWeightUnit] = useState(null)
165
+ const [pricePerWeightUnit, setPricePerWeightUnit] = useState<any>(null)
172
166
 
173
167
  const swiperRef: any = useRef(null)
174
168
 
@@ -187,10 +181,8 @@ export const ProductOptionsUI = (props: any) => {
187
181
  };
188
182
 
189
183
  const handleSaveProduct = () => {
190
- console.log('----- click handle ------')
191
184
  const isErrors = Object.values(errors).length > 0;
192
185
  if (!isErrors) {
193
- console.log('----- save handle ------')
194
186
  handleSave && handleSave();
195
187
  return;
196
188
  }
@@ -220,8 +212,9 @@ export const ProductOptionsUI = (props: any) => {
220
212
  }
221
213
 
222
214
  const handleRedirectLogin = () => {
223
- onClose();
224
- navigation.navigate('Login');
215
+ navigation.navigate('Login', {
216
+ store_slug: props.businessSlug
217
+ });
225
218
  };
226
219
 
227
220
  const handleSwitchQtyUnit = (val: string) => {
@@ -298,14 +291,16 @@ export const ProductOptionsUI = (props: any) => {
298
291
  </>
299
292
  );
300
293
 
294
+ const handleGoBack = navigation?.canGoBack()
295
+ ? () => navigation.goBack()
296
+ : () => navigation.navigate('Business', { store: props.businessSlug })
297
+
301
298
  return (
302
- <>
299
+ <SafeAreaView style={{ flex: 1 }}>
303
300
  <TopHeader>
304
- <TouchableOpacity
305
- style={styles.headerItem}
306
- onPress={onClose}>
307
- <OIcon src={theme.images.general.close} width={16} />
308
- </TouchableOpacity>
301
+ <TopActions onPress={() => handleGoBack()}>
302
+ <OIcon src={theme.images.general.arrow_left} width={15} />
303
+ </TopActions>
309
304
  </TopHeader>
310
305
  <ScrollView>
311
306
  {!error && (
@@ -356,15 +351,13 @@ export const ProductOptionsUI = (props: any) => {
356
351
  style={styles.slide1}
357
352
  key={i}
358
353
  >
359
- <Grayscale amount={isSoldOut ? 1 : 0}>
360
- <FastImage
361
- style={{ height: '100%' }}
362
- source={{
363
- uri: optimizeImage(img, 'h_258,c_limit'),
364
- priority: FastImage.priority.normal,
365
- }}
366
- />
367
- </Grayscale>
354
+ <FastImage
355
+ style={{ height: '100%', opacity: isSoldOut ? 0.5 : 1 }}
356
+ source={{
357
+ uri: optimizeImage(img, 'h_258,c_limit'),
358
+ priority: FastImage.priority.normal,
359
+ }}
360
+ />
368
361
  </View>
369
362
  ))}
370
363
  </Swiper>
@@ -388,19 +381,18 @@ export const ProductOptionsUI = (props: any) => {
388
381
  opacity: index === thumbsSwiper ? 1 : 0.8
389
382
  }}
390
383
  >
391
- <Grayscale amount={isSoldOut ? 1 : 0}>
392
- <OIcon
393
- url={img}
394
- style={{
395
- borderColor: theme.colors.lightGray,
396
- borderRadius: 8,
397
- minHeight: '100%'
398
- }}
399
- width={56}
400
- height={56}
401
- cover
402
- />
403
- </Grayscale>
384
+ <OIcon
385
+ url={img}
386
+ style={{
387
+ borderColor: theme.colors.lightGray,
388
+ borderRadius: 8,
389
+ minHeight: '100%',
390
+ opacity: isSoldOut ? 0.5 : 1
391
+ }}
392
+ width={56}
393
+ height={56}
394
+ cover
395
+ />
404
396
  </View>
405
397
  </TouchableOpacity>
406
398
 
@@ -432,12 +424,12 @@ export const ProductOptionsUI = (props: any) => {
432
424
  style={{ flex: 1, marginBottom: 10 }}>
433
425
  {product?.name || productCart.name}
434
426
  </OText>
435
- {product?.calories && (
427
+ {!!product?.calories && (
436
428
  <OText size={16} style={{ color: '#808080' }}>{product?.calories} cal
437
429
  </OText>
438
430
  )}
439
431
  </View>
440
- {((product?.sku && product?.sku !== '-1' && product?.sku !== '1') || (product?.estimated_person)) && (
432
+ {((!!product?.sku && product?.sku !== '-1' && product?.sku !== '1') || (!!product?.estimated_person)) && (
441
433
  <OText size={14} style={{ flex: I18nManager.isRTL ? 1 : 0 }} color={'#909BA9'} mBottom={7}>
442
434
  {
443
435
  ((product?.sku && product?.sku !== '-1' && product?.sku !== '1') || (productCart?.sku && productCart?.sku !== '-1' && productCart?.sku !== '1'))
@@ -456,14 +448,14 @@ export const ProductOptionsUI = (props: any) => {
456
448
  ) : (
457
449
  <View style={{ flexDirection: 'row', marginBottom: 10 }}>
458
450
  <OText size={16} style={{ flex: I18nManager.isRTL ? 1 : 0 }} color={theme.colors.primary}>{productCart.price ? parsePrice(productCart.price) : ''}</OText>
459
- {product?.offer_price && (
451
+ {product?.offer_price !== null && product?.in_offer && (
460
452
  <OText style={{
461
453
  fontSize: 14,
462
454
  color: '#808080',
463
455
  textDecorationLine: 'line-through',
464
456
  marginLeft: 7,
465
457
  marginRight: 7
466
- }}>{parsePrice(product?.offer_price)}</OText>
458
+ }}>{product?.offer_price ? parsePrice(product?.offer_price) : ''}</OText>
467
459
  )}
468
460
  </View>
469
461
  )}
@@ -485,7 +477,7 @@ export const ProductOptionsUI = (props: any) => {
485
477
  key={tag.id}
486
478
  style={styles.productTagWrapper}
487
479
  >
488
- {tag?.image ? (
480
+ {!!tag?.image ? (
489
481
  <OIcon
490
482
  url={optimizeImage(tag?.image, 'h_40,c_limit')}
491
483
  style={styles.productTagImageStyle}
@@ -768,16 +760,12 @@ export const ProductOptionsUI = (props: any) => {
768
760
  </WrapContent>
769
761
  </View>
770
762
  )}
771
- {error && error.length > 0 && (
763
+ {!!error && error.length > 0 && (
772
764
  <NotFoundSource content={error[0]?.message || error[0]} />
773
765
  )}
774
766
  </ScrollView>
775
767
  {!loading && !error && product && (
776
- <ProductActions
777
- style={{
778
- paddingBottom: Platform.OS === 'ios' ? bottom + 30 : bottom + 80
779
- }}
780
- >
768
+ <ProductActions>
781
769
  <OText size={16} lineHeight={24} weight={'600'}>
782
770
  {productCart.total ? parsePrice(productCart?.total) : ''}
783
771
  </OText>
@@ -799,7 +787,7 @@ export const ProductOptionsUI = (props: any) => {
799
787
  <OText
800
788
  size={12}
801
789
  lineHeight={18}
802
- style={{ minWidth: 29, textAlign: 'center' }}
790
+ style={{ minWidth: 40, textAlign: 'center' }}
803
791
  >
804
792
  {qtyBy?.pieces && productCart.quantity}
805
793
  {qtyBy?.weight_unit && productCart.quantity * product?.weight}
@@ -823,36 +811,38 @@ export const ProductOptionsUI = (props: any) => {
823
811
  }
824
812
  />
825
813
  </TouchableOpacity>
826
- <WeightUnitSwitch>
827
- <TouchableOpacity
828
- onPress={() => handleSwitchQtyUnit('pieces')}
829
- >
830
- <WeightUnitItem active={qtyBy?.pieces}>
831
- <OText
832
- size={12}
833
- lineHeight={18}
834
- color={qtyBy?.pieces ? theme.colors.primary : theme.colors.textNormal}
835
- >
836
- {t('PIECES', 'pieces')}
837
- </OText>
838
- </WeightUnitItem>
839
- </TouchableOpacity>
840
- <View style={{ alignItems: 'flex-start' }}>
814
+ {isHaveWeight && (
815
+ <WeightUnitSwitch>
841
816
  <TouchableOpacity
842
- onPress={() => handleSwitchQtyUnit('weight_unit')}
817
+ onPress={() => handleSwitchQtyUnit('pieces')}
843
818
  >
844
- <WeightUnitItem active={qtyBy?.weight_unit}>
819
+ <WeightUnitItem active={qtyBy?.pieces}>
845
820
  <OText
846
821
  size={12}
847
822
  lineHeight={18}
848
- color={qtyBy?.weight_unit ? theme.colors.primary : theme.colors.textNormal}
823
+ color={qtyBy?.pieces ? theme.colors.primary : theme.colors.textNormal}
849
824
  >
850
- {product?.weight_unit}
825
+ {t('PIECES', 'pcs')}
851
826
  </OText>
852
827
  </WeightUnitItem>
853
828
  </TouchableOpacity>
854
- </View>
855
- </WeightUnitSwitch>
829
+ <View style={{ alignItems: 'flex-start' }}>
830
+ <TouchableOpacity
831
+ onPress={() => handleSwitchQtyUnit('weight_unit')}
832
+ >
833
+ <WeightUnitItem active={qtyBy?.weight_unit}>
834
+ <OText
835
+ size={12}
836
+ lineHeight={18}
837
+ color={qtyBy?.weight_unit ? theme.colors.primary : theme.colors.textNormal}
838
+ >
839
+ {product?.weight_unit}
840
+ </OText>
841
+ </WeightUnitItem>
842
+ </TouchableOpacity>
843
+ </View>
844
+ </WeightUnitSwitch>
845
+ )}
856
846
  </View>
857
847
  )}
858
848
  <View
@@ -921,7 +911,7 @@ export const ProductOptionsUI = (props: any) => {
921
911
  </View>
922
912
  </ProductActions>
923
913
  )}
924
- </>
914
+ </SafeAreaView>
925
915
  );
926
916
  };
927
917
 
@@ -5,13 +5,20 @@ export const WrapHeader = styled.View`
5
5
  z-index: 1;
6
6
  `
7
7
 
8
+ export const TopActions = styled.TouchableOpacity`
9
+ height: 44px;
10
+ justify-content: center;
11
+ padding-horizontal: 30px;
12
+ `;
13
+
8
14
  export const TopHeader = styled.View`
9
15
  width: 100%;
10
16
  flex-direction: row;
11
17
  align-items: center;
12
18
  justify-content: space-between;
13
19
  z-index: 1;
14
- padding-horizontal: 40px;
20
+ height: 60px;
21
+ min-height: 60px;
15
22
  `
16
23
 
17
24
  export const ProductHeader = styled.ImageBackground`
@@ -89,4 +96,4 @@ export const WeightUnitItem = styled.View`
89
96
  ${({ active }: any) => active && css`
90
97
  background-color: ${(props: any) => props.theme.colors.primary}20;
91
98
  `}
92
- `
99
+ `
@@ -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'
@@ -137,7 +137,8 @@ const styles = StyleSheet.create({
137
137
  export const ProductOptionSubOption = (props: any) => {
138
138
  const productOptionSubOptionProps = {
139
139
  ...props,
140
- UIComponent: ProductOptionSubOptionUI
140
+ UIComponent: ProductOptionSubOptionUI,
141
+ isOrigin: true
141
142
  }
142
143
 
143
144
  return (
@@ -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}
@@ -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
  }