ordering-ui-react-native 0.21.27 → 0.21.29
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/business/src/components/NewOrderNotification/index.tsx +80 -79
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +9 -7
- package/themes/business/src/components/OrdersOption/index.tsx +83 -1
- package/themes/original/src/components/Checkout/index.tsx +4 -4
- package/themes/original/src/components/OrderDetails/index.tsx +17 -22
- package/themes/original/src/components/OrderProgress/index.tsx +5 -3
- package/themes/original/src/components/ProductForm/index.tsx +1 -1
- package/themes/original/src/utils/index.tsx +113 -0
- 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,117 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { View, Platform, PlatformIOSStatic } from 'react-native'
|
|
3
|
-
import { useOrder } from 'ordering-components/native'
|
|
4
|
-
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs'
|
|
5
|
-
import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
|
|
6
|
-
import MaterialIcon from 'react-native-vector-icons/MaterialIcons'
|
|
7
|
-
import styled from 'styled-components/native'
|
|
8
|
-
|
|
9
|
-
import { OText } from '../components/shared'
|
|
10
|
-
import BusinessList from '../pages/BusinessesListing'
|
|
11
|
-
import MyOrders from '../pages/MyOrders'
|
|
12
|
-
import CartList from '../pages/CartList'
|
|
13
|
-
import Profile from '../pages/Profile'
|
|
14
|
-
import { useTheme } from 'styled-components/native'
|
|
15
|
-
|
|
16
|
-
const CartsLenght = styled.View`
|
|
17
|
-
width: 25px;
|
|
18
|
-
height: 25px;
|
|
19
|
-
background-color: ${(props: any) => props.theme.colors.primary};
|
|
20
|
-
display: flex;
|
|
21
|
-
justify-content: center;
|
|
22
|
-
align-items: center;
|
|
23
|
-
position: absolute;
|
|
24
|
-
right: 0;
|
|
25
|
-
`
|
|
26
|
-
|
|
27
|
-
const Tab = createMaterialBottomTabNavigator();
|
|
28
|
-
|
|
29
|
-
const BottomNavigator = () => {
|
|
30
|
-
const theme = useTheme()
|
|
31
|
-
const [{ carts }] = useOrder()
|
|
32
|
-
const cartsList = (carts && Object.values(carts).filter((cart: any) => cart.products.length > 0)) || []
|
|
33
|
-
const isIos = Platform.OS === 'ios'
|
|
34
|
-
const platformIOS = Platform as PlatformIOSStatic
|
|
35
|
-
const androidStyles = isIos
|
|
36
|
-
? platformIOS.isPad
|
|
37
|
-
? { paddingBottom: 30 }
|
|
38
|
-
: {}
|
|
39
|
-
: {height: 40, position: 'relative', bottom: 15}
|
|
40
|
-
return (
|
|
41
|
-
<Tab.Navigator
|
|
42
|
-
initialRouteName="BusinessList"
|
|
43
|
-
activeColor={theme.colors.primary}
|
|
44
|
-
barStyle={{ backgroundColor: theme.colors.white, ...androidStyles }}
|
|
45
|
-
labeled={false}
|
|
46
|
-
inactiveColor={theme.colors.disabled}
|
|
47
|
-
>
|
|
48
|
-
<Tab.Screen
|
|
49
|
-
name="BusinessList"
|
|
50
|
-
component={BusinessList}
|
|
51
|
-
options={{
|
|
52
|
-
tabBarIcon:
|
|
53
|
-
({ color }: any) => (
|
|
54
|
-
<View style={{ width: 50, height: 50, justifyContent: !isIos ? 'flex-start' : 'space-evenly', position: 'relative', bottom: !isIos ? 10 : 0 }}>
|
|
55
|
-
<MaterialCommunityIcon name='home' size={46} color={color} />
|
|
56
|
-
</View>
|
|
57
|
-
)
|
|
58
|
-
}}
|
|
59
|
-
/>
|
|
60
|
-
<Tab.Screen
|
|
61
|
-
name="MyOrders"
|
|
62
|
-
component={MyOrders}
|
|
63
|
-
options={
|
|
64
|
-
{
|
|
65
|
-
tabBarIcon:
|
|
66
|
-
({ color }: any) => (
|
|
67
|
-
<View style={{ width: 50, height: 50, justifyContent: !isIos ? 'flex-start' : 'space-evenly', position: 'relative', bottom: !isIos ? 10 : 0 }}>
|
|
68
|
-
<MaterialIcon name='format-list-bulleted' size={46} color={color} />
|
|
69
|
-
</View>
|
|
70
|
-
),
|
|
71
|
-
}}
|
|
72
|
-
/>
|
|
73
|
-
<Tab.Screen
|
|
74
|
-
name="Cart"
|
|
75
|
-
component={CartList}
|
|
76
|
-
options={{
|
|
77
|
-
tabBarIcon:
|
|
78
|
-
({ color }: any) => (
|
|
79
|
-
<View style={{
|
|
80
|
-
width: 50,
|
|
81
|
-
height: 50,
|
|
82
|
-
justifyContent: !isIos ? 'flex-start' : 'space-evenly',
|
|
83
|
-
position: 'relative',
|
|
84
|
-
bottom: !isIos ? 10 : 0
|
|
85
|
-
}}
|
|
86
|
-
>
|
|
87
|
-
<MaterialIcon name='shopping-basket' size={46} color={color} />
|
|
88
|
-
{cartsList.length > 0 && (
|
|
89
|
-
<CartsLenght style={{ borderRadius: 100 / 2 }}>
|
|
90
|
-
<OText
|
|
91
|
-
color={theme.colors.white}
|
|
92
|
-
>
|
|
93
|
-
{cartsList.length}
|
|
94
|
-
</OText>
|
|
95
|
-
</CartsLenght>
|
|
96
|
-
)}
|
|
97
|
-
</View>
|
|
98
|
-
)
|
|
99
|
-
}}
|
|
100
|
-
/>
|
|
101
|
-
<Tab.Screen
|
|
102
|
-
name="Profile"
|
|
103
|
-
component={Profile}
|
|
104
|
-
options={{
|
|
105
|
-
tabBarIcon:
|
|
106
|
-
({ color }: any) => (
|
|
107
|
-
<View style={{ width: 50, height: 50, justifyContent: !isIos ? 'flex-start' : 'space-evenly', position: 'relative', bottom: !isIos ? 10 : 0 }}>
|
|
108
|
-
<MaterialIcon name='person' size={46} color={color} />
|
|
109
|
-
</View>
|
|
110
|
-
)
|
|
111
|
-
}}
|
|
112
|
-
/>
|
|
113
|
-
</Tab.Navigator>
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export default BottomNavigator
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { createStackNavigator } from "@react-navigation/stack";
|
|
3
|
-
|
|
4
|
-
import AddressList from '../pages/AddressList'
|
|
5
|
-
import AddressForm from '../pages/AddressForm'
|
|
6
|
-
import CartList from '../pages/CartList'
|
|
7
|
-
import CheckoutPage from '../pages/Checkout';
|
|
8
|
-
import BusinessProductsList from '../pages/BusinessProductsList';
|
|
9
|
-
import MultiCheckout from '../pages/MultiCheckout';
|
|
10
|
-
|
|
11
|
-
const Stack = createStackNavigator();
|
|
12
|
-
|
|
13
|
-
const CheckoutNavigator = (props: any) => {
|
|
14
|
-
const {
|
|
15
|
-
navigation,
|
|
16
|
-
route
|
|
17
|
-
} = props;
|
|
18
|
-
|
|
19
|
-
const cartUuid = route?.params?.cartUuid
|
|
20
|
-
|
|
21
|
-
const checkoutProps = {
|
|
22
|
-
navigation,
|
|
23
|
-
route,
|
|
24
|
-
cartUuid: route?.params?.cartUuid
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<Stack.Navigator>
|
|
29
|
-
{!cartUuid && (
|
|
30
|
-
<Stack.Screen
|
|
31
|
-
name="Cart"
|
|
32
|
-
component={CartList}
|
|
33
|
-
options={{ headerShown: false }}
|
|
34
|
-
/>
|
|
35
|
-
)}
|
|
36
|
-
<Stack.Screen
|
|
37
|
-
name="CheckoutPage"
|
|
38
|
-
children={() => <CheckoutPage {...checkoutProps} />}
|
|
39
|
-
options={{ headerShown: false }}
|
|
40
|
-
/>
|
|
41
|
-
<Stack.Screen
|
|
42
|
-
name="Business"
|
|
43
|
-
component={BusinessProductsList}
|
|
44
|
-
options={{ headerShown: false }}
|
|
45
|
-
/>
|
|
46
|
-
<Stack.Screen
|
|
47
|
-
name="AddressList"
|
|
48
|
-
component={AddressList}
|
|
49
|
-
options={{ headerShown: false }}
|
|
50
|
-
initialParams={{isFromCheckout: true}}
|
|
51
|
-
/>
|
|
52
|
-
<Stack.Screen
|
|
53
|
-
name="AddressForm"
|
|
54
|
-
component={AddressForm}
|
|
55
|
-
options={{ headerShown: false }}
|
|
56
|
-
/>
|
|
57
|
-
<Stack.Screen
|
|
58
|
-
name="MultiCheckout"
|
|
59
|
-
children={() => <MultiCheckout {...checkoutProps} />}
|
|
60
|
-
options={{ headerShown: false }}
|
|
61
|
-
/>
|
|
62
|
-
</Stack.Navigator>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export default CheckoutNavigator;
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { AppState } from 'react-native'
|
|
3
|
-
import { createStackNavigator } from "@react-navigation/stack";
|
|
4
|
-
import { useSession, useOrder, useWebsocket } from 'ordering-components/native';
|
|
5
|
-
import BottomNavigator from '../navigators/BottomNavigator';
|
|
6
|
-
import RootNavigator from '../navigators/RootNavigator';
|
|
7
|
-
import CheckoutNavigator from '../navigators/CheckoutNavigator';
|
|
8
|
-
import BackgroundTimer from 'react-native-background-timer';
|
|
9
|
-
|
|
10
|
-
import AddressList from '../pages/AddressList';
|
|
11
|
-
import AddressForm from '../pages/AddressForm';
|
|
12
|
-
import OrderDetails from '../pages/OrderDetails';
|
|
13
|
-
import BusinessProductsList from '../pages/BusinessProductsList';
|
|
14
|
-
import ReviewOrder from '../pages/ReviewOrder'
|
|
15
|
-
import ReviewProducts from '../pages/ReviewProducts';
|
|
16
|
-
import ReviewDriver from '../pages/ReviewDriver'
|
|
17
|
-
import MomentOption from '../pages/MomentOption'
|
|
18
|
-
import Account from '../pages/Account'
|
|
19
|
-
import Help from '../pages/Help'
|
|
20
|
-
import HelpOrder from '../pages/HelpOrder'
|
|
21
|
-
import HelpGuide from '../pages/HelpGuide'
|
|
22
|
-
import HelpAccountAndPayment from '../pages/HelpAccountAndPayment'
|
|
23
|
-
import Sessions from '../pages/Sessions';
|
|
24
|
-
import Splash from '../pages/Splash';
|
|
25
|
-
import ProductDetails from '../pages/ProductDetails';
|
|
26
|
-
import MultiOrdersDetails from '../pages/MultiOrdersDetails';
|
|
27
|
-
const Stack = createStackNavigator();
|
|
28
|
-
|
|
29
|
-
const HomeNavigator = (e : any) => {
|
|
30
|
-
const [orderState] = useOrder();
|
|
31
|
-
const [{ auth, user }] = useSession();
|
|
32
|
-
const socket = useWebsocket();
|
|
33
|
-
|
|
34
|
-
const appState = React.useRef(AppState.currentState);
|
|
35
|
-
let interval: any
|
|
36
|
-
|
|
37
|
-
const _handleAppStateChange = (nextAppState: any) => {
|
|
38
|
-
if (appState.current.match(/inactive|background/) && nextAppState === 'active') {
|
|
39
|
-
BackgroundTimer.clearInterval(interval)
|
|
40
|
-
}else{
|
|
41
|
-
interval = BackgroundTimer.setInterval(()=>{
|
|
42
|
-
const ordersRoom = user?.level === 0 ? 'orders' : `orders_${user?.id}`
|
|
43
|
-
socket.join(ordersRoom)
|
|
44
|
-
}, 5000)
|
|
45
|
-
appState.current = nextAppState;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
React.useEffect (() => {
|
|
50
|
-
AppState.addEventListener('change', _handleAppStateChange);
|
|
51
|
-
return () => {
|
|
52
|
-
AppState.removeEventListener('change', _handleAppStateChange);
|
|
53
|
-
};
|
|
54
|
-
},[])
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<Stack.Navigator>
|
|
58
|
-
{!orderState.loading || (orderState?.options?.user_id && orderState.loading) || orderState?.options?.address?.location ? (
|
|
59
|
-
<>
|
|
60
|
-
{auth ? (
|
|
61
|
-
<>
|
|
62
|
-
{Object.keys(orderState?.carts).length === 0 && !orderState?.options?.address?.location && !orderState.loading ? (
|
|
63
|
-
<>
|
|
64
|
-
<Stack.Screen
|
|
65
|
-
name="AddressListInitial"
|
|
66
|
-
component={AddressList}
|
|
67
|
-
options={{ headerShown: false }}
|
|
68
|
-
initialParams={{ afterSignup: true }}
|
|
69
|
-
/>
|
|
70
|
-
<Stack.Screen
|
|
71
|
-
name="AddressFormInitial"
|
|
72
|
-
component={AddressForm}
|
|
73
|
-
options={{ headerShown: false }}
|
|
74
|
-
initialParams={{ afterSignup: true }}
|
|
75
|
-
/>
|
|
76
|
-
</>
|
|
77
|
-
) : (
|
|
78
|
-
<>
|
|
79
|
-
{!!Object.keys(e?.route?.params?.productLogin || {})?.length && (
|
|
80
|
-
<Stack.Screen
|
|
81
|
-
name="BusinessAfterLogin"
|
|
82
|
-
component={BusinessProductsList}
|
|
83
|
-
options={{headerShown: false}}
|
|
84
|
-
initialParams={{productLogin: e?.route?.params?.productLogin}}
|
|
85
|
-
/>
|
|
86
|
-
)}
|
|
87
|
-
<Stack.Screen
|
|
88
|
-
name='BottomTab'
|
|
89
|
-
component={BottomNavigator}
|
|
90
|
-
options={{ headerShown: false }}
|
|
91
|
-
/>
|
|
92
|
-
<Stack.Screen
|
|
93
|
-
name="CheckoutNavigator"
|
|
94
|
-
component={CheckoutNavigator}
|
|
95
|
-
options={{ headerShown: false }}
|
|
96
|
-
/>
|
|
97
|
-
<Stack.Screen
|
|
98
|
-
name="OrderDetails"
|
|
99
|
-
component={OrderDetails}
|
|
100
|
-
options={{ headerShown: false }}
|
|
101
|
-
/>
|
|
102
|
-
<Stack.Screen
|
|
103
|
-
name="Business"
|
|
104
|
-
component={BusinessProductsList}
|
|
105
|
-
options={{ headerShown: false }}
|
|
106
|
-
/>
|
|
107
|
-
<Stack.Screen
|
|
108
|
-
name="ProductDetails"
|
|
109
|
-
component={ProductDetails}
|
|
110
|
-
options={{ headerShown: false }}
|
|
111
|
-
/>
|
|
112
|
-
<Stack.Screen
|
|
113
|
-
name="ReviewOrder"
|
|
114
|
-
component={ReviewOrder}
|
|
115
|
-
options={{ headerShown: false }}
|
|
116
|
-
/>
|
|
117
|
-
<Stack.Screen
|
|
118
|
-
name="ReviewProducts"
|
|
119
|
-
component={ReviewProducts}
|
|
120
|
-
options={{ headerShown: false }}
|
|
121
|
-
/>
|
|
122
|
-
<Stack.Screen
|
|
123
|
-
name="ReviewDriver"
|
|
124
|
-
component={ReviewDriver}
|
|
125
|
-
options={{ headerShown: false }}
|
|
126
|
-
/>
|
|
127
|
-
<Stack.Screen
|
|
128
|
-
name='MomentOption'
|
|
129
|
-
component={MomentOption}
|
|
130
|
-
options={{ headerShown: false }}
|
|
131
|
-
/>
|
|
132
|
-
<Stack.Screen
|
|
133
|
-
name="AddressList"
|
|
134
|
-
component={AddressList}
|
|
135
|
-
options={{ headerShown: false }}
|
|
136
|
-
initialParams={{ afterSignup: false }}
|
|
137
|
-
/>
|
|
138
|
-
<Stack.Screen
|
|
139
|
-
name="AddressForm"
|
|
140
|
-
component={AddressForm}
|
|
141
|
-
options={{ headerShown: false }}
|
|
142
|
-
initialParams={{ afterSignup: false }}
|
|
143
|
-
/>
|
|
144
|
-
<Stack.Screen
|
|
145
|
-
name="Account"
|
|
146
|
-
component={Account}
|
|
147
|
-
options={{ headerShown: false }}
|
|
148
|
-
/>
|
|
149
|
-
<Stack.Screen
|
|
150
|
-
name="Help"
|
|
151
|
-
component={Help}
|
|
152
|
-
options={{ headerShown: false }}
|
|
153
|
-
/>
|
|
154
|
-
<Stack.Screen
|
|
155
|
-
name="HelpOrder"
|
|
156
|
-
component={HelpOrder}
|
|
157
|
-
options={{ headerShown: false }}
|
|
158
|
-
/>
|
|
159
|
-
<Stack.Screen
|
|
160
|
-
name="HelpGuide"
|
|
161
|
-
component={HelpGuide}
|
|
162
|
-
options={{ headerShown: false }}
|
|
163
|
-
/>
|
|
164
|
-
<Stack.Screen
|
|
165
|
-
name="HelpAccountAndPayment"
|
|
166
|
-
component={HelpAccountAndPayment}
|
|
167
|
-
options={{ headerShown: false }}
|
|
168
|
-
/>
|
|
169
|
-
<Stack.Screen
|
|
170
|
-
name="Sessions"
|
|
171
|
-
component={Sessions}
|
|
172
|
-
options={{ headerShown: false }}
|
|
173
|
-
/>
|
|
174
|
-
<Stack.Screen
|
|
175
|
-
name="MultiOrdersDetails"
|
|
176
|
-
component={MultiOrdersDetails}
|
|
177
|
-
options={{ headerShown: false }}
|
|
178
|
-
/>
|
|
179
|
-
</>
|
|
180
|
-
)}
|
|
181
|
-
</>
|
|
182
|
-
)
|
|
183
|
-
: (
|
|
184
|
-
<Stack.Screen
|
|
185
|
-
name='root'
|
|
186
|
-
component={RootNavigator}
|
|
187
|
-
options={{ headerShown: false }}
|
|
188
|
-
/>
|
|
189
|
-
)}
|
|
190
|
-
</>
|
|
191
|
-
) : (
|
|
192
|
-
<Stack.Screen
|
|
193
|
-
name="Splash"
|
|
194
|
-
component={Splash}
|
|
195
|
-
options={{ headerShown: false }}
|
|
196
|
-
/>
|
|
197
|
-
)}
|
|
198
|
-
</Stack.Navigator>
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export default HomeNavigator;
|
|
@@ -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
|