ordering-ui-react-native 0.15.24 → 0.15.26-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.
- package/package.json +5 -3
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/BusinessController/index.tsx +8 -2
- package/src/components/BusinessTypeFilter/index.tsx +12 -2
- package/src/components/BusinessTypeFilter/styles.tsx +1 -1
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Checkout/index.tsx +0 -1
- package/src/components/LanguageSelector/index.tsx +7 -2
- package/src/components/OrderDetails/index.tsx +2 -2
- package/src/components/PaymentOptions/index.tsx +9 -16
- package/src/components/PaymentOptionsWebView/index.tsx +123 -124
- package/src/components/SingleProductCard/index.tsx +16 -4
- package/src/components/StripeElementsForm/index.tsx +27 -48
- package/src/components/UserProfileForm/index.tsx +63 -6
- package/src/components/UserProfileForm/styles.tsx +8 -0
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/components/shared/OModal.tsx +1 -1
- package/src/config.json +0 -2
- package/src/hooks/useCountdownTimer.tsx +26 -0
- package/src/navigators/HomeNavigator.tsx +6 -0
- package/src/pages/BusinessProductsList.tsx +1 -0
- package/src/pages/BusinessesListing.tsx +1 -1
- package/src/pages/Checkout.tsx +1 -1
- package/src/pages/Sessions.tsx +22 -0
- package/src/types/index.tsx +5 -11
- package/src/utils/index.tsx +68 -1
- package/themes/business/index.tsx +2 -0
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
- package/themes/business/src/components/Chat/index.tsx +38 -86
- package/themes/business/src/components/Home/index.tsx +128 -55
- package/themes/business/src/components/Home/styles.tsx +8 -1
- package/themes/business/src/components/LoginForm/index.tsx +89 -2
- package/themes/business/src/components/LoginForm/styles.tsx +6 -0
- package/themes/business/src/components/NewOrderNotification/index.tsx +61 -98
- package/themes/business/src/components/OrderDetails/Business.tsx +2 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +32 -15
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +151 -89
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +91 -17
- package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
- package/themes/business/src/components/OrdersListManager/index.tsx +874 -0
- package/themes/business/src/components/OrdersListManager/styles.tsx +123 -0
- package/themes/business/src/components/OrdersListManager/utils.tsx +216 -0
- package/themes/business/src/components/OrdersOption/index.tsx +54 -50
- package/themes/business/src/components/PreviousOrders/index.tsx +75 -22
- package/themes/business/src/components/shared/OModal.tsx +1 -1
- package/themes/business/src/types/index.tsx +5 -1
- package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
- package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/kiosk/src/components/Cart/index.tsx +98 -24
- package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
- package/themes/kiosk/src/components/CartBottomSheet/index.tsx +1 -1
- package/themes/kiosk/src/components/CartBottomSheet/styles.tsx +1 -1
- package/themes/kiosk/src/components/CartContent/index.tsx +13 -3
- package/themes/kiosk/src/components/CartItem/index.tsx +20 -8
- package/themes/kiosk/src/components/CustomerName/index.tsx +89 -88
- package/themes/kiosk/src/components/Intro/index.tsx +13 -13
- package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
- package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderDetails/index.tsx +136 -41
- package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
- package/themes/kiosk/src/components/OrderSummary/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
- package/themes/kiosk/src/components/ProductForm/index.tsx +174 -125
- package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
- package/themes/kiosk/src/components/ProductOption/index.tsx +1 -0
- package/themes/kiosk/src/components/ProductOption/styles.tsx +1 -0
- package/themes/kiosk/src/components/UpsellingProducts/index.tsx +48 -34
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/kiosk/src/types/index.d.ts +2 -0
- package/themes/original/index.tsx +178 -1
- package/themes/original/src/components/AddressForm/index.tsx +15 -10
- package/themes/original/src/components/AddressList/index.tsx +56 -18
- package/themes/original/src/components/AppleLogin/index.tsx +117 -78
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +96 -45
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
- package/themes/original/src/components/BusinessController/index.tsx +52 -22
- package/themes/original/src/components/BusinessController/styles.tsx +22 -0
- package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
- package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
- package/themes/original/src/components/BusinessListingSearch/index.tsx +121 -7
- package/themes/original/src/components/BusinessListingSearch/styles.tsx +14 -1
- package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
- package/themes/original/src/components/BusinessPreorder/index.tsx +142 -122
- package/themes/original/src/components/BusinessProductsCategories/index.tsx +9 -7
- package/themes/original/src/components/BusinessProductsList/index.tsx +127 -20
- package/themes/original/src/components/BusinessProductsList/styles.tsx +29 -2
- package/themes/original/src/components/BusinessProductsListing/index.tsx +92 -37
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
- package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
- package/themes/original/src/components/BusinessesListing/index.tsx +51 -58
- package/themes/original/src/components/Cart/index.tsx +19 -15
- package/themes/original/src/components/CartContent/index.tsx +2 -2
- package/themes/original/src/components/Checkout/index.tsx +42 -27
- package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
- package/themes/original/src/components/GoogleMap/index.tsx +1 -0
- package/themes/original/src/components/Help/index.tsx +21 -4
- package/themes/original/src/components/HighestRatedBusinesses/index.tsx +97 -89
- package/themes/original/src/components/Home/index.tsx +1 -1
- package/themes/original/src/components/LastOrders/index.tsx +12 -1
- package/themes/original/src/components/LoginForm/Otp/index.tsx +90 -0
- package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
- package/themes/original/src/components/LoginForm/index.tsx +389 -156
- package/themes/original/src/components/LoginForm/styles.tsx +7 -4
- package/themes/original/src/components/LogoutButton/index.tsx +7 -1
- package/themes/original/src/components/MessageListing/index.tsx +10 -1
- package/themes/original/src/components/Messages/index.tsx +34 -25
- package/themes/original/src/components/Messages/styles.tsx +1 -3
- package/themes/original/src/components/MomentOption/index.tsx +10 -1
- package/themes/original/src/components/MomentOption/styles.tsx +1 -1
- package/themes/original/src/components/OrderDetails/index.tsx +35 -28
- package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
- package/themes/original/src/components/OrderProgress/index.tsx +4 -4
- package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
- package/themes/original/src/components/OrderSummary/index.tsx +3 -3
- package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
- package/themes/original/src/components/OrdersOption/index.tsx +25 -33
- package/themes/original/src/components/OrdersOption/styles.tsx +0 -6
- package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +22 -24
- package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
- package/themes/original/src/components/PaymentOptions/index.tsx +9 -19
- package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
- package/themes/original/src/components/PreviousOrders/index.tsx +19 -13
- package/themes/original/src/components/ProductForm/index.tsx +76 -61
- package/themes/original/src/components/ProductForm/styles.tsx +2 -2
- package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
- package/themes/original/src/components/Promotions/index.tsx +250 -0
- package/themes/original/src/components/Promotions/styles.tsx +60 -0
- package/themes/original/src/components/ReviewOrder/index.tsx +10 -9
- package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
- package/themes/original/src/components/Sessions/index.tsx +160 -0
- package/themes/original/src/components/Sessions/styles.tsx +15 -0
- package/themes/original/src/components/SingleProductCard/index.tsx +47 -21
- package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
- package/themes/original/src/components/StripeElementsForm/index.tsx +55 -72
- package/themes/original/src/components/TaxInformation/index.tsx +10 -4
- package/themes/original/src/components/UpsellingProducts/index.tsx +87 -71
- package/themes/original/src/components/UserDetails/index.tsx +4 -95
- package/themes/original/src/components/UserFormDetails/index.tsx +32 -31
- package/themes/original/src/components/UserProfile/index.tsx +62 -14
- package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
- package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
- package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
- package/themes/original/src/components/Wallets/index.tsx +76 -9
- package/themes/original/src/components/Wallets/styles.tsx +21 -0
- package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
- package/themes/original/src/components/shared/OModal.tsx +1 -1
- package/themes/original/src/components/shared/index.tsx +2 -0
- package/themes/original/src/config/constants.tsx +6 -6
- package/themes/original/src/types/index.tsx +62 -5
- package/themes/original/src/utils/index.tsx +28 -2
- package/themes/single-business/src/components/AddressList/index.tsx +1 -1
- package/themes/single-business/src/components/OrderTypeSelector/index.tsx +6 -6
- package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/StripeMethodForm/index.tsx +0 -168
|
@@ -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
|
|
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
|
-
|
|
40
|
+
let billingDetails: any = {}
|
|
47
41
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
if (user?.email) {
|
|
52
|
+
billingDetails.email = user?.email
|
|
53
|
+
}
|
|
60
54
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
if (user?.address) {
|
|
56
|
+
billingDetails.addressLine1 = user?.address
|
|
57
|
+
}
|
|
64
58
|
|
|
65
59
|
const createPayMethod = async () => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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
1
|
import React from 'react'
|
|
2
|
-
import { useLanguage } from 'ordering-components/native'
|
|
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'
|
|
@@ -13,8 +13,9 @@ interface taxInformationParams {
|
|
|
13
13
|
fixed?: number,
|
|
14
14
|
percentage?: number,
|
|
15
15
|
id: number,
|
|
16
|
-
discounts?: any
|
|
17
|
-
|
|
16
|
+
discounts?: any,
|
|
17
|
+
rate_type?: number
|
|
18
|
+
},
|
|
18
19
|
products: Array<any>,
|
|
19
20
|
type: string
|
|
20
21
|
}
|
|
@@ -27,6 +28,7 @@ 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')})`
|
|
32
34
|
const offersHideArray = ['offer_target_2', 'offer_target_3']
|
|
@@ -56,8 +58,12 @@ export const TaxInformation = (props: taxInformationParams) => {
|
|
|
56
58
|
|
|
57
59
|
return (
|
|
58
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>
|
|
59
65
|
{!!data?.description ? (
|
|
60
|
-
<OText size={
|
|
66
|
+
<OText size={20} style={{ alignSelf: 'center', textAlign: 'center' }} mBottom={10}>
|
|
61
67
|
{t('DESCRIPTION', 'Description')}: {data?.description} {data?.type && !type?.includes('offer') && includedOnPriceString}
|
|
62
68
|
</OText>
|
|
63
69
|
) : (
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
UpsellingPage as UpsellingPageController,
|
|
5
5
|
useUtils,
|
|
6
6
|
useLanguage,
|
|
7
|
-
|
|
7
|
+
useOrder
|
|
8
8
|
} from 'ordering-components/native'
|
|
9
9
|
import { useTheme } from 'styled-components/native';
|
|
10
10
|
import { OText, OIcon, OBottomPopup, OButton } from '../shared'
|
|
@@ -62,7 +62,19 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
62
62
|
borderRadius: 7.6,
|
|
63
63
|
borderColor: theme.colors.textSecondary,
|
|
64
64
|
height: 38
|
|
65
|
-
}
|
|
65
|
+
},
|
|
66
|
+
headerItem: {
|
|
67
|
+
flexDirection: 'row',
|
|
68
|
+
alignItems: 'center',
|
|
69
|
+
marginVertical: 2,
|
|
70
|
+
marginHorizontal: 20,
|
|
71
|
+
},
|
|
72
|
+
btnBackArrow: {
|
|
73
|
+
borderWidth: 0,
|
|
74
|
+
backgroundColor: theme.colors.clear,
|
|
75
|
+
shadowColor: theme.colors.clear,
|
|
76
|
+
padding: 40,
|
|
77
|
+
},
|
|
66
78
|
})
|
|
67
79
|
|
|
68
80
|
const [modalIsOpen, setModalIsOpen] = useState(false)
|
|
@@ -77,11 +89,11 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
77
89
|
? cart?.products.map((product: any) => product.id)
|
|
78
90
|
: []
|
|
79
91
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
const productsList = !upsellingProducts.loading && !upsellingProducts.error
|
|
93
|
+
? upsellingProducts?.products?.length
|
|
94
|
+
? upsellingProducts?.products.filter((product: any) => !cartProducts.includes(product.id))
|
|
95
|
+
: (props?.products ?? []).filter((product: any) => !cartProducts.includes(product.id)) ?? []
|
|
96
|
+
: []
|
|
85
97
|
|
|
86
98
|
useEffect(() => {
|
|
87
99
|
if (!isCustomMode && !props.products) {
|
|
@@ -100,10 +112,10 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
100
112
|
}, [cart, isCheckout])
|
|
101
113
|
|
|
102
114
|
const handleFormProduct = (product: any) => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
115
|
+
onNavigationRedirect && onNavigationRedirect('ProductDetails', {
|
|
116
|
+
product: product,
|
|
117
|
+
businessId: product?.api?.businessId,
|
|
118
|
+
businessSlug: business.slug,
|
|
107
119
|
})
|
|
108
120
|
}
|
|
109
121
|
|
|
@@ -119,8 +131,8 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
119
131
|
!upsellingProducts.loading && (
|
|
120
132
|
<>
|
|
121
133
|
{
|
|
122
|
-
!upsellingProducts.error ? productsList.map((product: any) => (
|
|
123
|
-
<Item key={product.id}>
|
|
134
|
+
!upsellingProducts.error ? productsList.map((product: any, i: number) => (
|
|
135
|
+
<Item key={`${product.id}_${i}`}>
|
|
124
136
|
<View style={{ flexBasis: '57%' }}>
|
|
125
137
|
<Details>
|
|
126
138
|
<OText size={12} lineHeight={18} numberOfLines={1} ellipsizeMode='tail'>{product.name}</OText>
|
|
@@ -148,50 +160,54 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
148
160
|
)
|
|
149
161
|
}
|
|
150
162
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
163
|
+
const UpsellingContent = () => {
|
|
164
|
+
return (
|
|
165
|
+
<>
|
|
166
|
+
<View style={{ ...styles.headerItem, flex: 1, marginTop: Platform.OS == 'ios' ? 35 : 70 }}>
|
|
167
|
+
<OButton
|
|
168
|
+
imgLeftSrc={theme.images.general.arrow_left}
|
|
169
|
+
imgRightSrc={null}
|
|
170
|
+
style={styles.btnBackArrow}
|
|
171
|
+
onClick={() => onGoBack()}
|
|
172
|
+
imgLeftStyle={{ tintColor: theme.colors.textNormal, width: 16 }}
|
|
173
|
+
/>
|
|
174
|
+
</View>
|
|
175
|
+
<ScrollView style={{ marginTop: 10, marginBottom: props.isPage ? 40 : bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
|
|
176
|
+
{productsList.length > 0 &&
|
|
177
|
+
<View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
|
|
178
|
+
<OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
|
|
179
|
+
<UpsellingLayout />
|
|
180
|
+
</View>
|
|
181
|
+
}
|
|
182
|
+
<View style={{ paddingHorizontal: 40 }}>
|
|
183
|
+
<OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
|
|
184
|
+
<OrderSummary
|
|
185
|
+
cart={cart}
|
|
186
|
+
isCartPending={cart?.status === 2}
|
|
187
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
188
|
+
/>
|
|
189
|
+
</View>
|
|
190
|
+
</ScrollView>
|
|
191
|
+
<View
|
|
192
|
+
style={{
|
|
193
|
+
alignItems: 'center',
|
|
194
|
+
bottom: props.isPage ? Platform.OS === 'ios' ? 0 : 20 : Platform.OS === 'ios' ? bottom + 59 : bottom + 125
|
|
195
|
+
}}
|
|
196
|
+
>
|
|
197
|
+
<OButton
|
|
198
|
+
imgRightSrc=''
|
|
199
|
+
text={t('CHECKOUT', 'Checkout')}
|
|
200
|
+
style={{ ...styles.closeUpsellingButton }}
|
|
201
|
+
textStyle={{ color: theme.colors.white, fontSize: 14 }}
|
|
202
|
+
onClick={() => {
|
|
203
|
+
handleUpsellingPage()
|
|
204
|
+
setIsCheckout(true)
|
|
205
|
+
}}
|
|
206
|
+
/>
|
|
207
|
+
</View>
|
|
208
|
+
</>
|
|
209
|
+
)
|
|
210
|
+
}
|
|
195
211
|
|
|
196
212
|
return (
|
|
197
213
|
<>
|
|
@@ -199,20 +215,20 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
199
215
|
<UpsellingLayout />
|
|
200
216
|
) : (
|
|
201
217
|
<>
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
218
|
+
{props.isPage ? (
|
|
219
|
+
<UpsellingContent />
|
|
220
|
+
) : (
|
|
221
|
+
canOpenUpselling && !modalIsOpen && (
|
|
222
|
+
<OBottomPopup
|
|
223
|
+
title={''}
|
|
224
|
+
open={openUpselling}
|
|
225
|
+
onClose={() => handleUpsellingPage()}
|
|
226
|
+
isStatusBar
|
|
227
|
+
>
|
|
228
|
+
<UpsellingContent />
|
|
229
|
+
</OBottomPopup>
|
|
230
|
+
)
|
|
231
|
+
)}
|
|
216
232
|
</>
|
|
217
233
|
)}
|
|
218
234
|
</>
|
|
@@ -3,17 +3,14 @@ import { TouchableOpacity, View } from 'react-native';
|
|
|
3
3
|
import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons';
|
|
4
4
|
|
|
5
5
|
import { UDContainer, UDHeader, UDForm, UDInfo, EditBtn } from './styles';
|
|
6
|
+
|
|
6
7
|
import {
|
|
7
8
|
UserFormDetails as UserFormController,
|
|
8
9
|
useLanguage,
|
|
9
10
|
useSession,
|
|
10
|
-
ToastType,
|
|
11
|
-
useToast
|
|
12
11
|
} from 'ordering-components/native';
|
|
13
12
|
import { useTheme } from 'styled-components/native';
|
|
14
|
-
import { OIcon, OText
|
|
15
|
-
import { VerifyPhone } from '../VerifyPhone';
|
|
16
|
-
import Spinner from 'react-native-loading-spinner-overlay';
|
|
13
|
+
import { OIcon, OText } from '../shared';
|
|
17
14
|
|
|
18
15
|
import { UserFormDetailsUI } from '../UserFormDetails';
|
|
19
16
|
import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
|
|
@@ -29,33 +26,15 @@ const UserDetailsUI = (props: any) => {
|
|
|
29
26
|
isUserDetailsEdit,
|
|
30
27
|
phoneUpdate,
|
|
31
28
|
togglePhoneUpdate,
|
|
32
|
-
isCheckout
|
|
33
|
-
checkPhoneCodeState,
|
|
34
|
-
handleSendVerifyCode,
|
|
35
|
-
handleCheckPhoneCode,
|
|
36
|
-
verifyPhoneState,
|
|
37
|
-
isVerifiedPhone,
|
|
38
|
-
setCheckPhoneCodeState
|
|
29
|
+
isCheckout
|
|
39
30
|
} = props
|
|
40
31
|
|
|
41
32
|
const theme = useTheme();
|
|
42
33
|
|
|
43
34
|
const [, t] = useLanguage()
|
|
44
35
|
const [{ user }] = useSession()
|
|
45
|
-
const [, { showToast }] = useToast();
|
|
46
|
-
|
|
47
36
|
const userData = props.userData || (!formState.result.error && formState.result?.result) || user
|
|
48
37
|
|
|
49
|
-
const [isModalVisible, setIsModalVisible] = useState(false);
|
|
50
|
-
const [willVerifyOtpState, setWillVerifyOtpState] = useState(false);
|
|
51
|
-
const [phoneInputData, setPhoneInputData] = useState({
|
|
52
|
-
error: '',
|
|
53
|
-
phone: {
|
|
54
|
-
country_phone_code: null,
|
|
55
|
-
cellphone: null,
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
|
|
59
38
|
|
|
60
39
|
useEffect(() => {
|
|
61
40
|
if (isUserDetailsEdit) {
|
|
@@ -76,54 +55,6 @@ const UserDetailsUI = (props: any) => {
|
|
|
76
55
|
}
|
|
77
56
|
}, [user?.country_phone_code])
|
|
78
57
|
|
|
79
|
-
const handleVerifyCodeClick = () => {
|
|
80
|
-
if (formState?.changes?.cellphone && formState?.changes?.country_phone_code) {
|
|
81
|
-
const { cellphone, country_phone_code: countryPhoneCode } = formState?.changes
|
|
82
|
-
|
|
83
|
-
setPhoneInputData({
|
|
84
|
-
error: '',
|
|
85
|
-
phone: {
|
|
86
|
-
country_phone_code: countryPhoneCode,
|
|
87
|
-
cellphone: cellphone,
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
handleSendVerifyCode({
|
|
91
|
-
cellphone: cellphone,
|
|
92
|
-
country_phone_code: countryPhoneCode
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
useEffect(() => {
|
|
98
|
-
if (willVerifyOtpState) handleVerifyCodeClick()
|
|
99
|
-
}, [willVerifyOtpState])
|
|
100
|
-
|
|
101
|
-
useEffect(() => {
|
|
102
|
-
if (verifyPhoneState && !verifyPhoneState?.loading) {
|
|
103
|
-
if (verifyPhoneState.result?.error) {
|
|
104
|
-
const message = typeof verifyPhoneState?.result?.result === 'string'
|
|
105
|
-
? verifyPhoneState?.result?.result
|
|
106
|
-
: verifyPhoneState?.result?.result[0]
|
|
107
|
-
verifyPhoneState.result?.result && showToast(
|
|
108
|
-
ToastType.Error,
|
|
109
|
-
message
|
|
110
|
-
)
|
|
111
|
-
setWillVerifyOtpState(false)
|
|
112
|
-
return
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const okResult = verifyPhoneState.result?.result === 'OK'
|
|
116
|
-
if (okResult) {
|
|
117
|
-
!isModalVisible && setIsModalVisible(true)
|
|
118
|
-
setWillVerifyOtpState(false)
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}, [verifyPhoneState])
|
|
122
|
-
|
|
123
|
-
useEffect(() => {
|
|
124
|
-
if (isVerifiedPhone) setIsModalVisible(false)
|
|
125
|
-
}, [isVerifiedPhone])
|
|
126
|
-
|
|
127
58
|
return (
|
|
128
59
|
<>
|
|
129
60
|
{(validationFields.loading || formState.loading) && (
|
|
@@ -186,32 +117,10 @@ const UserDetailsUI = (props: any) => {
|
|
|
186
117
|
)}
|
|
187
118
|
</UDInfo>
|
|
188
119
|
) : (
|
|
189
|
-
<UserFormDetailsUI
|
|
190
|
-
{...props}
|
|
191
|
-
phoneUpdate={phoneUpdate}
|
|
192
|
-
togglePhoneUpdate={togglePhoneUpdate}
|
|
193
|
-
isCheckout={isCheckout}
|
|
194
|
-
setWillVerifyOtpState={setWillVerifyOtpState}
|
|
195
|
-
/>
|
|
120
|
+
<UserFormDetailsUI {...props} phoneUpdate={phoneUpdate} togglePhoneUpdate={togglePhoneUpdate} isCheckout={isCheckout} />
|
|
196
121
|
)}
|
|
197
122
|
</UDContainer>
|
|
198
123
|
)}
|
|
199
|
-
<OModal
|
|
200
|
-
open={isModalVisible}
|
|
201
|
-
onClose={() => setIsModalVisible(false)}
|
|
202
|
-
entireModal
|
|
203
|
-
>
|
|
204
|
-
<VerifyPhone
|
|
205
|
-
phone={phoneInputData.phone}
|
|
206
|
-
verifyPhoneState={verifyPhoneState}
|
|
207
|
-
checkPhoneCodeState={checkPhoneCodeState}
|
|
208
|
-
handleCheckPhoneCode={handleCheckPhoneCode}
|
|
209
|
-
setCheckPhoneCodeState={setCheckPhoneCodeState}
|
|
210
|
-
handleVerifyCodeClick={handleVerifyCodeClick}
|
|
211
|
-
onClose={() => setIsModalVisible(false)}
|
|
212
|
-
/>
|
|
213
|
-
</OModal>
|
|
214
|
-
<Spinner visible={verifyPhoneState?.loading} />
|
|
215
124
|
</>
|
|
216
125
|
)
|
|
217
126
|
}
|