ordering-ui-react-native 0.15.9 → 0.15.10-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/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 +1 -0
- package/src/components/MomentOption/index.tsx +3 -1
- package/src/components/OrderDetails/index.tsx +24 -3
- package/src/components/PaymentOptions/index.tsx +9 -16
- package/src/components/PaymentOptionsWebView/index.tsx +123 -124
- package/src/components/ProductForm/index.tsx +1 -1
- package/src/components/ProductForm/styles.tsx +1 -0
- package/src/components/StripeElementsForm/index.tsx +27 -48
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/config.json +0 -2
- package/src/pages/Checkout.tsx +1 -1
- package/src/types/index.tsx +1 -9
- package/src/utils/index.tsx +2 -1
- package/themes/business/index.tsx +2 -0
- package/themes/business/src/components/Chat/index.tsx +3 -2
- 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/NewOrderNotification/index.tsx +59 -98
- package/themes/business/src/components/OrderDetails/Business.tsx +1 -0
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +27 -0
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +85 -17
- 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 +70 -116
- package/themes/business/src/components/OrdersOption/styles.tsx +2 -5
- package/themes/business/src/components/PreviousOrders/index.tsx +82 -23
- 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/BusinessController/index.tsx +27 -6
- package/themes/kiosk/src/components/BusinessController/styles.tsx +1 -1
- package/themes/kiosk/src/components/BusinessProductsListing/index.tsx +51 -24
- package/themes/kiosk/src/components/Cart/index.tsx +1 -1
- 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/CategoriesMenu/index.tsx +7 -5
- 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/LanguageSelector/index.tsx +12 -8
- 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 +2 -2
- 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 -126
- 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/components/shared/OCard.tsx +112 -78
- package/themes/original/index.tsx +177 -0
- package/themes/original/src/components/AddressForm/index.tsx +15 -10
- package/themes/original/src/components/AddressList/index.tsx +28 -2
- package/themes/original/src/components/AppleLogin/index.tsx +119 -78
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +95 -44
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
- package/themes/original/src/components/BusinessController/index.tsx +32 -21
- package/themes/original/src/components/BusinessListingSearch/index.tsx +7 -3
- package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
- package/themes/original/src/components/BusinessPreorder/index.tsx +141 -121
- package/themes/original/src/components/BusinessProductsCategories/index.tsx +7 -5
- package/themes/original/src/components/BusinessProductsList/index.tsx +129 -22
- package/themes/original/src/components/BusinessProductsList/styles.tsx +32 -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/BusinessesListing/index.tsx +40 -53
- package/themes/original/src/components/Cart/index.tsx +40 -9
- package/themes/original/src/components/CartContent/index.tsx +2 -2
- package/themes/original/src/components/Checkout/index.tsx +47 -31
- package/themes/original/src/components/Checkout/styles.tsx +7 -0
- package/themes/original/src/components/CouponControl/index.tsx +1 -0
- package/themes/original/src/components/DriverTips/index.tsx +1 -1
- package/themes/original/src/components/ForgotPasswordForm/index.tsx +8 -12
- 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/LoginForm/index.tsx +156 -70
- package/themes/original/src/components/LoginForm/styles.tsx +6 -1
- package/themes/original/src/components/Messages/index.tsx +50 -45
- 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 +104 -126
- package/themes/original/src/components/OrderDetails/styles.tsx +3 -1
- 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 +34 -1
- package/themes/original/src/components/OrdersOption/index.tsx +15 -46
- package/themes/original/src/components/OrdersOption/styles.tsx +0 -6
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +6 -2
- package/themes/original/src/components/PaymentOptions/index.tsx +24 -25
- package/themes/original/src/components/PhoneInputNumber/index.tsx +15 -8
- package/themes/original/src/components/PlaceSpot/index.tsx +114 -0
- package/themes/original/src/components/PlaceSpot/styles.tsx +11 -0
- package/themes/original/src/components/PreviousOrders/index.tsx +19 -13
- package/themes/original/src/components/ProductForm/index.tsx +31 -20
- package/themes/original/src/components/ProductForm/styles.tsx +2 -2
- 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/SignupForm/index.tsx +173 -154
- package/themes/original/src/components/StripeElementsForm/index.tsx +55 -72
- package/themes/original/src/components/TaxInformation/index.tsx +17 -7
- package/themes/original/src/components/UpsellingProducts/index.tsx +6 -6
- package/themes/original/src/components/UserDetails/index.tsx +4 -95
- package/themes/original/src/components/UserFormDetails/index.tsx +2 -14
- package/themes/original/src/components/UserProfile/index.tsx +16 -16
- package/themes/original/src/components/UserProfileForm/index.tsx +8 -6
- 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/shared/HeaderTitle.tsx +21 -0
- 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 +63 -23
- package/themes/original/src/utils/index.tsx +12 -2
- package/themes/single-business/src/components/AddressList/index.tsx +1 -1
- package/themes/single-business/src/components/OrderTypeSelector/index.tsx +5 -5
- 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,6 +1,6 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { Platform, Text, StyleSheet } from 'react-native';
|
|
3
|
-
import { useApi, useSession, useLanguage } from 'ordering-components/native';
|
|
3
|
+
import { useApi, useSession, useLanguage, useConfig, useToast, ToastType } from 'ordering-components/native';
|
|
4
4
|
import { appleAuthAndroid, appleAuth } from '@invertase/react-native-apple-authentication';
|
|
5
5
|
import uuid from 'react-native-uuid';
|
|
6
6
|
import Icon from 'react-native-vector-icons/FontAwesome5';
|
|
@@ -16,12 +16,17 @@ export const AppleLogin = (props: any) => {
|
|
|
16
16
|
} = props
|
|
17
17
|
|
|
18
18
|
const [ordering] = useApi();
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const [{ auth }] = useSession();
|
|
20
|
+
const [, t] = useLanguage();
|
|
21
|
+
const [{ configs }] = useConfig();
|
|
22
|
+
const [, { showToast }] = useToast()
|
|
23
|
+
const [credentialStateForUser, updateCredentialStateForUser] = useState<any>(-1);
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
let user: any = null
|
|
26
|
+
|
|
27
|
+
const buttonText = auth
|
|
28
|
+
? t('CONTINUE_WITH_APPLE', 'Logout with Apple')
|
|
29
|
+
: t('CONTINUE_WITH_FACEBOOK', 'Continue with Apple');
|
|
25
30
|
|
|
26
31
|
const performAppleLogin = async (code: string) => {
|
|
27
32
|
try {
|
|
@@ -29,17 +34,19 @@ export const AppleLogin = (props: any) => {
|
|
|
29
34
|
method: 'POST',
|
|
30
35
|
headers: { 'Content-Type': 'application/json' },
|
|
31
36
|
body: JSON.stringify({
|
|
32
|
-
code: code
|
|
37
|
+
code: code,
|
|
38
|
+
platform: Platform.OS === 'ios' ? 'ios' : 'other'
|
|
33
39
|
})
|
|
34
40
|
})
|
|
35
|
-
|
|
41
|
+
const { result, error } = await response.json()
|
|
42
|
+
if (!error) {
|
|
36
43
|
if (handleSuccessAppleLogin) {
|
|
37
|
-
handleSuccessAppleLogin(
|
|
44
|
+
handleSuccessAppleLogin(result)
|
|
38
45
|
handleLoading && handleLoading(false)
|
|
39
46
|
}
|
|
40
47
|
} else {
|
|
48
|
+
handleErrors && handleErrors(result)
|
|
41
49
|
handleLoading && handleLoading(false)
|
|
42
|
-
logoutFromApple()
|
|
43
50
|
}
|
|
44
51
|
} catch (err: any) {
|
|
45
52
|
handleLoading && handleLoading(false)
|
|
@@ -47,66 +54,99 @@ export const AppleLogin = (props: any) => {
|
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
56
|
|
|
50
|
-
const
|
|
51
|
-
|
|
57
|
+
const fetchAndUpdateCredentialState = async (updateCredentialStateForUser: any) => {
|
|
58
|
+
if (user === null) {
|
|
59
|
+
updateCredentialStateForUser('N/A');
|
|
60
|
+
} else {
|
|
61
|
+
const credentialState = await appleAuth.getCredentialStateForUser(user);
|
|
62
|
+
if (credentialState === appleAuth.State.AUTHORIZED) {
|
|
63
|
+
updateCredentialStateForUser('AUTHORIZED');
|
|
64
|
+
} else {
|
|
65
|
+
updateCredentialStateForUser(credentialState);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
52
68
|
}
|
|
53
69
|
|
|
54
|
-
const onIOSButtonPress = async () => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
const onIOSButtonPress = async (updateCredentialStateForUser: any) => {
|
|
71
|
+
try {
|
|
72
|
+
const appleAuthRequestResponse = await appleAuth.performRequest({
|
|
73
|
+
requestedOperation: appleAuth.Operation.LOGIN,
|
|
74
|
+
requestedScopes: [appleAuth.Scope.EMAIL, appleAuth.Scope.FULL_NAME],
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const {
|
|
78
|
+
user: newUser,
|
|
79
|
+
email,
|
|
80
|
+
identityToken,
|
|
81
|
+
authorizationCode
|
|
82
|
+
} = appleAuthRequestResponse;
|
|
83
|
+
|
|
84
|
+
user = newUser;
|
|
85
|
+
|
|
86
|
+
fetchAndUpdateCredentialState(updateCredentialStateForUser).catch(error =>
|
|
87
|
+
updateCredentialStateForUser(`Error: ${error.code}`),
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
if (identityToken && authorizationCode) {
|
|
91
|
+
showToast(ToastType.Success, `Apple Authentication Completed, ${email}`)
|
|
92
|
+
performAppleLogin(authorizationCode)
|
|
93
|
+
} else {
|
|
94
|
+
handleErrors && handleErrors('UNABLE_LOGIN_TOKEN', 'Unable to login, no token found')
|
|
70
95
|
}
|
|
71
|
-
}
|
|
72
96
|
|
|
97
|
+
} catch (err: any) {
|
|
98
|
+
handleLoading && handleLoading(false)
|
|
99
|
+
handleErrors && handleErrors(err.message)
|
|
100
|
+
}
|
|
73
101
|
}
|
|
74
102
|
|
|
75
103
|
const onAndroidButtonPress = async () => {
|
|
76
|
-
// Generate secure, random values for state and nonce
|
|
77
|
-
const rawNonce: any = uuid.v4();
|
|
78
|
-
const state: any = uuid.v4();
|
|
79
|
-
|
|
80
|
-
// Configure the request
|
|
81
|
-
appleAuthAndroid.configure({
|
|
82
|
-
clientId: 'com.example.client-android',
|
|
83
|
-
// Return URL added to your Apple dev console. We intercept this redirect, but it must still match
|
|
84
|
-
// the URL you provided to Apple. It can be an empty route on your backend as it's never called.
|
|
85
|
-
redirectUri: 'https://example.com/auth/callback',
|
|
86
|
-
responseType: appleAuthAndroid.ResponseType.ALL,
|
|
87
|
-
scope: appleAuthAndroid.Scope.ALL,
|
|
88
|
-
// Random nonce value that will be SHA256 hashed before sending to Apple.
|
|
89
|
-
nonce: rawNonce,
|
|
90
|
-
state,
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// Open the browser window for user sign in
|
|
94
|
-
const response = await appleAuthAndroid.signIn();
|
|
95
|
-
|
|
96
104
|
try {
|
|
105
|
+
// Generate secure, random values for state and nonce
|
|
106
|
+
const rawNonce: any = uuid.v4();
|
|
107
|
+
const state: any = uuid.v4();
|
|
108
|
+
|
|
109
|
+
// Configure the request
|
|
110
|
+
appleAuthAndroid.configure({
|
|
111
|
+
// The Service ID you registered with Apple
|
|
112
|
+
clientId: configs?.apple_login_client_id?.value,
|
|
113
|
+
// Return URL added to your Apple dev console. We intercept this redirect, but it must still match
|
|
114
|
+
// the URL you provided to Apple. It can be an empty route on your backend as it's never called.
|
|
115
|
+
redirectUri: 'https://example.com/auth/callback',
|
|
116
|
+
responseType: appleAuthAndroid.ResponseType.ALL,
|
|
117
|
+
scope: appleAuthAndroid.Scope.ALL,
|
|
118
|
+
// Random nonce value that will be SHA256 hashed before sending to Apple.
|
|
119
|
+
nonce: rawNonce,
|
|
120
|
+
state,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Open the browser window for user sign in
|
|
124
|
+
const response = await appleAuthAndroid.signIn();
|
|
97
125
|
if (response.code) {
|
|
98
126
|
performAppleLogin(response.code)
|
|
99
127
|
}
|
|
100
128
|
} catch (err: any) {
|
|
101
|
-
|
|
129
|
+
handleLoading && handleLoading(false)
|
|
130
|
+
handleErrors && handleErrors(err.message)
|
|
102
131
|
}
|
|
132
|
+
|
|
103
133
|
}
|
|
104
134
|
|
|
105
135
|
useEffect(() => {
|
|
106
|
-
if (Platform.OS
|
|
107
|
-
|
|
136
|
+
if (!appleAuth.isSupported || Platform.OS === 'android') return;
|
|
137
|
+
|
|
138
|
+
fetchAndUpdateCredentialState(updateCredentialStateForUser).catch(error =>
|
|
139
|
+
updateCredentialStateForUser(`Error: ${error.code}`),
|
|
140
|
+
);
|
|
141
|
+
}, []);
|
|
142
|
+
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
if (!appleAuth.isSupported || Platform.OS === 'android') return;
|
|
145
|
+
|
|
108
146
|
return appleAuth.onCredentialRevoked(async () => {
|
|
109
|
-
|
|
147
|
+
fetchAndUpdateCredentialState(updateCredentialStateForUser).catch(error =>
|
|
148
|
+
updateCredentialStateForUser(`Error: ${error.code}`),
|
|
149
|
+
);
|
|
110
150
|
});
|
|
111
151
|
}, []);
|
|
112
152
|
|
|
@@ -115,35 +155,36 @@ export const AppleLogin = (props: any) => {
|
|
|
115
155
|
if (Platform.OS === 'android') return appleAuthAndroid.isSupported;
|
|
116
156
|
return false;
|
|
117
157
|
}
|
|
158
|
+
|
|
118
159
|
return (
|
|
119
160
|
<Container>
|
|
120
|
-
{canShowButton() &&
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
161
|
+
{canShowButton() &&
|
|
162
|
+
<AppleButton
|
|
163
|
+
onPress={() => Platform.OS == 'android' ? onAndroidButtonPress() : onIOSButtonPress(updateCredentialStateForUser)}
|
|
164
|
+
>
|
|
165
|
+
<Icon
|
|
166
|
+
name="apple"
|
|
167
|
+
size={20}
|
|
168
|
+
color={'black'}
|
|
169
|
+
style={style.fbBtn}
|
|
170
|
+
/>
|
|
171
|
+
<Text style={style.textBtn}>
|
|
172
|
+
{buttonText}
|
|
173
|
+
</Text>
|
|
174
|
+
</AppleButton>
|
|
134
175
|
}
|
|
135
176
|
</Container>
|
|
136
177
|
);
|
|
137
178
|
}
|
|
138
179
|
|
|
139
180
|
const style = StyleSheet.create({
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
})
|
|
181
|
+
fbBtn: {
|
|
182
|
+
position: 'absolute',
|
|
183
|
+
left: 0,
|
|
184
|
+
marginHorizontal: 16
|
|
185
|
+
},
|
|
186
|
+
textBtn: {
|
|
187
|
+
fontSize: 14,
|
|
188
|
+
color: '#000000'
|
|
189
|
+
}
|
|
190
|
+
})
|
|
@@ -5,8 +5,6 @@ import { useTheme } from 'styled-components/native';
|
|
|
5
5
|
import { OIcon, OText, OModal } from '../shared';
|
|
6
6
|
import { BusinessBasicInformationParams } from '../../types';
|
|
7
7
|
import { convertHoursToMinutes } from '../../utils';
|
|
8
|
-
import { BusinessInformation } from '../BusinessInformation';
|
|
9
|
-
import { BusinessReviews } from '../BusinessReviews';
|
|
10
8
|
import dayjs from 'dayjs';
|
|
11
9
|
import timezone from 'dayjs/plugin/timezone';
|
|
12
10
|
import isBetween from 'dayjs/plugin/isBetween';
|
|
@@ -22,10 +20,15 @@ import {
|
|
|
22
20
|
BusinessInfoItem,
|
|
23
21
|
WrapReviews,
|
|
24
22
|
WrapBusinessInfo,
|
|
23
|
+
TitleWrapper,
|
|
24
|
+
RibbonBox
|
|
25
25
|
} from './styles';
|
|
26
26
|
import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
|
|
27
27
|
const types = ['food', 'laundry', 'alcohol', 'groceries'];
|
|
28
28
|
|
|
29
|
+
let BusinessInformation: null | React.ElementType = null
|
|
30
|
+
let BusinessReviews: null | React.ElementType = null
|
|
31
|
+
|
|
29
32
|
export const BusinessBasicInformation = (
|
|
30
33
|
props: BusinessBasicInformationParams,
|
|
31
34
|
) => {
|
|
@@ -38,6 +41,25 @@ export const BusinessBasicInformation = (
|
|
|
38
41
|
const [{ parsePrice, parseDistance, optimizeImage }] = useUtils();
|
|
39
42
|
const [openBusinessInformation, setOpenBusinessInformation] = useState(false);
|
|
40
43
|
const [openBusinessReviews, setOpenBusinessReviews] = useState(false);
|
|
44
|
+
const [businessInformationObtained, setBusinessInformationObtained] = useState(false)
|
|
45
|
+
const [businessReviewsObtained, setBusinessReviewsObtainedbtained] = useState(false)
|
|
46
|
+
|
|
47
|
+
const handleClickBusinessInformation = () => {
|
|
48
|
+
if (!businessInformationObtained) {
|
|
49
|
+
BusinessInformation = require('../BusinessInformation').BusinessInformation
|
|
50
|
+
setBusinessInformationObtained(true)
|
|
51
|
+
}
|
|
52
|
+
setOpenBusinessInformation(true)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const handleClickBusinessReviews = () => {
|
|
56
|
+
if (!businessReviewsObtained) {
|
|
57
|
+
BusinessReviews = require('../BusinessReviews').BusinessReviews
|
|
58
|
+
setBusinessReviewsObtainedbtained(true)
|
|
59
|
+
}
|
|
60
|
+
setOpenBusinessReviews(true)
|
|
61
|
+
}
|
|
62
|
+
|
|
41
63
|
const getBusinessType = () => {
|
|
42
64
|
if (Object.keys(business).length <= 0) return t('GENERAL', 'General');
|
|
43
65
|
const _types: any = [];
|
|
@@ -51,7 +73,7 @@ export const BusinessBasicInformation = (
|
|
|
51
73
|
return _types.join(', ');
|
|
52
74
|
};
|
|
53
75
|
|
|
54
|
-
|
|
76
|
+
|
|
55
77
|
useEffect(() => {
|
|
56
78
|
if (businessState?.loading) return
|
|
57
79
|
let timeout: any = null
|
|
@@ -65,16 +87,16 @@ export const BusinessBasicInformation = (
|
|
|
65
87
|
})
|
|
66
88
|
}
|
|
67
89
|
if (lapse) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
90
|
+
const to = currentDate.hour(lapse.close.hour).minute(lapse.close.minute)
|
|
91
|
+
const timeToClose = (to.unix() - currentDate.unix()) * 1000
|
|
92
|
+
timeout = setTimeout(() => {
|
|
93
|
+
navigation.navigate('BusinessPreorder', { business: businessState?.business, handleBusinessClick: () => navigation?.goBack() })
|
|
94
|
+
}, timeToClose)
|
|
73
95
|
}
|
|
74
96
|
return () => {
|
|
75
|
-
|
|
97
|
+
timeout && clearTimeout(timeout)
|
|
76
98
|
}
|
|
77
|
-
|
|
99
|
+
}, [businessState?.business])
|
|
78
100
|
|
|
79
101
|
return (
|
|
80
102
|
<BusinessContainer>
|
|
@@ -90,7 +112,7 @@ export const BusinessBasicInformation = (
|
|
|
90
112
|
optimizeImage(businessState?.business?.header, 'h_250,c_limit'),
|
|
91
113
|
}}>
|
|
92
114
|
{!isBusinessInfoShow && (
|
|
93
|
-
<WrapBusinessInfo onPress={() =>
|
|
115
|
+
<WrapBusinessInfo onPress={() => handleClickBusinessInformation()}>
|
|
94
116
|
<OIcon src={theme.images.general.info} width={24} />
|
|
95
117
|
</WrapBusinessInfo>
|
|
96
118
|
)}
|
|
@@ -121,9 +143,29 @@ export const BusinessBasicInformation = (
|
|
|
121
143
|
<PlaceholderLine height={30} width={20} />
|
|
122
144
|
</Placeholder>
|
|
123
145
|
) : (
|
|
124
|
-
<
|
|
125
|
-
{
|
|
126
|
-
|
|
146
|
+
<TitleWrapper>
|
|
147
|
+
<OText size={24} weight={'600'}>
|
|
148
|
+
{business?.name}
|
|
149
|
+
</OText>
|
|
150
|
+
{business?.ribbon?.enabled && (
|
|
151
|
+
<RibbonBox
|
|
152
|
+
bgColor={business?.ribbon?.color}
|
|
153
|
+
isRoundRect={business?.ribbon?.shape === shape?.rectangleRound}
|
|
154
|
+
isCapsule={business?.ribbon?.shape === shape?.capsuleShape}
|
|
155
|
+
>
|
|
156
|
+
<OText
|
|
157
|
+
size={10}
|
|
158
|
+
weight={'400'}
|
|
159
|
+
color={theme.colors.white}
|
|
160
|
+
numberOfLines={2}
|
|
161
|
+
ellipsizeMode='tail'
|
|
162
|
+
lineHeight={13}
|
|
163
|
+
>
|
|
164
|
+
{business?.ribbon?.text}
|
|
165
|
+
</OText>
|
|
166
|
+
</RibbonBox>
|
|
167
|
+
)}
|
|
168
|
+
</TitleWrapper>
|
|
127
169
|
)}
|
|
128
170
|
</BusinessInfoItem>
|
|
129
171
|
{loading ? (
|
|
@@ -181,17 +223,17 @@ export const BusinessBasicInformation = (
|
|
|
181
223
|
<WrapReviews>
|
|
182
224
|
{!isBusinessInfoShow && (
|
|
183
225
|
<>
|
|
184
|
-
{
|
|
226
|
+
{isPreOrder && (
|
|
185
227
|
<>
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
228
|
+
<TouchableOpacity onPress={() => navigation.navigate('BusinessPreorder', { business: businessState?.business, handleBusinessClick: () => navigation?.goBack() })}>
|
|
229
|
+
<OText color={theme.colors.textSecondary} style={{ textDecorationLine: 'underline' }}>
|
|
230
|
+
{t('PRE_ORDER', 'Preorder')}
|
|
231
|
+
</OText>
|
|
232
|
+
</TouchableOpacity>
|
|
233
|
+
<OText size={12} color={theme.colors.textSecondary}>{' \u2022 '}</OText>
|
|
192
234
|
</>
|
|
193
235
|
)}
|
|
194
|
-
<TouchableOpacity onPress={() =>
|
|
236
|
+
<TouchableOpacity onPress={() => handleClickBusinessReviews()}>
|
|
195
237
|
<OText color={theme.colors.textSecondary} style={{ textDecorationLine: 'underline' }}>
|
|
196
238
|
{t('REVIEWS', 'Reviews')}
|
|
197
239
|
</OText>
|
|
@@ -200,28 +242,37 @@ export const BusinessBasicInformation = (
|
|
|
200
242
|
)}
|
|
201
243
|
</WrapReviews>
|
|
202
244
|
</BusinessInfo>
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
245
|
+
{businessInformationObtained ? (
|
|
246
|
+
<OModal
|
|
247
|
+
titleSectionStyle={styles.modalTitleSectionStyle}
|
|
248
|
+
open={openBusinessInformation}
|
|
249
|
+
onClose={() => setOpenBusinessInformation(false)}
|
|
250
|
+
isNotDecoration>
|
|
251
|
+
{BusinessInformation && (
|
|
252
|
+
<BusinessInformation
|
|
253
|
+
businessState={businessState}
|
|
254
|
+
business={business}
|
|
255
|
+
/>
|
|
256
|
+
)}
|
|
257
|
+
</OModal>
|
|
258
|
+
) : null}
|
|
259
|
+
{businessReviewsObtained ? (
|
|
260
|
+
<OModal
|
|
261
|
+
entireModal
|
|
262
|
+
titleSectionStyle={styles.modalTitleSectionStyle}
|
|
263
|
+
open={openBusinessReviews}
|
|
264
|
+
onClose={() => setOpenBusinessReviews(false)}
|
|
265
|
+
isNotDecoration
|
|
266
|
+
>
|
|
267
|
+
{BusinessReviews && (
|
|
268
|
+
<BusinessReviews
|
|
269
|
+
businessState={businessState}
|
|
270
|
+
businessId={business.id}
|
|
271
|
+
reviews={business.reviews?.reviews}
|
|
272
|
+
/>
|
|
273
|
+
)}
|
|
274
|
+
</OModal>
|
|
275
|
+
) : null}
|
|
225
276
|
</BusinessContainer>
|
|
226
277
|
);
|
|
227
278
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import styled from 'styled-components/native';
|
|
1
|
+
import styled, { css } from 'styled-components/native';
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
3
|
|
|
4
4
|
export const BusinessContainer = styled.View`
|
|
@@ -41,3 +41,30 @@ export const WrapBusinessInfo = styled.TouchableOpacity`
|
|
|
41
41
|
top: 16px;
|
|
42
42
|
end: 39px;
|
|
43
43
|
`;
|
|
44
|
+
|
|
45
|
+
export const TitleWrapper = styled.View`
|
|
46
|
+
width: 100%;
|
|
47
|
+
flex-direction: row;
|
|
48
|
+
align-items: center;
|
|
49
|
+
justify-content: space-between;
|
|
50
|
+
`
|
|
51
|
+
|
|
52
|
+
export const RibbonBox = styled.View`
|
|
53
|
+
margin-left: 5px;
|
|
54
|
+
background-color: ${(props: any) => props.theme.colors.primary};
|
|
55
|
+
padding: 2px 8px;
|
|
56
|
+
max-width: 180px;
|
|
57
|
+
align-self: flex-start;
|
|
58
|
+
|
|
59
|
+
${(props: any) => props.bgColor && css`
|
|
60
|
+
background-color: ${props.bgColor};
|
|
61
|
+
`}
|
|
62
|
+
|
|
63
|
+
${(props: any) => props.isRoundRect && css`
|
|
64
|
+
border-radius: 7.6px;
|
|
65
|
+
`}
|
|
66
|
+
|
|
67
|
+
${(props: any) => props.isCapsule && css`
|
|
68
|
+
border-radius: 50px;
|
|
69
|
+
`}
|
|
70
|
+
`
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
useUtils,
|
|
5
5
|
useOrder,
|
|
6
6
|
useLanguage,
|
|
7
|
+
useConfig
|
|
7
8
|
} from 'ordering-components/native';
|
|
8
9
|
import { OIcon, OText } from '../shared';
|
|
9
10
|
import { StyleSheet, View } from 'react-native';
|
|
@@ -25,18 +26,26 @@ import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome5';
|
|
|
25
26
|
import FastImage from 'react-native-fast-image'
|
|
26
27
|
|
|
27
28
|
export const BusinessControllerUI = (props: BusinessControllerParams) => {
|
|
28
|
-
const {
|
|
29
|
-
business,
|
|
30
|
-
handleClick,
|
|
31
|
-
navigation,
|
|
32
|
-
isBusinessOpen,
|
|
33
|
-
style
|
|
29
|
+
const {
|
|
30
|
+
business,
|
|
31
|
+
handleClick,
|
|
32
|
+
navigation,
|
|
33
|
+
isBusinessOpen,
|
|
34
|
+
style,
|
|
35
|
+
businessHeader,
|
|
36
|
+
businessFeatured,
|
|
37
|
+
businessLogo,
|
|
38
|
+
businessReviews,
|
|
39
|
+
businessDeliveryPrice,
|
|
40
|
+
businessDeliveryTime,
|
|
41
|
+
businessPickupTime,
|
|
42
|
+
businessDistance
|
|
34
43
|
} = props;
|
|
35
44
|
const [{ parsePrice, parseDistance, parseNumber, optimizeImage }] = useUtils();
|
|
36
45
|
const [orderState] = useOrder();
|
|
46
|
+
const [configState] = useConfig();
|
|
37
47
|
const [, t] = useLanguage();
|
|
38
48
|
const theme = useTheme()
|
|
39
|
-
|
|
40
49
|
const styles = StyleSheet.create({
|
|
41
50
|
headerStyle: {
|
|
42
51
|
borderTopLeftRadius: 7.6,
|
|
@@ -116,18 +125,18 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
|
|
|
116
125
|
<FastImage
|
|
117
126
|
style={{ height: 120 }}
|
|
118
127
|
source={{
|
|
119
|
-
|
|
120
|
-
|
|
128
|
+
uri: optimizeImage(businessHeader || business?.header, 'h_500,c_limit'),
|
|
129
|
+
priority: FastImage.priority.normal,
|
|
121
130
|
}}
|
|
122
131
|
resizeMode={FastImage.resizeMode.cover}
|
|
123
132
|
/>
|
|
124
|
-
{business?.featured && (
|
|
133
|
+
{(businessFeatured ?? business?.featured) && (
|
|
125
134
|
<View style={styles.featured}>
|
|
126
135
|
<FontAwesomeIcon name="crown" size={26} color="gold" />
|
|
127
136
|
</View>
|
|
128
137
|
)}
|
|
129
138
|
<BusinessState>
|
|
130
|
-
{!isBusinessOpen && (
|
|
139
|
+
{!isBusinessOpen && (configState?.configs?.preorder_status_enabled?.value === '1') && (
|
|
131
140
|
<View style={styles.businessStateView}>
|
|
132
141
|
<OText
|
|
133
142
|
color={theme.colors.textThird}
|
|
@@ -145,17 +154,17 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
|
|
|
145
154
|
<FastImage
|
|
146
155
|
style={{ width: 56, height: 56 }}
|
|
147
156
|
source={{
|
|
148
|
-
|
|
149
|
-
|
|
157
|
+
uri: optimizeImage(businessLogo || business?.logo, 'h_150,c_limit'),
|
|
158
|
+
priority: FastImage.priority.normal,
|
|
150
159
|
}}
|
|
151
160
|
resizeMode={FastImage.resizeMode.cover}
|
|
152
161
|
/>
|
|
153
162
|
</BusinessLogo>
|
|
154
|
-
{business?.reviews?.total > 0 && (
|
|
163
|
+
{(businessReviews?.reviews?.total > 0 ?? business?.reviews?.total > 0) && (
|
|
155
164
|
<Reviews>
|
|
156
165
|
<OIcon src={theme.images.general.star} width={12} style={styles.starIcon} />
|
|
157
166
|
<OText size={10} style={{ lineHeight: 15 }}>
|
|
158
|
-
{parseNumber(business?.reviews?.total, { separator: '.' })}
|
|
167
|
+
{parseNumber(businessReviews?.reviews?.total ?? business?.reviews?.total, { separator: '.' })}
|
|
159
168
|
</OText>
|
|
160
169
|
</Reviews>
|
|
161
170
|
)}
|
|
@@ -181,15 +190,17 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
|
|
|
181
190
|
</View>
|
|
182
191
|
) : (
|
|
183
192
|
<View style={styles.bullet}>
|
|
184
|
-
|
|
185
|
-
{
|
|
186
|
-
|
|
193
|
+
{orderState?.options?.type === 1 && (
|
|
194
|
+
<OText size={10} color={theme.colors.textSecondary}>
|
|
195
|
+
{`${t('DELIVERY_FEE', 'Delivery fee')} ${parsePrice(businessDeliveryPrice ?? business?.delivery_price) + ' \u2022 '}`}
|
|
196
|
+
</OText>
|
|
197
|
+
)}
|
|
187
198
|
<OText size={10} color={theme.colors.textSecondary}>{`${convertHoursToMinutes(
|
|
188
199
|
orderState?.options?.type === 1
|
|
189
|
-
? business?.delivery_time
|
|
190
|
-
: business?.pickup_time,
|
|
200
|
+
? (businessDeliveryTime ?? business?.delivery_time)
|
|
201
|
+
: (businessPickupTime ?? business?.pickup_time),
|
|
191
202
|
)} \u2022 `}</OText>
|
|
192
|
-
<OText size={10} color={theme.colors.textSecondary}>{parseDistance(business?.distance)}</OText>
|
|
203
|
+
<OText size={10} color={theme.colors.textSecondary}>{parseDistance(businessDistance ?? business?.distance)}</OText>
|
|
193
204
|
</View>
|
|
194
205
|
)}
|
|
195
206
|
</Metadata>
|
|
@@ -58,9 +58,9 @@ export const BusinessListingSearchUI = (props : BusinessSearchParams) => {
|
|
|
58
58
|
const maxDistanceOptions = [1000, 2000, 5000, 'default']
|
|
59
59
|
const maxTimeOptions = [5, 15, 30, 'default']
|
|
60
60
|
const sortItems = [
|
|
61
|
-
{ text: t('PICKED_FOR_YOU', 'Picked for you (default)'), value: '
|
|
61
|
+
{ text: t('PICKED_FOR_YOU', 'Picked for you (default)'), value: 'distance' },
|
|
62
62
|
{ text: t('DELIVERY_TIME', 'Delivery time'), value: 'delivery_time' },
|
|
63
|
-
{ text: t('PICKUP_TIME', 'Pickup time'), value: '
|
|
63
|
+
{ text: t('PICKUP_TIME', 'Pickup time'), value: 'pickup_time' }
|
|
64
64
|
]
|
|
65
65
|
|
|
66
66
|
const styles = StyleSheet.create({
|
|
@@ -137,6 +137,10 @@ export const BusinessListingSearchUI = (props : BusinessSearchParams) => {
|
|
|
137
137
|
}
|
|
138
138
|
}, [filters, openFilters])
|
|
139
139
|
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
handleSearchbusinessAndProducts(true)
|
|
142
|
+
}, [])
|
|
143
|
+
|
|
140
144
|
const MaxSectionItem = ({ title, options, filter }: any) => {
|
|
141
145
|
const parseValue = (option: number) => {
|
|
142
146
|
return filter === 'max_distance'
|
|
@@ -396,7 +400,7 @@ export const BusinessListingSearchUI = (props : BusinessSearchParams) => {
|
|
|
396
400
|
<OText weight='bold' mBottom={7} size={16}>
|
|
397
401
|
{t('SORT', 'Sort')}
|
|
398
402
|
</OText>
|
|
399
|
-
{sortItems?.map(item => (
|
|
403
|
+
{sortItems?.filter(item => !(orderState?.options?.type === 1 && item?.value === 'pickup_time') && !(orderState?.options?.type === 2 && item?.value === 'delivery_time'))?.map(item => (
|
|
400
404
|
<TouchableOpacity
|
|
401
405
|
key={item?.value}
|
|
402
406
|
onPress={() => handleChangeFilters('orderBy', item?.value)}
|