ordering-ui-react-native 0.15.16 → 0.15.18-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 (154) hide show
  1. package/package.json +5 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessTypeFilter/index.tsx +12 -2
  4. package/src/components/BusinessTypeFilter/styles.tsx +1 -1
  5. package/src/components/BusinessesListing/index.tsx +1 -1
  6. package/src/components/Checkout/index.tsx +0 -1
  7. package/src/components/LanguageSelector/index.tsx +1 -0
  8. package/src/components/OrderDetails/index.tsx +26 -5
  9. package/src/components/PaymentOptions/index.tsx +9 -16
  10. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  11. package/src/components/ProductForm/index.tsx +1 -1
  12. package/src/components/ProductForm/styles.tsx +1 -0
  13. package/src/components/StripeElementsForm/index.tsx +27 -48
  14. package/src/components/VerifyPhone/styles.tsx +1 -2
  15. package/src/config.json +0 -2
  16. package/src/navigators/HomeNavigator.tsx +6 -0
  17. package/src/pages/BusinessProductsList.tsx +1 -0
  18. package/src/pages/BusinessesListing.tsx +1 -1
  19. package/src/pages/Checkout.tsx +1 -1
  20. package/src/pages/Sessions.tsx +22 -0
  21. package/src/types/index.tsx +1 -9
  22. package/src/utils/index.tsx +68 -1
  23. package/themes/business/index.tsx +2 -0
  24. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +56 -8
  25. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +5 -0
  26. package/themes/business/src/components/Chat/index.tsx +38 -86
  27. package/themes/business/src/components/Home/index.tsx +128 -55
  28. package/themes/business/src/components/Home/styles.tsx +8 -1
  29. package/themes/business/src/components/NewOrderNotification/index.tsx +59 -98
  30. package/themes/business/src/components/OrderDetails/Business.tsx +2 -1
  31. package/themes/business/src/components/OrderDetails/Delivery.tsx +22 -13
  32. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +150 -89
  33. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +91 -17
  34. package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
  35. package/themes/business/src/components/OrdersListManager/index.tsx +874 -0
  36. package/themes/business/src/components/OrdersListManager/styles.tsx +123 -0
  37. package/themes/business/src/components/OrdersListManager/utils.tsx +216 -0
  38. package/themes/business/src/components/OrdersOption/index.tsx +54 -49
  39. package/themes/business/src/components/PreviousOrders/index.tsx +82 -23
  40. package/themes/business/src/types/index.tsx +2 -1
  41. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  42. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  43. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  44. package/themes/kiosk/src/components/BusinessController/index.tsx +27 -6
  45. package/themes/kiosk/src/components/BusinessController/styles.tsx +1 -1
  46. package/themes/kiosk/src/components/BusinessProductsListing/index.tsx +48 -21
  47. package/themes/kiosk/src/components/Cart/index.tsx +98 -24
  48. package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
  49. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +1 -1
  50. package/themes/kiosk/src/components/CartBottomSheet/styles.tsx +1 -1
  51. package/themes/kiosk/src/components/CartContent/index.tsx +13 -3
  52. package/themes/kiosk/src/components/CartItem/index.tsx +20 -8
  53. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +6 -5
  54. package/themes/kiosk/src/components/CustomerName/index.tsx +89 -88
  55. package/themes/kiosk/src/components/Intro/index.tsx +13 -13
  56. package/themes/kiosk/src/components/LanguageSelector/index.tsx +12 -8
  57. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  58. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  59. package/themes/kiosk/src/components/OrderDetails/index.tsx +136 -41
  60. package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
  61. package/themes/kiosk/src/components/OrderSummary/index.tsx +1 -1
  62. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
  63. package/themes/kiosk/src/components/ProductForm/index.tsx +174 -125
  64. package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
  65. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -0
  66. package/themes/kiosk/src/components/ProductOption/styles.tsx +1 -0
  67. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +48 -34
  68. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  69. package/themes/kiosk/src/components/shared/OCard.tsx +112 -78
  70. package/themes/kiosk/src/types/index.d.ts +2 -0
  71. package/themes/original/index.tsx +179 -0
  72. package/themes/original/src/components/AddressForm/index.tsx +15 -10
  73. package/themes/original/src/components/AddressList/index.tsx +56 -18
  74. package/themes/original/src/components/AppleLogin/index.tsx +117 -78
  75. package/themes/original/src/components/BusinessBasicInformation/index.tsx +96 -45
  76. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
  77. package/themes/original/src/components/BusinessController/index.tsx +52 -22
  78. package/themes/original/src/components/BusinessController/styles.tsx +22 -0
  79. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  80. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  81. package/themes/original/src/components/BusinessListingSearch/index.tsx +4 -0
  82. package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
  83. package/themes/original/src/components/BusinessPreorder/index.tsx +141 -121
  84. package/themes/original/src/components/BusinessProductsCategories/index.tsx +7 -5
  85. package/themes/original/src/components/BusinessProductsList/index.tsx +129 -22
  86. package/themes/original/src/components/BusinessProductsList/styles.tsx +29 -2
  87. package/themes/original/src/components/BusinessProductsListing/index.tsx +92 -37
  88. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
  89. package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
  90. package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
  91. package/themes/original/src/components/BusinessesListing/index.tsx +49 -58
  92. package/themes/original/src/components/Cart/index.tsx +58 -21
  93. package/themes/original/src/components/CartContent/index.tsx +2 -2
  94. package/themes/original/src/components/Checkout/index.tsx +57 -33
  95. package/themes/original/src/components/CouponControl/index.tsx +1 -0
  96. package/themes/original/src/components/DriverTips/index.tsx +1 -1
  97. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  98. package/themes/original/src/components/Help/index.tsx +21 -4
  99. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +97 -89
  100. package/themes/original/src/components/Home/index.tsx +1 -1
  101. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  102. package/themes/original/src/components/LoginForm/index.tsx +73 -2
  103. package/themes/original/src/components/LoginForm/styles.tsx +6 -1
  104. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  105. package/themes/original/src/components/Messages/index.tsx +50 -45
  106. package/themes/original/src/components/Messages/styles.tsx +1 -3
  107. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  108. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  109. package/themes/original/src/components/OrderDetails/index.tsx +119 -127
  110. package/themes/original/src/components/OrderDetails/styles.tsx +3 -1
  111. package/themes/original/src/components/OrderProgress/index.tsx +4 -4
  112. package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
  113. package/themes/original/src/components/OrderSummary/index.tsx +35 -2
  114. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  115. package/themes/original/src/components/OrdersOption/index.tsx +25 -33
  116. package/themes/original/src/components/OrdersOption/styles.tsx +0 -6
  117. package/themes/original/src/components/PaymentOptionWallet/index.tsx +10 -4
  118. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  119. package/themes/original/src/components/PaymentOptions/index.tsx +9 -19
  120. package/themes/original/src/components/PlaceSpot/index.tsx +114 -0
  121. package/themes/original/src/components/PlaceSpot/styles.tsx +11 -0
  122. package/themes/original/src/components/PreviousOrders/index.tsx +19 -13
  123. package/themes/original/src/components/ProductForm/index.tsx +40 -35
  124. package/themes/original/src/components/ProductForm/styles.tsx +2 -2
  125. package/themes/original/src/components/ProductOptionSubOption/index.tsx +5 -3
  126. package/themes/original/src/components/Promotions/index.tsx +250 -0
  127. package/themes/original/src/components/Promotions/styles.tsx +60 -0
  128. package/themes/original/src/components/ReviewOrder/index.tsx +10 -9
  129. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  130. package/themes/original/src/components/Sessions/index.tsx +160 -0
  131. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  132. package/themes/original/src/components/SingleProductCard/index.tsx +47 -21
  133. package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
  134. package/themes/original/src/components/StripeElementsForm/index.tsx +55 -72
  135. package/themes/original/src/components/TaxInformation/index.tsx +17 -7
  136. package/themes/original/src/components/UpsellingProducts/index.tsx +87 -71
  137. package/themes/original/src/components/UserDetails/index.tsx +4 -95
  138. package/themes/original/src/components/UserFormDetails/index.tsx +32 -31
  139. package/themes/original/src/components/UserProfile/index.tsx +70 -20
  140. package/themes/original/src/components/UserProfileForm/index.tsx +28 -24
  141. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  142. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  143. package/themes/original/src/components/Wallets/index.tsx +75 -8
  144. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  145. package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
  146. package/themes/original/src/components/shared/index.tsx +2 -0
  147. package/themes/original/src/config/constants.tsx +6 -6
  148. package/themes/original/src/types/index.tsx +79 -25
  149. package/themes/original/src/utils/index.tsx +12 -2
  150. package/themes/single-business/src/components/AddressList/index.tsx +1 -1
  151. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +6 -6
  152. package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
  153. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  154. package/src/components/StripeMethodForm/index.tsx +0 -168
@@ -0,0 +1,160 @@
1
+ import React, { useState } from 'react'
2
+ import { View, TouchableOpacity } from 'react-native'
3
+ import { useLanguage, useSession, useUtils, Sessions as SessionsController } from 'ordering-components/native'
4
+ import NavBar from '../NavBar'
5
+ import { SessionsParams } from '../../types'
6
+ import { OAlert } from '../../../../../src/components/shared'
7
+ import { OButton, OIcon, OText } from '../shared'
8
+ import { useTheme } from 'styled-components/native'
9
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder'
10
+ import AntIcon from 'react-native-vector-icons/AntDesign'
11
+
12
+ import {
13
+ SessionsWrapper,
14
+ SessionItem,
15
+ DurationWrapper
16
+ } from './styles'
17
+
18
+ export const SessionsUI = (props: SessionsParams) => {
19
+ const {
20
+ navigation,
21
+ sessionsList,
22
+ actionState,
23
+ handleDeleteSession,
24
+ handleDeleteAllSessions
25
+ } = props
26
+
27
+ const [, t] = useLanguage()
28
+ const [{ user }] = useSession()
29
+ const [{ parseDate }] = useUtils()
30
+ const theme = useTheme()
31
+ const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
32
+ const goToBack = () => navigation?.canGoBack() && navigation.goBack()
33
+
34
+ const onDeleteSession = (session: any) => {
35
+ setConfirm({
36
+ open: true,
37
+ title: t('WEB_APPNAME', 'Ordering'),
38
+ content: [t('QUESTION_DELETE_SESSION', 'Are you sure to delete this session?')],
39
+ handleOnAccept: () => {
40
+ handleDeleteSession(session)
41
+ setConfirm({ ...confirm, open: false })
42
+ }
43
+ })
44
+ }
45
+
46
+ const onDeleteAllSessions = (isOldUser: any, deleteCurrent: any) => {
47
+ setConfirm({
48
+ open: true,
49
+ title: t('WEB_APPNAME', 'Ordering'),
50
+ content:
51
+ isOldUser
52
+ ? [t('QUESTION_ENABLE_ALL_SESSIONS', 'Are you sure to enable all sessions?')]
53
+ : deleteCurrent
54
+ ? [t('QUESTION_DELETE_ALL_SESSIONS', 'Are you sure that you want to delete all sessions?')]
55
+ : [t('QUESTION_DELETE_ALL_SESSIONS_EXCEPT_CURRENT', 'Are you sure that you want to delete all sessions except current?')],
56
+ handleOnAccept: () => {
57
+ handleDeleteAllSessions(deleteCurrent)
58
+ setConfirm({ ...confirm, open: false })
59
+ }
60
+ })
61
+ }
62
+
63
+ return (
64
+ <>
65
+ <NavBar
66
+ title={t('SESSIONS', 'Sessions')}
67
+ titleAlign={'center'}
68
+ onActionLeft={goToBack}
69
+ showCall={false}
70
+ paddingTop={10}
71
+ btnStyle={{ paddingLeft: 0 }}
72
+ />
73
+ {user?.session_strategy === 'jwt_session' ? (
74
+ <>
75
+ {sessionsList.loading ? (
76
+ [...Array(5).keys()].map(i => (
77
+ <SessionItem key={i}>
78
+ <Placeholder Animation={Fade}>
79
+ <View style={{ flexDirection: 'row', alignItems: 'center' }}>
80
+ <View style={{ flex: 1}}>
81
+ <PlaceholderLine width={40} />
82
+ <PlaceholderLine width={40} />
83
+ </View>
84
+ <PlaceholderLine width={5}/>
85
+ </View>
86
+ </Placeholder>
87
+ </SessionItem>
88
+ ))
89
+ ) : (
90
+ sessionsList.sessions.length > 0 ? (
91
+ <SessionsWrapper>
92
+ {sessionsList.sessions.map((session: any) => (
93
+ <SessionItem key={session.id}>
94
+ <DurationWrapper>
95
+ <OText>{parseDate(session.created_at)}</OText>
96
+ <OText>{parseDate(session.valid_thru)}</OText>
97
+ </DurationWrapper>
98
+ {session.current && (
99
+ <OText mLeft={15} style={{ flex: 1 }}>({t('CURRENT', 'Current')})</OText>
100
+ )}
101
+ <TouchableOpacity
102
+ onPress={() => onDeleteSession(session)}
103
+ >
104
+ <AntIcon name='close' size={16} color={theme.colors.red} />
105
+ </TouchableOpacity>
106
+ </SessionItem>
107
+ ))}
108
+ <OButton
109
+ text={t('DELETE_ALL_SESSIONS', 'Delete all sessions')}
110
+ isDisabled={actionState.loading}
111
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
112
+ onClick={() => onDeleteAllSessions(false, true)}
113
+ style={{ borderRadius: 7.6, marginTop: 30 }}
114
+ />
115
+ <OButton
116
+ text={t('DELETE_ALL_SESSIONS_EXCEPT_CURRENT', 'Delete all sessions except current')}
117
+ isDisabled={actionState.loading}
118
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
119
+ onClick={() => onDeleteAllSessions(false, false)}
120
+ style={{ borderRadius: 7.6, marginTop: 20 }}
121
+ />
122
+ </SessionsWrapper>
123
+ ) : (
124
+ <OText>{t('YOU_DONT_HAVE_ANY_SESSIONS', 'You don\'t have any sessions')}</OText>
125
+ )
126
+ )}
127
+ </>
128
+ ) : (
129
+ <View>
130
+ <OText>
131
+ {t('YOU_DONT_HAVE_ENABLED_THE_SESSIONS', 'You don\'t have enabled the sessions, please active them to have a better control of your sessions.')}
132
+ </OText>
133
+ <OButton
134
+ text={t('ACTIVE_SESSIONS', 'Active sessions')}
135
+ isDisabled={actionState.loading}
136
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
137
+ onClick={() => onDeleteAllSessions(true, false)}
138
+ style={{ borderRadius: 7.6, marginTop: 20 }}
139
+ />
140
+ </View>
141
+ )}
142
+ <OAlert
143
+ open={confirm.open}
144
+ title={confirm.title}
145
+ content={confirm.content}
146
+ onAccept={confirm.handleOnAccept}
147
+ onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
148
+ onClose={() => setConfirm({ ...confirm, open: false, title: null })}
149
+ />
150
+ </>
151
+ )
152
+ }
153
+
154
+ export const Sessions = (props: SessionsParams) => {
155
+ const sessionsProps = {
156
+ ...props,
157
+ UIComponent: SessionsUI
158
+ }
159
+ return <SessionsController {...sessionsProps} />
160
+ }
@@ -0,0 +1,15 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const SessionsWrapper = styled.View`
4
+ `
5
+ export const SessionItem = styled.View`
6
+ flex-direction: row;
7
+ align-items: center;
8
+ justify-content: space-between;
9
+ padding-vertical: 15px;
10
+ border-bottom-color: ${(props: any) => props.theme.colors.lightGray};
11
+ border-bottom-width: 1px;
12
+ `
13
+ export const DurationWrapper = styled.View`
14
+ /* flex-direction: row; */
15
+ `
@@ -7,14 +7,20 @@ 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, PricesContainer } from './styles';
10
+ import { CardContainer, CardInfo, SoldOut, QuantityContainer, PricesContainer, RibbonBox, LogoWrapper } 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'
14
+ import { shape } from '../../utils';
14
15
 
15
- export const SingleProductCard = (props: SingleProductCardParams) => {
16
+ function SingleProductCardPropsAreEqual(prevProps : any, nextProps : any) {
17
+ return JSON.stringify(prevProps.product) === JSON.stringify(nextProps.product) &&
18
+ prevProps.isSoldOut === nextProps.isSoldOut &&
19
+ prevProps.productAddedToCartLength === nextProps.productAddedToCartLength
20
+ }
21
+
22
+ export const SingleProductCard = React.memo((props: SingleProductCardParams) => {
16
23
  const {
17
- businessId,
18
24
  product,
19
25
  isSoldOut,
20
26
  onProductClick,
@@ -46,8 +52,7 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
46
52
  productStyle: {
47
53
  width: 75,
48
54
  height: 75,
49
- borderRadius: 7.6,
50
- marginStart: 12
55
+ borderRadius: 7.6
51
56
  },
52
57
  quantityContainer: {
53
58
  position: 'absolute',
@@ -136,21 +141,42 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
136
141
  {product?.description}
137
142
  </OText>
138
143
  </CardInfo>
139
- {product?.images ? (
140
- <FastImage
141
- style={styles.productStyle}
142
- source={{
143
- uri: optimizeImage(product?.images, 'h_250,c_limit'),
144
- priority: FastImage.priority.normal,
145
- }}
146
- resizeMode={FastImage.resizeMode.cover}
147
- />
148
- ) : (
149
- <OIcon
150
- src={theme?.images?.dummies?.product}
151
- style={styles.productStyle}
152
- />
153
- )}
144
+ <LogoWrapper>
145
+ {product?.ribbon?.enabled && (
146
+ <RibbonBox
147
+ bgColor={product?.ribbon?.color}
148
+ isRoundRect={product?.ribbon?.shape === shape?.rectangleRound}
149
+ isCapsule={product?.ribbon?.shape === shape?.capsuleShape}
150
+ >
151
+ <OText
152
+ size={10}
153
+ weight={'400'}
154
+ color={theme.colors.white}
155
+ numberOfLines={2}
156
+ ellipsizeMode='tail'
157
+ lineHeight={13}
158
+ >
159
+ {product?.ribbon?.text}
160
+ </OText>
161
+ </RibbonBox>
162
+ )}
163
+ {product?.images ? (
164
+ <FastImage
165
+ style={styles.productStyle}
166
+ source={{
167
+ uri: optimizeImage(product?.images, 'h_250,c_limit'),
168
+ priority: FastImage.priority.normal,
169
+ }}
170
+ resizeMode={FastImage.resizeMode.cover}
171
+ />
172
+ ) : (
173
+ <OIcon
174
+ src={theme?.images?.dummies?.product}
175
+ style={styles.productStyle}
176
+ />
177
+ )}
178
+ </LogoWrapper>
179
+
154
180
  {(isSoldOut || maxProductQuantity <= 0) && (
155
181
  <SoldOut>
156
182
  <OText size={12} weight="bold" color={theme.colors.textSecondary} style={styles.soldOutTextStyle}>
@@ -160,4 +186,4 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
160
186
  )}
161
187
  </CardContainer>
162
188
  );
163
- };
189
+ }, SingleProductCardPropsAreEqual);
@@ -1,4 +1,4 @@
1
- import styled from 'styled-components/native'
1
+ import styled, { css } from 'styled-components/native'
2
2
 
3
3
  export const CardContainer = styled.TouchableOpacity`
4
4
  flex: 1;
@@ -31,3 +31,30 @@ export const PricesContainer = styled.View`
31
31
  flex-direction: row;
32
32
  align-items: center;
33
33
  `
34
+
35
+ export const LogoWrapper = styled.View`
36
+ position: relative;
37
+ margin-left: 12px;
38
+ `
39
+
40
+ export const RibbonBox = styled.View`
41
+ position: absolute;
42
+ z-index: 1;
43
+ top: -4px;
44
+ right: -4px;
45
+ background-color: ${(props: any) => props.theme.colors.primary};
46
+ padding: 1px 8px;
47
+ max-width: 60px;
48
+
49
+ ${(props: any) => props.bgColor && css`
50
+ background-color: ${props.bgColor};
51
+ `}
52
+
53
+ ${(props: any) => props.isRoundRect && css`
54
+ border-radius: 7.6px;
55
+ `}
56
+
57
+ ${(props: any) => props.isCapsule && css`
58
+ border-radius: 50px;
59
+ `}
60
+ `
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useEffect } from 'react';
2
2
  import { View, StyleSheet, useWindowDimensions, Keyboard } from 'react-native';
3
- import { useLanguage, useSession, useConfig } from 'ordering-components/native';
3
+ import { useLanguage, useSession } from 'ordering-components/native';
4
4
  import {
5
5
  StripeProvider,
6
6
  CardField,
@@ -13,7 +13,6 @@ import { ErrorMessage } from './styles';
13
13
  import { StripeElementsForm as StripeFormController } from './naked';
14
14
  import { OButton, OText } from '../shared';
15
15
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
16
- import { StripeMethodForm } from '../../../../../src/components/StripeMethodForm';
17
16
 
18
17
  const StripeElementsFormUI = (props: any) => {
19
18
  const {
@@ -23,17 +22,12 @@ const StripeElementsFormUI = (props: any) => {
23
22
  businessId,
24
23
  requirements,
25
24
  stripeTokenHandler,
26
- methodsPay,
27
- paymethod,
28
- onCancel,
29
- cart,
30
25
  } = props;
31
26
 
32
27
  const theme = useTheme();
33
28
 
34
29
  const [, t] = useLanguage();
35
30
  const [{ user }] = useSession();
36
- const [{ configs }] = useConfig();
37
31
  const [card, setCard] = useState<any>(null);
38
32
  const [isCompleted, setIsCompleted] = useState(false);
39
33
  const [errors, setErrors] = useState('')
@@ -43,30 +37,30 @@ const StripeElementsFormUI = (props: any) => {
43
37
  const { top, bottom } = useSafeAreaInsets();
44
38
  const [isKeyboardShow, setIsKeyboardShow] = useState(false);
45
39
 
46
- let billingDetails: any = {}
40
+ let billingDetails: any = {}
47
41
 
48
- if (user?.name || user?.lastname) {
49
- if (user?.name) {
50
- billingDetails.name = user?.name
51
- }
52
- if (user?.lastname) {
53
- billingDetails.name = `${billingDetails?.name} ${user?.lastname}`
54
- }
55
- }
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
+ }
56
50
 
57
- if (user?.email) {
58
- billingDetails.email = user?.email
59
- }
51
+ if (user?.email) {
52
+ billingDetails.email = user?.email
53
+ }
60
54
 
61
- if (user?.address) {
62
- billingDetails.addressLine1 = user?.address
63
- }
55
+ if (user?.address) {
56
+ billingDetails.addressLine1 = user?.address
57
+ }
64
58
 
65
59
  const createPayMethod = async () => {
66
- const params: any = { type: 'Card' }
67
- if (Object.keys(billingDetails).length > 0) {
68
- params.billingDetails = billingDetails
69
- }
60
+ const params: any = { type: 'Card' }
61
+ if (Object.keys(billingDetails).length > 0) {
62
+ params.billingDetails = billingDetails
63
+ }
70
64
  try {
71
65
  setCreatePmLoading(true)
72
66
  const { paymentMethod } = await createPaymentMethod(params);
@@ -99,10 +93,10 @@ const StripeElementsFormUI = (props: any) => {
99
93
  createPayMethod();
100
94
  return
101
95
  }
102
- const params: any = { type: 'Card' }
103
- if (Object.keys(billingDetails).length > 0) {
104
- params.billingDetails = billingDetails
105
- }
96
+ const params: any = { type: 'Card' }
97
+ if (Object.keys(billingDetails).length > 0) {
98
+ params.billingDetails = billingDetails
99
+ }
106
100
  try {
107
101
  const { setupIntent, error } = await confirmSetupIntent(requirements, params);
108
102
 
@@ -158,35 +152,27 @@ const StripeElementsFormUI = (props: any) => {
158
152
  <View style={{ ...styles.container, height: height - top - bottom - 60 - (isKeyboardShow ? 250 : 0) }}>
159
153
  {publicKey ? (
160
154
  <View style={{ flex: 1 }}>
161
- <StripeProvider
162
- publishableKey={publicKey}
163
- merchantIdentifier={`merchant.${configs.apple_app_id}`}
164
- >
165
- {methodsPay?.includes(paymethod) ? (
166
- <StripeMethodForm
167
- handleSource={handleSource}
168
- onCancel={onCancel}
169
- cart={cart}
170
- setErrors={setErrors}
171
- paymethod={paymethod}
172
- devMode={publicKey?.includes('test')}
173
- />
174
- ) : (
175
- <CardField
176
- postalCodeEnabled={true}
177
- cardStyle={{
178
- backgroundColor: '#FFFFFF',
179
- textColor: '#000000',
180
- }}
181
- style={{
182
- width: '100%',
183
- height: 50,
184
- marginVertical: 30,
185
- zIndex: 9999,
186
- }}
187
- onCardChange={(cardDetails: any) => setCard(cardDetails)}
188
- />
189
- )}
155
+ <StripeProvider publishableKey={publicKey}>
156
+ <CardField
157
+ postalCodeEnabled={false}
158
+ cardStyle={{
159
+ backgroundColor: '#FFFFFF',
160
+ textColor: '#000000',
161
+ fontSize: 17,
162
+ styles: {
163
+
164
+ }
165
+ }}
166
+ style={{
167
+ width: '100%',
168
+ height: 50,
169
+ marginVertical: 50,
170
+ borderWidth: 1,
171
+ borderColor: theme.colors.border,
172
+ borderRadius: 7.6,
173
+ }}
174
+ onCardChange={(cardDetails: any) => setCard(cardDetails)}
175
+ />
190
176
  </StripeProvider>
191
177
  {!!errors && (
192
178
  <ErrorMessage>
@@ -211,19 +197,16 @@ const StripeElementsFormUI = (props: any) => {
211
197
  </OText>
212
198
  </ErrorMessage>
213
199
  )}
214
- {!methodsPay?.includes(paymethod) && (
215
- <OButton
216
- text={t('SAVE_CARD', 'Save card')}
217
- bgColor={isCompleted ? theme.colors.primary : theme.colors.backgroundGray}
218
- borderColor={isCompleted ? theme.colors.primary : theme.colors.backgroundGray}
219
- style={styles.btnAddStyle}
220
- textStyle={{ color: 'white' }}
221
- imgRightSrc={null}
222
- onClick={() => handleSaveCard()}
223
- isDisabled={!isCompleted}
224
- isLoading={confirmSetupLoading || values.loadingAdd || createPmLoading}
225
- />
226
- )}
200
+ <OButton
201
+ text={t('SAVE_CARD', 'Save card')}
202
+ bgColor={isCompleted ? theme.colors.primary : theme.colors.backgroundGray}
203
+ borderColor={isCompleted ? theme.colors.primary : theme.colors.backgroundGray}
204
+ style={styles.btnAddStyle}
205
+ textStyle={{ color: 'white', fontSize: 14 }}
206
+ imgRightSrc={null}
207
+ onClick={isCompleted ? () => handleSaveCard() : () => { }}
208
+ isLoading={confirmSetupLoading || values.loadingAdd || createPmLoading}
209
+ />
227
210
  </View>
228
211
  )
229
212
  }
@@ -1,5 +1,5 @@
1
- import React, { Mixin } from 'react'
2
- import { useLanguage } from 'ordering-components/native'
1
+ import React from 'react'
2
+ import { useLanguage, useUtils } from 'ordering-components/native'
3
3
  import { SingleProductCard } from '../SingleProductCard'
4
4
  import { TaxInformationContainer, ProductContainer } from './styles'
5
5
  import { OText } from '../shared'
@@ -9,12 +9,13 @@ interface taxInformationParams {
9
9
  name: string,
10
10
  description?: string,
11
11
  rate: string | number,
12
- type: number,
12
+ type: string | number,
13
13
  fixed?: number,
14
14
  percentage?: number,
15
15
  id: number,
16
- discounts?: any
17
- } | null,
16
+ discounts?: any,
17
+ rate_type?: number
18
+ },
18
19
  products: Array<any>,
19
20
  type: string
20
21
  }
@@ -27,8 +28,13 @@ export const TaxInformation = (props: taxInformationParams) => {
27
28
  } = props
28
29
 
29
30
  const [, t] = useLanguage()
31
+ const [{ parsePrice }] = useUtils()
30
32
 
31
33
  const includedOnPriceString = data?.type === 1 ? `(${t('INCLUDED_ON_PRICE', 'Included on price')})` : `(${t('NOT_INCLUDED_ON_PRICE', 'Not included on price')})`
34
+ const offersHideArray = ['offer_target_2', 'offer_target_3']
35
+ const hideProductsSectionOffers = offersHideArray.includes(type)
36
+ const dataHideArray : Array<string | number> = ['platform', 'business']
37
+ const hideProductsSectionData = dataHideArray.includes(data.type)
32
38
 
33
39
  const getFilterValidation = (product: any) => {
34
40
  return (
@@ -52,8 +58,12 @@ export const TaxInformation = (props: taxInformationParams) => {
52
58
 
53
59
  return (
54
60
  <TaxInformationContainer>
61
+ <OText size={24} style={{ alignSelf: 'center', textAlign: 'center' }} mBottom={10}>
62
+ {`${data?.name ||
63
+ t('INHERIT_FROM_BUSINESS', 'Inherit from business')} ${data?.rate_type !== 2 ? `(${typeof data?.rate === 'number' ? `${data?.rate}%` : `${parsePrice(data?.fixed ?? 0)} + ${data?.percentage}%`})` : ''} `}
64
+ </OText>
55
65
  {!!data?.description ? (
56
- <OText size={24} style={{ alignSelf: 'center', textAlign: 'center' }} mBottom={10}>
66
+ <OText size={20} style={{ alignSelf: 'center', textAlign: 'center' }} mBottom={10}>
57
67
  {t('DESCRIPTION', 'Description')}: {data?.description} {data?.type && !type?.includes('offer') && includedOnPriceString}
58
68
  </OText>
59
69
  ) : (
@@ -61,7 +71,7 @@ export const TaxInformation = (props: taxInformationParams) => {
61
71
  {t('WITHOUT_DESCRIPTION', 'Without description')}
62
72
  </OText>
63
73
  )}
64
- {!(type === 'offer_target_2' || type === 'offer_target_3') && (
74
+ {!hideProductsSectionOffers && !hideProductsSectionData && (
65
75
  <>
66
76
  <OText>{t('OTHER_PRODUCTS_WITH_THIS', 'Other products with this')} {getTypeString()}:</OText>
67
77
  <ProductContainer>