ordering-ui-react-native 0.17.73-release → 0.17.74-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 +1 -1
- package/themes/original/src/components/OrderDetails/index.tsx +12 -19
- package/src/navigators/BottomNavigator.tsx +0 -117
- package/src/navigators/CheckoutNavigator.tsx +0 -66
- package/src/navigators/HomeNavigator.tsx +0 -202
- package/src/navigators/NavigationRef.tsx +0 -7
- package/src/navigators/RootNavigator.tsx +0 -269
- package/src/pages/Account.tsx +0 -34
- package/src/pages/AddressForm.tsx +0 -62
- package/src/pages/AddressList.tsx +0 -24
- package/src/pages/BusinessProductsList.tsx +0 -81
- package/src/pages/BusinessesListing.tsx +0 -43
- package/src/pages/CartList.tsx +0 -49
- package/src/pages/Checkout.tsx +0 -101
- package/src/pages/ForgotPassword.tsx +0 -24
- package/src/pages/Help.tsx +0 -23
- package/src/pages/HelpAccountAndPayment.tsx +0 -23
- package/src/pages/HelpGuide.tsx +0 -23
- package/src/pages/HelpOrder.tsx +0 -23
- package/src/pages/Home.tsx +0 -36
- package/src/pages/IntroductoryTutorial.tsx +0 -170
- package/src/pages/Login.tsx +0 -47
- package/src/pages/MomentOption.tsx +0 -30
- package/src/pages/MultiCheckout.tsx +0 -31
- package/src/pages/MultiOrdersDetails.tsx +0 -27
- package/src/pages/MyOrders.tsx +0 -40
- package/src/pages/NetworkError.tsx +0 -24
- package/src/pages/NotFound.tsx +0 -22
- package/src/pages/OrderDetails.tsx +0 -25
- package/src/pages/ProductDetails.tsx +0 -55
- package/src/pages/Profile.tsx +0 -36
- package/src/pages/ReviewDriver.tsx +0 -30
- package/src/pages/ReviewOrder.tsx +0 -32
- package/src/pages/ReviewProducts.tsx +0 -30
- package/src/pages/Sessions.tsx +0 -22
- package/src/pages/Signup.tsx +0 -53
- package/src/pages/SpinnerLoader.tsx +0 -10
- package/src/pages/Splash.tsx +0 -21
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { Platform } from 'react-native'
|
|
3
|
-
import { createStackNavigator } from '@react-navigation/stack';
|
|
4
|
-
import { useOrder, useSession, useConfig } from 'ordering-components/native';
|
|
5
|
-
import dayjs from 'dayjs'
|
|
6
|
-
import utc from 'dayjs/plugin/utc'
|
|
7
|
-
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter'
|
|
8
|
-
import OneSignal from 'react-native-onesignal';
|
|
9
|
-
import NetInfo from '@react-native-community/netinfo'
|
|
10
|
-
|
|
11
|
-
dayjs.extend(isSameOrAfter)
|
|
12
|
-
dayjs.extend(utc)
|
|
13
|
-
|
|
14
|
-
import Login from '../pages/Login';
|
|
15
|
-
import Signup from '../pages/Signup';
|
|
16
|
-
import Forgot from '../pages/ForgotPassword';
|
|
17
|
-
import Home from '../pages/Home';
|
|
18
|
-
import IntroductoryTutorial from '../pages/IntroductoryTutorial';
|
|
19
|
-
import AddressForm from '../pages/AddressForm';
|
|
20
|
-
import MomentOption from '../pages/MomentOption';
|
|
21
|
-
import Splash from '../pages/Splash';
|
|
22
|
-
import BusinessList from '../pages/BusinessesListing';
|
|
23
|
-
import BusinessProductsList from '../pages/BusinessProductsList';
|
|
24
|
-
import NotFound from '../pages/NotFound'
|
|
25
|
-
import HomeNavigator from './HomeNavigator';
|
|
26
|
-
import settings from '../config.json';
|
|
27
|
-
import NetworkError from '../pages/NetworkError';
|
|
28
|
-
|
|
29
|
-
import * as RootNavigation from '../navigators/NavigationRef';
|
|
30
|
-
import { _retrieveStoreData, _setStoreData } from '../providers/StoreUtil';
|
|
31
|
-
|
|
32
|
-
const Stack = createStackNavigator();
|
|
33
|
-
const RootNavigator = () => {
|
|
34
|
-
const [orderId, setOrderId] = useState(null)
|
|
35
|
-
const [{ auth, loading: sessionLoading }] = useSession();
|
|
36
|
-
const [orderStatus, { changeMoment }] = useOrder();
|
|
37
|
-
const [{ configs, loading: configsLoading }] = useConfig();
|
|
38
|
-
const [loaded, setLoaded] = useState(false);
|
|
39
|
-
const [productLogin, setProductLogin] = useState({})
|
|
40
|
-
const [oneSignalState, setOneSignalState] = useState<any>({
|
|
41
|
-
notification_app: settings.notification_app
|
|
42
|
-
});
|
|
43
|
-
const [ isTutorial, setTutorial] = useState(true)
|
|
44
|
-
const [isPushLoading, setIsPushLoading] = useState({ loading: true })
|
|
45
|
-
const [connectionState, setConnectionState] = useState<{
|
|
46
|
-
connection_status: boolean;
|
|
47
|
-
} | null>(null);
|
|
48
|
-
|
|
49
|
-
const validDate = (date : any) => {
|
|
50
|
-
if (!date) return
|
|
51
|
-
const _date = dayjs(date, 'YYYY-MM-DD HH:mm').isSameOrAfter(dayjs(), 'day')
|
|
52
|
-
? dayjs(date).format('YYYY-MM-DD HH:mm')
|
|
53
|
-
: dayjs().format('YYYY-MM-DD HH:mm')
|
|
54
|
-
return _date
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const oneSignalSetup = async () => {
|
|
58
|
-
setIsPushLoading({ loading: true });
|
|
59
|
-
OneSignal.setLogLevel(6, 0);
|
|
60
|
-
|
|
61
|
-
OneSignal.setAppId(configs?.onesignal_orderingapp_id?.value);
|
|
62
|
-
|
|
63
|
-
if (Platform.OS === 'ios') {
|
|
64
|
-
OneSignal.promptForPushNotificationsWithUserResponse((response : any) => {
|
|
65
|
-
console.log('Prompt response:', response);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
OneSignal.setNotificationOpenedHandler(({ notification }: any) => {
|
|
70
|
-
if(notification?.additionalData?.order_uuid) {
|
|
71
|
-
setOrderId(notification?.additionalData?.order_uuid)
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
OneSignal.addSubscriptionObserver((event: any) => {
|
|
76
|
-
setOneSignalState({ ...oneSignalState, notification_token: event?.to?.userId });
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const deviceState: any = await OneSignal.getDeviceState();
|
|
80
|
-
|
|
81
|
-
if (!deviceState?.isSubscribed) {
|
|
82
|
-
OneSignal.addTrigger("prompt_ios", "true");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
OneSignal.disablePush(false);
|
|
86
|
-
|
|
87
|
-
const data = {
|
|
88
|
-
...oneSignalState,
|
|
89
|
-
notification_token: deviceState?.userId,
|
|
90
|
-
notification_app: settings.notification_app
|
|
91
|
-
}
|
|
92
|
-
setOneSignalState(data);
|
|
93
|
-
setIsPushLoading({ loading: false });
|
|
94
|
-
};
|
|
95
|
-
useEffect(() => {
|
|
96
|
-
if (!loaded && !orderStatus.loading && !isPushLoading.loading) {
|
|
97
|
-
setLoaded(true)
|
|
98
|
-
}
|
|
99
|
-
}, [orderStatus, isPushLoading])
|
|
100
|
-
|
|
101
|
-
useEffect(() => {
|
|
102
|
-
if (orderId && loaded && auth) {
|
|
103
|
-
RootNavigation.navigate('OrderDetails', {
|
|
104
|
-
orderId: orderId,
|
|
105
|
-
isFromRoot: true
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
setOrderId(null)
|
|
109
|
-
}
|
|
110
|
-
}, [loaded, orderId])
|
|
111
|
-
|
|
112
|
-
useEffect(() => {
|
|
113
|
-
const setTutorialLocal = async () => {
|
|
114
|
-
const data = await _retrieveStoreData('isTutorial');
|
|
115
|
-
if(data === false){
|
|
116
|
-
setTutorial(false)
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
setTutorialLocal();
|
|
120
|
-
}, [isTutorial])
|
|
121
|
-
|
|
122
|
-
useEffect(() => {
|
|
123
|
-
if (!sessionLoading && !isPushLoading.loading && !auth) {
|
|
124
|
-
setLoaded(!auth)
|
|
125
|
-
}
|
|
126
|
-
}, [sessionLoading, isPushLoading])
|
|
127
|
-
|
|
128
|
-
useEffect(() => {
|
|
129
|
-
const _currentDate = dayjs.utc(validDate(orderStatus.options?.moment)).local()
|
|
130
|
-
if (!_currentDate) {
|
|
131
|
-
return
|
|
132
|
-
}
|
|
133
|
-
const selected = dayjs(_currentDate, 'YYYY-MM-DD HH:mm')
|
|
134
|
-
const now = dayjs()
|
|
135
|
-
const secondsDiff = selected.diff(now, 'seconds')
|
|
136
|
-
const checkTime = setTimeout(() => {
|
|
137
|
-
changeMoment(null)
|
|
138
|
-
}, secondsDiff * 1000)
|
|
139
|
-
|
|
140
|
-
return () => {
|
|
141
|
-
clearTimeout(checkTime)
|
|
142
|
-
}
|
|
143
|
-
}, [orderStatus.options?.moment])
|
|
144
|
-
|
|
145
|
-
useEffect(() => {
|
|
146
|
-
if (configsLoading) return
|
|
147
|
-
if (configs?.onesignal_orderingapp_id?.value) {
|
|
148
|
-
oneSignalSetup();
|
|
149
|
-
}
|
|
150
|
-
if (!!!configs?.onesignal_orderingapp_id?.value) {
|
|
151
|
-
setIsPushLoading({ loading: false });
|
|
152
|
-
}
|
|
153
|
-
}, [configsLoading]);
|
|
154
|
-
|
|
155
|
-
let netInfoSuscription : any = null
|
|
156
|
-
useEffect(() => {
|
|
157
|
-
netInfoSuscription = NetInfo.addEventListener(handleConnectivityChange);
|
|
158
|
-
|
|
159
|
-
return () => {
|
|
160
|
-
netInfoSuscription && netInfoSuscription()
|
|
161
|
-
}
|
|
162
|
-
}, []);
|
|
163
|
-
|
|
164
|
-
const handleConnectivityChange = (state : any) => {
|
|
165
|
-
setConnectionState({ connection_status: state.isConnected });
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
return (
|
|
169
|
-
<Stack.Navigator>
|
|
170
|
-
{
|
|
171
|
-
!loaded && (
|
|
172
|
-
<Stack.Screen
|
|
173
|
-
name="Splash"
|
|
174
|
-
component={Splash}
|
|
175
|
-
options={{ headerShown: false }}
|
|
176
|
-
/>
|
|
177
|
-
)
|
|
178
|
-
}
|
|
179
|
-
{
|
|
180
|
-
loaded && connectionState?.connection_status && (
|
|
181
|
-
<>
|
|
182
|
-
{!auth ? (
|
|
183
|
-
<>
|
|
184
|
-
{ isTutorial ? (
|
|
185
|
-
<Stack.Screen
|
|
186
|
-
name="IntroductoryTutorial"
|
|
187
|
-
component={IntroductoryTutorial}
|
|
188
|
-
options={{ headerShown: false }}
|
|
189
|
-
initialParams={{ setTutorial }}
|
|
190
|
-
/>):(
|
|
191
|
-
<Stack.Screen
|
|
192
|
-
name="Home"
|
|
193
|
-
component={Home}
|
|
194
|
-
options={{ headerShown: false }}
|
|
195
|
-
/>)}
|
|
196
|
-
<Stack.Screen
|
|
197
|
-
name="Login"
|
|
198
|
-
component={Login}
|
|
199
|
-
options={{ headerShown: false }}
|
|
200
|
-
listeners={{
|
|
201
|
-
state: (e: any) => {
|
|
202
|
-
setProductLogin(e.data.state.routes.find((object: any) => object?.params?.product)?.params?.product)
|
|
203
|
-
}
|
|
204
|
-
}}
|
|
205
|
-
initialParams={{ notification_state: oneSignalState }}
|
|
206
|
-
/>
|
|
207
|
-
<Stack.Screen
|
|
208
|
-
name="Signup"
|
|
209
|
-
component={Signup}
|
|
210
|
-
options={{ headerShown: false }}
|
|
211
|
-
initialParams={{ notification_state: oneSignalState }}
|
|
212
|
-
/>
|
|
213
|
-
<Stack.Screen
|
|
214
|
-
name="Forgot"
|
|
215
|
-
component={Forgot}
|
|
216
|
-
options={{ headerShown: false }}
|
|
217
|
-
/>
|
|
218
|
-
<Stack.Screen
|
|
219
|
-
name="AddressForm"
|
|
220
|
-
component={AddressForm}
|
|
221
|
-
options={{ headerShown: false }}
|
|
222
|
-
/>
|
|
223
|
-
<Stack.Screen
|
|
224
|
-
name='BusinessList'
|
|
225
|
-
component={BusinessList}
|
|
226
|
-
options={{ headerShown: false }}
|
|
227
|
-
/>
|
|
228
|
-
<Stack.Screen
|
|
229
|
-
name='Business'
|
|
230
|
-
component={BusinessProductsList}
|
|
231
|
-
options={{ headerShown: false }}
|
|
232
|
-
initialParams={{ setProductLogin }}
|
|
233
|
-
/>
|
|
234
|
-
<Stack.Screen
|
|
235
|
-
name='MomentOption'
|
|
236
|
-
component={MomentOption}
|
|
237
|
-
options={{ headerShown: false }}
|
|
238
|
-
/>
|
|
239
|
-
</>
|
|
240
|
-
) : (
|
|
241
|
-
<>
|
|
242
|
-
<Stack.Screen
|
|
243
|
-
name='MyAccount'
|
|
244
|
-
component={HomeNavigator}
|
|
245
|
-
options={{ headerShown: false }}
|
|
246
|
-
initialParams={{ productLogin }}
|
|
247
|
-
/>
|
|
248
|
-
</>
|
|
249
|
-
)}
|
|
250
|
-
</>
|
|
251
|
-
)
|
|
252
|
-
}
|
|
253
|
-
{connectionState?.connection_status === false ? (
|
|
254
|
-
<Stack.Screen
|
|
255
|
-
name='NetworkError'
|
|
256
|
-
component={NetworkError}
|
|
257
|
-
options={{ headerShown: false }}
|
|
258
|
-
/>
|
|
259
|
-
) : (
|
|
260
|
-
<Stack.Screen
|
|
261
|
-
name='NotFound'
|
|
262
|
-
component={NotFound}
|
|
263
|
-
options={{ headerShown: false }}
|
|
264
|
-
/>
|
|
265
|
-
)}
|
|
266
|
-
</Stack.Navigator>
|
|
267
|
-
);
|
|
268
|
-
};
|
|
269
|
-
export default RootNavigator;
|
package/src/pages/Account.tsx
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import styled from 'styled-components/native';
|
|
3
|
-
import { Platform } from 'react-native';
|
|
4
|
-
import { Container } from '../layouts/Container'
|
|
5
|
-
import { Account as AccountController } from '../components/Account'
|
|
6
|
-
|
|
7
|
-
const KeyboardView = styled.KeyboardAvoidingView`
|
|
8
|
-
flex-grow: 1;
|
|
9
|
-
`;
|
|
10
|
-
interface Props {
|
|
11
|
-
navigation: any;
|
|
12
|
-
route: any;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const Account = (props: Props) => {
|
|
16
|
-
const accountProps = {
|
|
17
|
-
...props,
|
|
18
|
-
useSessionUser: true,
|
|
19
|
-
useValidationFields: true
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<KeyboardView
|
|
24
|
-
enabled
|
|
25
|
-
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
26
|
-
>
|
|
27
|
-
<Container>
|
|
28
|
-
<AccountController {...accountProps} />
|
|
29
|
-
</Container>
|
|
30
|
-
</KeyboardView>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default Account
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react'
|
|
2
|
-
import styled from 'styled-components/native'
|
|
3
|
-
import { Platform } from 'react-native';
|
|
4
|
-
import { AddressForm as AddressFormController } from '../components/AddressForm'
|
|
5
|
-
import { SafeAreaContainer } from '../layouts/SafeAreaContainer'
|
|
6
|
-
import { _retrieveStoreData } from '../providers/StoreUtil';
|
|
7
|
-
|
|
8
|
-
const KeyboardView = styled.KeyboardAvoidingView`
|
|
9
|
-
flex-grow: 1;
|
|
10
|
-
flex-shrink: 1;
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
|
-
const AddressForm = ({ navigation, route }: any) => {
|
|
14
|
-
const AddressFormProps = {
|
|
15
|
-
navigation,
|
|
16
|
-
route,
|
|
17
|
-
address: route?.params?.address,
|
|
18
|
-
addressId: route?.params?.address?.id,
|
|
19
|
-
isEditing: route?.params?.isEditing,
|
|
20
|
-
addressesList: route?.params?.addressList,
|
|
21
|
-
onSaveAddress: route?.params?.onSaveAddress,
|
|
22
|
-
isSelectedAfterAdd: true,
|
|
23
|
-
isGuestUser: route?.params?.isGuestUser,
|
|
24
|
-
isFromBusinesses: route?.params?.isFromBusinesses,
|
|
25
|
-
isFromProductsList: route?.params?.isFromProductsList,
|
|
26
|
-
isFromCheckout: route?.params?.isFromCheckout,
|
|
27
|
-
hasAddressDefault: route?.params?.hasAddressDefault,
|
|
28
|
-
afterSignup: route?.params?.afterSignup,
|
|
29
|
-
businessId: route.params?.businessId,
|
|
30
|
-
categoryId: route.params?.categoryId,
|
|
31
|
-
productId: route.params?.productId,
|
|
32
|
-
store: route.params?.store
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const [isGuestFromStore, setIsGuestFromStore] = useState(false)
|
|
36
|
-
|
|
37
|
-
const getDataFromStorage = async () => {
|
|
38
|
-
const value = await _retrieveStoreData('isGuestUser');
|
|
39
|
-
setIsGuestFromStore(value);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
getDataFromStorage()
|
|
44
|
-
}, [])
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<SafeAreaContainer>
|
|
48
|
-
<KeyboardView
|
|
49
|
-
enabled
|
|
50
|
-
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
51
|
-
>
|
|
52
|
-
<AddressFormController
|
|
53
|
-
{ ...AddressFormProps }
|
|
54
|
-
isGuestFromStore={isGuestFromStore}
|
|
55
|
-
useValidationFileds
|
|
56
|
-
/>
|
|
57
|
-
</KeyboardView>
|
|
58
|
-
</SafeAreaContainer>
|
|
59
|
-
)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default AddressForm
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { AddressList as AddressListController } from '../components/AddressList'
|
|
3
|
-
import { useSession } from 'ordering-components/native'
|
|
4
|
-
|
|
5
|
-
const AddressList = ({ route, navigation }: any) => {
|
|
6
|
-
const [{ user }] = useSession()
|
|
7
|
-
const addressListProps = {
|
|
8
|
-
navigation,
|
|
9
|
-
route,
|
|
10
|
-
userId: user?.id,
|
|
11
|
-
isGoBack: route?.params?.isGoBack,
|
|
12
|
-
isFromBusinesses: route?.params?.isFromBusinesses,
|
|
13
|
-
isFromProductsList: route?.params?.isFromProductsList,
|
|
14
|
-
isFromCheckout: route?.params?.isFromCheckout,
|
|
15
|
-
isFromProfile: route?.params?.isFromProfile,
|
|
16
|
-
afterSignup: route?.params?.afterSignup
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<AddressListController {...addressListProps} />
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default AddressList
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { useApi } from 'ordering-components/native'
|
|
3
|
-
import { BusinessProductsListing as BusinessProductsListController } from '../components/BusinessProductsListing'
|
|
4
|
-
import styled from 'styled-components/native'
|
|
5
|
-
import { useTheme } from 'styled-components/native'
|
|
6
|
-
|
|
7
|
-
const BusinessProductsList = (props: any) => {
|
|
8
|
-
const theme = useTheme()
|
|
9
|
-
const [ordering] = useApi()
|
|
10
|
-
|
|
11
|
-
const store = props.route.params?.store || props.route.params?.productLogin?.slug
|
|
12
|
-
const header = props.route.params?.header
|
|
13
|
-
const logo = props.route.params?.logo
|
|
14
|
-
const product = props.route.params?.productLogin
|
|
15
|
-
const businessId = props.route.params?.businessId
|
|
16
|
-
const categoryId = props.route.params?.categoryId
|
|
17
|
-
const productId = props.route.params?.productId
|
|
18
|
-
|
|
19
|
-
const businessProductsProps = {
|
|
20
|
-
...props,
|
|
21
|
-
ordering,
|
|
22
|
-
isSearchByName: true,
|
|
23
|
-
isSearchByDescription: true,
|
|
24
|
-
slug: store,
|
|
25
|
-
businessProps: [
|
|
26
|
-
'id',
|
|
27
|
-
'name',
|
|
28
|
-
'header',
|
|
29
|
-
'logo',
|
|
30
|
-
'name',
|
|
31
|
-
'open',
|
|
32
|
-
'about',
|
|
33
|
-
'description',
|
|
34
|
-
'ribbon',
|
|
35
|
-
'address',
|
|
36
|
-
'location',
|
|
37
|
-
'schedule',
|
|
38
|
-
'service_fee',
|
|
39
|
-
'delivery_price',
|
|
40
|
-
'distance',
|
|
41
|
-
'delivery_time',
|
|
42
|
-
'gallery',
|
|
43
|
-
'pickup_time',
|
|
44
|
-
'reviews',
|
|
45
|
-
'featured',
|
|
46
|
-
'offers',
|
|
47
|
-
'food',
|
|
48
|
-
'laundry',
|
|
49
|
-
'alcohol',
|
|
50
|
-
'groceries',
|
|
51
|
-
'slug',
|
|
52
|
-
'products',
|
|
53
|
-
'zones',
|
|
54
|
-
'timezone'
|
|
55
|
-
],
|
|
56
|
-
handleSearchRedirect: () => {
|
|
57
|
-
props.navigation.navigate('BusinessList')
|
|
58
|
-
},
|
|
59
|
-
onProductRedirect: ({ slug, category, product }: any) => {},
|
|
60
|
-
onCheckoutRedirect: (cartUuid: any) => {},
|
|
61
|
-
logo,
|
|
62
|
-
header,
|
|
63
|
-
product,
|
|
64
|
-
productId,
|
|
65
|
-
categoryId,
|
|
66
|
-
businessId
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const BusinessProductsListView = styled.SafeAreaView`
|
|
70
|
-
flex: 1;
|
|
71
|
-
background-color: ${theme.colors.backgroundPage};
|
|
72
|
-
`
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<BusinessProductsListView>
|
|
76
|
-
<BusinessProductsListController {...businessProductsProps} />
|
|
77
|
-
</BusinessProductsListView>
|
|
78
|
-
)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export default BusinessProductsList
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react'
|
|
2
|
-
import { BusinessesListing as BusinessListingController } from '../components/BusinessesListing'
|
|
3
|
-
import styled from 'styled-components/native'
|
|
4
|
-
import { useTheme } from 'styled-components/native'
|
|
5
|
-
|
|
6
|
-
const BusinessesListing = (props: any) => {
|
|
7
|
-
const theme = useTheme()
|
|
8
|
-
const businessId = props.route.params?.businessId
|
|
9
|
-
const categoryId = props.route.params?.categoryId
|
|
10
|
-
const productId = props.route.params?.productId
|
|
11
|
-
const store = props.route.params?.store
|
|
12
|
-
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
if (store) {
|
|
15
|
-
props.navigation.navigate('Business', { store, businessId, categoryId, productId })
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
}, [businessId, categoryId, productId, store])
|
|
19
|
-
|
|
20
|
-
const BusinessesListingProps = {
|
|
21
|
-
...props,
|
|
22
|
-
navigation: props?.navigation,
|
|
23
|
-
isSearchByName: true,
|
|
24
|
-
isSearchByDescription: true,
|
|
25
|
-
propsToFetch: ['id', 'name', 'header', 'logo', 'ribbon', 'location', 'schedule', 'open', 'delivery_price', 'distance', 'delivery_time', 'pickup_time', 'reviews', 'featured', 'offers', 'food', 'laundry', 'alcohol', 'groceries', 'slug'],
|
|
26
|
-
onBusinessClick: (business: any) => {
|
|
27
|
-
props.navigation.navigate('Business', { store: store || business.slug, header: business.header, logo: business.logo })
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const BusinessListView = styled.SafeAreaView`
|
|
32
|
-
flex: 1;
|
|
33
|
-
background-color: ${theme.colors.backgroundPage};
|
|
34
|
-
`
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<BusinessListView>
|
|
38
|
-
<BusinessListingController {...BusinessesListingProps} />
|
|
39
|
-
</BusinessListView>
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default BusinessesListing
|
package/src/pages/CartList.tsx
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useFocusEffect } from '@react-navigation/native'
|
|
3
|
-
import styled from 'styled-components/native';
|
|
4
|
-
import { useOrder } from 'ordering-components/native';
|
|
5
|
-
import { Platform } from 'react-native';
|
|
6
|
-
import { CartContent } from '../components/CartContent';
|
|
7
|
-
import { Container } from '../layouts/Container'
|
|
8
|
-
|
|
9
|
-
const KeyboardView = styled.KeyboardAvoidingView`
|
|
10
|
-
flex-grow: 1;
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
|
-
interface Props {
|
|
14
|
-
navigation: any;
|
|
15
|
-
route: any;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const CartList = (props: Props) => {
|
|
19
|
-
const [{ carts }, { refreshOrderOptions }] = useOrder();
|
|
20
|
-
const cartsList = (carts && Object.values(carts).filter((cart: any) => cart.products.length > 0)) || []
|
|
21
|
-
|
|
22
|
-
useFocusEffect(
|
|
23
|
-
React.useCallback(() => {
|
|
24
|
-
refreshOrderOptions()
|
|
25
|
-
}, [props.navigation])
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
const cartProps = {
|
|
29
|
-
...props,
|
|
30
|
-
carts: cartsList,
|
|
31
|
-
isOrderStateCarts: !!carts,
|
|
32
|
-
onNavigationRedirect: (route: string, params: any) => props.navigation.navigate(route, params)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<>
|
|
37
|
-
<KeyboardView
|
|
38
|
-
enabled
|
|
39
|
-
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
40
|
-
>
|
|
41
|
-
<Container>
|
|
42
|
-
<CartContent {...cartProps} />
|
|
43
|
-
</Container>
|
|
44
|
-
</KeyboardView>
|
|
45
|
-
</>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export default CartList;
|
package/src/pages/Checkout.tsx
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Platform } from 'react-native';
|
|
3
|
-
import { Checkout } from '../components/Checkout';
|
|
4
|
-
|
|
5
|
-
import { initStripe, useConfirmPayment } from '@stripe/stripe-react-native';
|
|
6
|
-
import styled from 'styled-components/native';
|
|
7
|
-
|
|
8
|
-
import { useOrder, useLanguage, ToastType, useToast } from 'ordering-components/native';
|
|
9
|
-
|
|
10
|
-
const stripePaymentOptions = ['stripe', 'stripe_direct', 'stripe_connect', 'google_pay', 'apple_pay'];
|
|
11
|
-
|
|
12
|
-
const KeyboardView = styled.KeyboardAvoidingView`
|
|
13
|
-
flex: 1;
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
export const CheckoutPage = (props: any) => {
|
|
17
|
-
const [, { showToast }] = useToast();
|
|
18
|
-
const [, t] = useLanguage();
|
|
19
|
-
const [orderState, { confirmCart, changeMoment }] = useOrder();
|
|
20
|
-
const { confirmPayment, loading: confirmPaymentLoading } = useConfirmPayment();
|
|
21
|
-
const checkoutProps = {
|
|
22
|
-
...props,
|
|
23
|
-
cartUuid: props?.cartUuid || props.route?.params?.cartUuid,
|
|
24
|
-
businessLogo: props.route?.params?.businessLogo,
|
|
25
|
-
businessName: props.route?.params?.businessName,
|
|
26
|
-
cartTotal: props.route?.params?.cartTotal,
|
|
27
|
-
stripePaymentOptions,
|
|
28
|
-
onPlaceOrderClick: async (data: any, paymethod: any, cart: any) => {
|
|
29
|
-
if (cart?.order?.uuid) {
|
|
30
|
-
if (orderState?.options?.moment) {
|
|
31
|
-
changeMoment(null);
|
|
32
|
-
}
|
|
33
|
-
props.navigation.navigate('OrderDetails', { orderId: cart.order?.uuid, isFromCheckout: true });
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (cart?.status === 2 && stripePaymentOptions.includes(paymethod?.gateway)) {
|
|
38
|
-
const clientSecret = cart?.paymethod_data?.result?.client_secret;
|
|
39
|
-
const paymentMethodId = paymethod?.gateway === 'stripe_connect'
|
|
40
|
-
? cart.paymethod_data?.result?.payment_method_id
|
|
41
|
-
: cart.paymethod_data?.data?.source_id
|
|
42
|
-
const stripeAccountId = paymethod?.paymethod?.credentials?.user;
|
|
43
|
-
const publicKey = paymethod?.paymethod?.credentials?.publishable;
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
const stripeParams = stripeAccountId
|
|
47
|
-
? { publishableKey: publicKey, stripeAccountId: stripeAccountId}
|
|
48
|
-
: { publishableKey: publicKey };
|
|
49
|
-
initStripe(stripeParams);
|
|
50
|
-
} catch (error: any) {
|
|
51
|
-
showToast(ToastType.Error, error?.toString() || error.message)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
const { paymentIntent, error } = await confirmPayment(clientSecret, {
|
|
56
|
-
type: 'Card',
|
|
57
|
-
paymentMethodId
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
if (error) {
|
|
61
|
-
showToast(ToastType.Error, error.message)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
props.handleIsRedirect && props.handleIsRedirect(true);
|
|
65
|
-
try {
|
|
66
|
-
const confirmCartRes = await confirmCart(cart?.uuid)
|
|
67
|
-
if (confirmCartRes.error) {
|
|
68
|
-
showToast(ToastType.Error, confirmCartRes.error.message)
|
|
69
|
-
}
|
|
70
|
-
if (confirmCartRes.result.order?.uuid) {
|
|
71
|
-
props.navigation.navigate('OrderDetails', { orderId: confirmCartRes.result.order.uuid, isFromCheckout: true })
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
} catch (error: any) {
|
|
75
|
-
showToast(ToastType.Error, error?.toString() || error.message)
|
|
76
|
-
}
|
|
77
|
-
return
|
|
78
|
-
} catch (error: any) {
|
|
79
|
-
const e = error?.message?.toLowerCase() === 'failed'
|
|
80
|
-
? t('FAILED_PAYMENT', 'The payment has failed')
|
|
81
|
-
: error?.toString() || error.message
|
|
82
|
-
showToast(ToastType.Error, e)
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
onNavigationRedirect: (page: string, params: any) => {
|
|
87
|
-
if (!page) return
|
|
88
|
-
props.navigation.navigate(page, params);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return (
|
|
92
|
-
<KeyboardView
|
|
93
|
-
enabled
|
|
94
|
-
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
95
|
-
>
|
|
96
|
-
<Checkout {...checkoutProps} />
|
|
97
|
-
</KeyboardView>
|
|
98
|
-
)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export default CheckoutPage;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Platform } from 'react-native';
|
|
3
|
-
import styled from 'styled-components/native';
|
|
4
|
-
import { ForgotPasswordForm } from '../components/ForgotPasswordForm';
|
|
5
|
-
import { Container } from '../layouts/Container';
|
|
6
|
-
|
|
7
|
-
const KeyboardView = styled.KeyboardAvoidingView`
|
|
8
|
-
flex: 1;
|
|
9
|
-
`;
|
|
10
|
-
|
|
11
|
-
export const ForgotPassword = (props: any) => {
|
|
12
|
-
return (
|
|
13
|
-
<KeyboardView
|
|
14
|
-
enabled
|
|
15
|
-
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
16
|
-
>
|
|
17
|
-
<Container>
|
|
18
|
-
<ForgotPasswordForm {...props} />
|
|
19
|
-
</Container>
|
|
20
|
-
</KeyboardView>
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default ForgotPassword;
|