ordering-ui-react-native 0.15.37 → 0.15.38-test
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 +3 -2
- package/src/components/BusinessTypeFilter/index.tsx +4 -1
- package/src/components/LanguageSelector/index.tsx +1 -0
- package/src/components/OrderDetails/index.tsx +2 -2
- package/src/components/PaymentOptions/index.tsx +2 -2
- package/src/components/StripeMethodForm/index.tsx +22 -21
- package/src/pages/BusinessProductsList.tsx +1 -0
- package/src/pages/BusinessesListing.tsx +1 -1
- 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/Delivery.tsx +9 -9
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +152 -91
- package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
- package/themes/business/src/components/OrdersListManager/index.tsx +51 -48
- package/themes/business/src/components/OrdersOption/index.tsx +52 -48
- package/themes/business/src/components/PreviousOrders/index.tsx +50 -14
- package/themes/kiosk/src/components/Cart/index.tsx +99 -25
- package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
- package/themes/kiosk/src/components/OrderDetails/index.tsx +134 -39
- package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
- package/themes/kiosk/src/components/ProductForm/index.tsx +2 -2
- package/themes/kiosk/src/types/index.d.ts +2 -0
- package/themes/original/index.tsx +165 -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 +118 -77
- 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 +28 -9
- 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 +4 -0
- 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 +126 -21
- package/themes/original/src/components/BusinessProductsList/styles.tsx +32 -2
- package/themes/original/src/components/BusinessProductsListing/index.tsx +12 -5
- package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
- package/themes/original/src/components/BusinessesListing/index.tsx +1 -2
- package/themes/original/src/components/Cart/index.tsx +1 -3
- package/themes/original/src/components/CartContent/index.tsx +2 -2
- package/themes/original/src/components/Checkout/index.tsx +2 -1
- package/themes/original/src/components/Home/index.tsx +1 -1
- package/themes/original/src/components/LoginForm/index.tsx +73 -2
- package/themes/original/src/components/LoginForm/styles.tsx +6 -1
- package/themes/original/src/components/LogoutButton/index.tsx +7 -1
- package/themes/original/src/components/Messages/index.tsx +5 -0
- 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 +1 -3
- package/themes/original/src/components/OrderProgress/index.tsx +3 -3
- package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
- package/themes/original/src/components/OrderSummary/index.tsx +2 -2
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +6 -2
- package/themes/original/src/components/PaymentOptions/index.tsx +3 -1
- package/themes/original/src/components/PhoneInputNumber/index.tsx +10 -4
- package/themes/original/src/components/PreviousOrders/index.tsx +14 -12
- package/themes/original/src/components/ProductForm/index.tsx +4 -4
- package/themes/original/src/components/Promotions/index.tsx +232 -0
- package/themes/original/src/components/Promotions/styles.tsx +80 -0
- package/themes/original/src/components/SignupForm/index.tsx +109 -13
- package/themes/original/src/components/SingleProductCard/index.tsx +39 -18
- package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
- package/themes/original/src/components/TaxInformation/index.tsx +10 -4
- package/themes/original/src/components/UserFormDetails/index.tsx +13 -2
- package/themes/original/src/components/UserProfile/index.tsx +53 -8
- package/themes/original/src/components/Wallets/index.tsx +57 -3
- 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/index.tsx +2 -0
- package/themes/original/src/config/constants.tsx +6 -6
- package/themes/original/src/types/index.tsx +21 -1
- package/themes/original/src/utils/index.tsx +9 -0
- package/themes/single-business/src/components/AddressList/index.tsx +1 -1
- package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ordering-ui-react-native",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.38-test",
|
|
4
4
|
"description": "Reusable components made in react native",
|
|
5
5
|
"main": "src/index.tsx",
|
|
6
6
|
"author": "ordering.inc",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"react-native-linear-gradient": "^2.5.6",
|
|
91
91
|
"react-native-loading-spinner-overlay": "^2.0.0",
|
|
92
92
|
"react-native-map-link": "^2.8.2",
|
|
93
|
-
"react-native-maps": "
|
|
93
|
+
"react-native-maps": "0.31.1",
|
|
94
94
|
"react-native-modal-dropdown": "^1.0.1",
|
|
95
95
|
"react-native-onesignal": "^4.1.1",
|
|
96
96
|
"react-native-paper": "^4.7.2",
|
|
@@ -99,6 +99,7 @@
|
|
|
99
99
|
"react-native-picker-select": "^8.0.4",
|
|
100
100
|
"react-native-print": "^0.9.0",
|
|
101
101
|
"react-native-reanimated": "^1.13.1",
|
|
102
|
+
"react-native-recaptcha-that-works": "^1.2.0",
|
|
102
103
|
"react-native-restart": "^0.0.22",
|
|
103
104
|
"react-native-safe-area-context": "^3.1.8",
|
|
104
105
|
"react-native-screens": "^2.11.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
|
-
import { StyleSheet, View, ScrollView,
|
|
2
|
+
import { StyleSheet, View, ScrollView, Dimensions, Platform, PlatformIOSStatic, Pressable } from 'react-native'
|
|
3
3
|
import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder'
|
|
4
4
|
import { BusinessTypeFilter as BusinessTypeFilterController, useLanguage } from 'ordering-components/native'
|
|
5
5
|
|
|
@@ -9,6 +9,7 @@ import { BusinessTypeFilterParams } from '../../types'
|
|
|
9
9
|
import { useTheme } from 'styled-components/native'
|
|
10
10
|
import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons';
|
|
11
11
|
import DeviceInfo from 'react-native-device-info';
|
|
12
|
+
import { TouchableOpacity } from 'react-native-gesture-handler'
|
|
12
13
|
|
|
13
14
|
const windowWidth = Dimensions.get('window').width;
|
|
14
15
|
|
|
@@ -71,11 +72,13 @@ export const BusinessTypeFilterUI = (props: BusinessTypeFilterParams) => {
|
|
|
71
72
|
<OIcon
|
|
72
73
|
url={item.image}
|
|
73
74
|
style={styles.logo}
|
|
75
|
+
cover
|
|
74
76
|
/>
|
|
75
77
|
) : (
|
|
76
78
|
<OIcon
|
|
77
79
|
src={theme.images.categories.all}
|
|
78
80
|
style={styles.logo}
|
|
81
|
+
cover
|
|
79
82
|
/>
|
|
80
83
|
)}
|
|
81
84
|
<OText
|
|
@@ -101,6 +101,7 @@ const LanguageSelectorUI = (props: LanguageSelectorParams) => {
|
|
|
101
101
|
disabled={orderState.loading}
|
|
102
102
|
onClose={() => Platform.OS === 'ios' ? handlerChangeLanguage() : {}}
|
|
103
103
|
onDonePress={() => handlerChangeLanguage()}
|
|
104
|
+
fixAndroidTouchableBug={true}
|
|
104
105
|
/>
|
|
105
106
|
) : <DummyContainer />}
|
|
106
107
|
</Container>
|
|
@@ -514,7 +514,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
514
514
|
</Table>
|
|
515
515
|
)}
|
|
516
516
|
{
|
|
517
|
-
order?.taxes?.length === 0 && order?.tax_type === 2 && (
|
|
517
|
+
order?.taxes?.length === 0 && order?.tax_type === 2 && order?.summary?.tax > 0 && (
|
|
518
518
|
<Table>
|
|
519
519
|
<OText>
|
|
520
520
|
{t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
|
|
@@ -524,7 +524,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
524
524
|
)
|
|
525
525
|
}
|
|
526
526
|
{
|
|
527
|
-
order?.fees?.length === 0 && (
|
|
527
|
+
order?.fees?.length === 0 && order?.summary?.service_fee > 0 && (
|
|
528
528
|
<Table>
|
|
529
529
|
<OText>
|
|
530
530
|
{t('SERVICE_FEE', 'Service fee')}
|
|
@@ -67,7 +67,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
67
67
|
|
|
68
68
|
const theme = useTheme();
|
|
69
69
|
const [, t] = useLanguage();
|
|
70
|
-
const methodsPay = ['google_pay'
|
|
70
|
+
const methodsPay = ['google_pay']
|
|
71
71
|
const stripeDirectMethods = ['stripe_direct', ...methodsPay]
|
|
72
72
|
|
|
73
73
|
const [addCardOpen, setAddCardOpen] = useState({ stripe: false, stripeConnect: false });
|
|
@@ -156,7 +156,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
156
156
|
)
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
const excludeGateway: any = ['stripe_connect', 'stripe_redirect']; //exclude connect & redirect
|
|
159
|
+
const excludeGateway: any = ['stripe_connect', 'stripe_redirect', 'apple_pay']; //exclude connect & redirect & apple pay
|
|
160
160
|
|
|
161
161
|
return (
|
|
162
162
|
<PMContainer>
|
|
@@ -131,7 +131,7 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
|
|
|
131
131
|
|
|
132
132
|
return (
|
|
133
133
|
<>
|
|
134
|
-
{paymethod === 'google_pay'
|
|
134
|
+
{paymethod === 'google_pay' && (
|
|
135
135
|
<View>
|
|
136
136
|
<OButton
|
|
137
137
|
textStyle={{
|
|
@@ -145,26 +145,27 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
|
|
|
145
145
|
style={{ marginTop: 20 }}
|
|
146
146
|
/>
|
|
147
147
|
</View>
|
|
148
|
-
|
|
149
|
-
<View>
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
</View>
|
|
148
|
+
// ) : (
|
|
149
|
+
// <View>
|
|
150
|
+
// {isApplePaySupported ? (
|
|
151
|
+
// <>
|
|
152
|
+
// <OText>{t('APPLE_PAY_PAYMENT', 'Apple pay payment')}</OText>
|
|
153
|
+
// <ApplePayButton
|
|
154
|
+
// onPress={pay}
|
|
155
|
+
// type="plain"
|
|
156
|
+
// buttonStyle="black"
|
|
157
|
+
// borderRadius={4}
|
|
158
|
+
// style={{
|
|
159
|
+
// width: '100%',
|
|
160
|
+
// height: 50,
|
|
161
|
+
// }}
|
|
162
|
+
// />
|
|
163
|
+
// </>
|
|
164
|
+
// ) : (
|
|
165
|
+
// <OText>{t('APPLE_PAY_NOT_SUPPORTED', 'Apple pay not supported')}</OText>
|
|
166
|
+
// )}
|
|
167
|
+
// </View>
|
|
168
|
+
// )}
|
|
168
169
|
)}
|
|
169
170
|
<Spinner
|
|
170
171
|
visible={loadingGooglePayment}
|
|
@@ -21,7 +21,7 @@ const BusinessesListing = (props: any) => {
|
|
|
21
21
|
...props,
|
|
22
22
|
isSearchByName: true,
|
|
23
23
|
isSearchByDescription: true,
|
|
24
|
-
propsToFetch: ['id', 'name', 'header', 'logo', 'location', 'schedule', 'open', 'delivery_price', 'distance', 'delivery_time', 'pickup_time', 'reviews', 'featured', 'offers', 'food', 'laundry', 'alcohol', 'groceries', 'slug'],
|
|
24
|
+
propsToFetch: ['id', 'name', 'header', 'logo', 'ribbon', 'location', 'schedule', 'open', 'delivery_price', 'distance', 'delivery_time', 'pickup_time', 'reviews', 'featured', 'offers', 'food', 'laundry', 'alcohol', 'groceries', 'slug'],
|
|
25
25
|
onBusinessClick: (business: any) => {
|
|
26
26
|
props.navigation.navigate('Business', { store: store || business.slug, header: business.header, logo: business.logo })
|
|
27
27
|
}
|
|
@@ -1,18 +1,66 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import { StyleSheet, View, Dimensions, Platform } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import { useForm, Controller } from 'react-hook-form';
|
|
4
|
+
import { useLanguage, useApi } from 'ordering-components/native';
|
|
4
5
|
import { useTheme } from 'styled-components/native';
|
|
5
|
-
import { LogoWrapper, Container, BackgroundImage } from './styles';
|
|
6
|
-
import { OButton, OIcon, OText } from '../shared';
|
|
6
|
+
import { LogoWrapper, Container, BackgroundImage, FormInput } from './styles';
|
|
7
|
+
import { OButton, OIcon, OText, OInput } from '../shared';
|
|
7
8
|
import { _setStoreData } from '../../providers/StoreUtil';
|
|
8
9
|
|
|
9
10
|
export const Home = (props: any) => {
|
|
10
|
-
const { onNavigationRedirect } = props;
|
|
11
|
+
const { onNavigationRedirect, useRootPoint } = props;
|
|
11
12
|
const safeHeight = Platform.OS === 'ios' ? 80 : 40;
|
|
12
13
|
|
|
13
14
|
const theme = useTheme();
|
|
15
|
+
const [ordering, { setOrdering }] = useApi();
|
|
14
16
|
const [, t] = useLanguage();
|
|
17
|
+
const { control, handleSubmit, errors } = useForm();
|
|
15
18
|
|
|
19
|
+
|
|
20
|
+
const styles = StyleSheet.create({
|
|
21
|
+
logo: {
|
|
22
|
+
height: 65,
|
|
23
|
+
width: 300,
|
|
24
|
+
},
|
|
25
|
+
wrapperContent: {
|
|
26
|
+
width: '100%',
|
|
27
|
+
},
|
|
28
|
+
wrapperText: {
|
|
29
|
+
marginBottom: 20,
|
|
30
|
+
},
|
|
31
|
+
textTitle: {
|
|
32
|
+
fontWeight: '600',
|
|
33
|
+
fontStyle: 'normal',
|
|
34
|
+
fontSize: 50,
|
|
35
|
+
},
|
|
36
|
+
textSubtitle: {
|
|
37
|
+
fontWeight: 'normal',
|
|
38
|
+
fontStyle: 'normal',
|
|
39
|
+
fontSize: 14,
|
|
40
|
+
},
|
|
41
|
+
wrapperBtn: {
|
|
42
|
+
marginBottom: 20
|
|
43
|
+
},
|
|
44
|
+
btn: {
|
|
45
|
+
borderRadius: 7.6,
|
|
46
|
+
marginTop: 20,
|
|
47
|
+
},
|
|
48
|
+
btnText: {
|
|
49
|
+
fontFamily: 'Poppins',
|
|
50
|
+
fontStyle: 'normal',
|
|
51
|
+
fontWeight: 'normal',
|
|
52
|
+
fontSize: 18,
|
|
53
|
+
},
|
|
54
|
+
input: {
|
|
55
|
+
borderWidth: 1,
|
|
56
|
+
borderRadius: 7.6,
|
|
57
|
+
borderColor: Object.keys(errors).length > 0 ? theme.colors.error : theme.colors.inputSignup,
|
|
58
|
+
backgroundColor: theme.colors.transparent,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const [projectName, setProjectName] = useState<any>(null)
|
|
63
|
+
const [isLoadingProject, setLoadingProject] = useState(false)
|
|
16
64
|
const [orientation, setOrientation] = useState(
|
|
17
65
|
Dimensions.get('window').width < Dimensions.get('window').height
|
|
18
66
|
? 'Portrait'
|
|
@@ -34,6 +82,27 @@ export const Home = (props: any) => {
|
|
|
34
82
|
}
|
|
35
83
|
});
|
|
36
84
|
|
|
85
|
+
const onSubmit = (values: any) => {
|
|
86
|
+
setLoadingProject(true)
|
|
87
|
+
setProjectName(values)
|
|
88
|
+
setOrdering({ ...ordering, project: values?.project_name })
|
|
89
|
+
_setStoreData('project_name', values?.project_name)
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (Object.keys(errors).length > 0) {
|
|
94
|
+
setProjectName(null)
|
|
95
|
+
setLoadingProject(false)
|
|
96
|
+
}
|
|
97
|
+
}, [errors])
|
|
98
|
+
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (ordering?.project === projectName?.project_name) {
|
|
101
|
+
setLoadingProject(false)
|
|
102
|
+
onNavigationRedirect('Login')
|
|
103
|
+
}
|
|
104
|
+
}, [ordering])
|
|
105
|
+
|
|
37
106
|
return (
|
|
38
107
|
<Container height={windowHeight - safeHeight} orientation={orientation}>
|
|
39
108
|
<BackgroundImage
|
|
@@ -54,58 +123,62 @@ export const Home = (props: any) => {
|
|
|
54
123
|
</OText>
|
|
55
124
|
</View>
|
|
56
125
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
126
|
+
<>
|
|
127
|
+
{useRootPoint && (
|
|
128
|
+
<FormInput>
|
|
129
|
+
<Controller
|
|
130
|
+
control={control}
|
|
131
|
+
name='project_name'
|
|
132
|
+
rules={{ required: t(`VALIDATION_ERROR_PROJECT_NAME_REQUIRED`, 'The field project name is required') }}
|
|
133
|
+
defaultValue=""
|
|
134
|
+
render={({ onChange, value }: any) => (
|
|
135
|
+
<OInput
|
|
136
|
+
name='project_name'
|
|
137
|
+
placeholderTextColor={theme.colors.arrowColor}
|
|
138
|
+
placeholder={t('PROJECT_NAME', 'Project Name')}
|
|
139
|
+
icon={theme.images.general.project}
|
|
140
|
+
iconColor={theme.colors.arrowColor}
|
|
141
|
+
onChange={(e: any) => onChange(e?.target?.value)}
|
|
142
|
+
selectionColor={theme.colors.primary}
|
|
143
|
+
color={theme.colors.white}
|
|
144
|
+
value={value}
|
|
145
|
+
style={styles.input}
|
|
146
|
+
returnKeyType='done'
|
|
147
|
+
autoCorrect={false}
|
|
148
|
+
autoCapitalize='none'
|
|
149
|
+
blurOnSubmit={false}
|
|
150
|
+
onSubmitEditing={() => handleSubmit(onSubmit)()}
|
|
151
|
+
/>
|
|
152
|
+
)}
|
|
153
|
+
/>
|
|
154
|
+
</FormInput>
|
|
155
|
+
)}
|
|
156
|
+
{Object.keys(errors).length > 0 && (
|
|
157
|
+
<OText
|
|
158
|
+
color={theme.colors.white}
|
|
159
|
+
style={{ alignSelf: 'center', marginTop: 5 }}
|
|
160
|
+
>
|
|
161
|
+
{errors['project_name'].message}
|
|
162
|
+
</OText>
|
|
163
|
+
)}
|
|
164
|
+
<View style={styles.wrapperBtn}>
|
|
165
|
+
<OButton
|
|
166
|
+
text={useRootPoint ? t('SET_PROJECT', 'Set project') : t('LOGIN', 'Login')}
|
|
167
|
+
textStyle={{
|
|
168
|
+
...styles.btnText,
|
|
169
|
+
color: theme.colors.inputTextColor,
|
|
170
|
+
}}
|
|
171
|
+
bgColor={theme.colors.primary}
|
|
172
|
+
borderColor={theme.colors.primary}
|
|
173
|
+
isLoading={isLoadingProject}
|
|
174
|
+
style={styles.btn}
|
|
175
|
+
imgRightSrc={false}
|
|
176
|
+
onClick={() => useRootPoint ? handleSubmit(onSubmit)() : onNavigationRedirect('Login')}
|
|
177
|
+
/>
|
|
178
|
+
</View>
|
|
179
|
+
</>
|
|
71
180
|
</View>
|
|
72
181
|
</BackgroundImage>
|
|
73
182
|
</Container>
|
|
74
183
|
);
|
|
75
184
|
};
|
|
76
|
-
|
|
77
|
-
const styles = StyleSheet.create({
|
|
78
|
-
logo: {
|
|
79
|
-
height: 65,
|
|
80
|
-
width: 300,
|
|
81
|
-
},
|
|
82
|
-
wrapperContent: {
|
|
83
|
-
width: '100%',
|
|
84
|
-
},
|
|
85
|
-
wrapperText: {
|
|
86
|
-
marginBottom: 20,
|
|
87
|
-
},
|
|
88
|
-
textTitle: {
|
|
89
|
-
fontWeight: '600',
|
|
90
|
-
fontStyle: 'normal',
|
|
91
|
-
fontSize: 50,
|
|
92
|
-
},
|
|
93
|
-
textSubtitle: {
|
|
94
|
-
fontWeight: 'normal',
|
|
95
|
-
fontStyle: 'normal',
|
|
96
|
-
fontSize: 14,
|
|
97
|
-
},
|
|
98
|
-
wrapperBtn: {
|
|
99
|
-
marginBottom: 20,
|
|
100
|
-
},
|
|
101
|
-
btn: {
|
|
102
|
-
borderRadius: 7.6,
|
|
103
|
-
marginTop: 20,
|
|
104
|
-
},
|
|
105
|
-
btnText: {
|
|
106
|
-
fontFamily: 'Poppins',
|
|
107
|
-
fontStyle: 'normal',
|
|
108
|
-
fontWeight: 'normal',
|
|
109
|
-
fontSize: 18,
|
|
110
|
-
},
|
|
111
|
-
});
|
|
@@ -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 Container = styled.View`
|
|
4
4
|
width: 100%;
|
|
@@ -25,3 +25,10 @@ export const BackgroundImage = styled.ImageBackground`
|
|
|
25
25
|
align-items: center;
|
|
26
26
|
padding: 20px 40px;
|
|
27
27
|
`;
|
|
28
|
+
|
|
29
|
+
export const FormInput = styled.View`
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
width: 100%;
|
|
33
|
+
min-height: 50px;
|
|
34
|
+
`;
|
|
@@ -1,50 +1,55 @@
|
|
|
1
|
-
import React, { useState, useEffect
|
|
2
|
-
import
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import moment from 'moment'
|
|
3
3
|
import { View, Modal, StyleSheet, TouchableOpacity, Dimensions } from 'react-native'
|
|
4
|
-
import
|
|
5
|
-
import { useTheme } from 'styled-components/native'
|
|
4
|
+
import Sound from 'react-native-sound'
|
|
6
5
|
import Icon from 'react-native-vector-icons/Feather'
|
|
6
|
+
import { useTheme } from 'styled-components/native'
|
|
7
|
+
import { useEvent, useLanguage, useSession, useApi, NewOrderNotification as NewOrderNotificationController } from 'ordering-components/native'
|
|
8
|
+
|
|
9
|
+
import { OText, OIcon } from '../shared'
|
|
7
10
|
import { NotificationContainer } from './styles'
|
|
8
|
-
import Sound from 'react-native-sound'
|
|
9
|
-
import moment from 'moment'
|
|
10
11
|
import { useLocation } from '../../hooks/useLocation'
|
|
11
|
-
|
|
12
|
+
|
|
12
13
|
Sound.setCategory('Playback')
|
|
13
14
|
|
|
14
15
|
const windowWidth = Dimensions.get('screen').width
|
|
15
16
|
|
|
16
|
-
const NewOrderNotificationUI = (
|
|
17
|
+
const NewOrderNotificationUI = () => {
|
|
17
18
|
const [events] = useEvent()
|
|
18
19
|
const theme = useTheme()
|
|
19
20
|
const [, t] = useLanguage()
|
|
20
21
|
const [{ user, token }] = useSession()
|
|
21
22
|
const [ordering] = useApi()
|
|
22
|
-
const [{ getTimeAgo }] = useUtils()
|
|
23
23
|
const { getCurrentLocation } = useLocation();
|
|
24
|
-
const [modalOpen, setModalOpen] = useState(false)
|
|
25
|
-
const [newOrderId, setNewOrderId] = useState(null)
|
|
26
|
-
const [messageOrderId, setMessageOrderId] = useState(null)
|
|
27
24
|
const [soundTimeout, setSoundTimeout] = useState<any>(null)
|
|
28
|
-
const [
|
|
29
|
-
|
|
25
|
+
const [currentEvent, setCurrentEvent] = useState<any>(null)
|
|
26
|
+
|
|
27
|
+
const evtList: any = {
|
|
28
|
+
1: {
|
|
29
|
+
event: 'messages',
|
|
30
|
+
message: t('NEW_MESSAGES_RECEIVED', 'New messages have been received!'),
|
|
31
|
+
message2: t('ORDER_N_UNREAD_MESSAGES', 'Order #_order_id_ has unread messages.').replace('_order_id_', currentEvent?.orderId),
|
|
32
|
+
},
|
|
33
|
+
2: {
|
|
34
|
+
event: 'order_added',
|
|
35
|
+
message: t('NEW_ORDERS_RECEIVED', 'New orders have been received!'),
|
|
36
|
+
message2: t('ORDER_N_ORDERED', 'Order #_order_id_ has been ordered.').replace('_order_id_', currentEvent?.orderId),
|
|
37
|
+
},
|
|
38
|
+
3: {
|
|
39
|
+
event: 'order_updated',
|
|
40
|
+
message: t('NEW_ORDERS_UPDATED', 'New orders have been updated!'),
|
|
41
|
+
message2: t('ORDER_N_UPDATED', 'Order #_order_id_ has been updated.').replace('_order_id_', currentEvent?.orderId),
|
|
42
|
+
},
|
|
43
|
+
}
|
|
30
44
|
|
|
31
|
-
const notificationSound = new Sound(theme.sounds.notification,
|
|
32
|
-
if (error) {
|
|
33
|
-
console.log('failed to load the sound', error);
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
console.log('loaded successfully');
|
|
37
|
-
});
|
|
45
|
+
const notificationSound = new Sound(theme.sounds.notification, (e) => { console.log(e) });
|
|
38
46
|
|
|
39
47
|
const handlePlayNotificationSound = () => {
|
|
40
48
|
let times = 0
|
|
41
49
|
const _timeout = setInterval(function () {
|
|
42
50
|
notificationSound.play(success => {
|
|
43
51
|
if (success) {
|
|
44
|
-
console.log('successfully finished playing');
|
|
45
52
|
times = times + 1
|
|
46
|
-
} else {
|
|
47
|
-
console.log('playback failed due to audio decoding errors');
|
|
48
53
|
}
|
|
49
54
|
})
|
|
50
55
|
setSoundTimeout(_timeout)
|
|
@@ -57,39 +62,11 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
57
62
|
|
|
58
63
|
const handleCloseModal = () => {
|
|
59
64
|
clearInterval(soundTimeout)
|
|
60
|
-
|
|
61
|
-
setNewOrderId(null)
|
|
62
|
-
setMessageOrderId(null)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const handleNotification = (order: any) => {
|
|
66
|
-
setModalOpen(true)
|
|
67
|
-
clearInterval(soundTimeout)
|
|
68
|
-
setCurrentChange(1)
|
|
69
|
-
handlePlayNotificationSound()
|
|
70
|
-
setNewOrderId(order.id)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const handleMessageNotification = (message: any) => {
|
|
74
|
-
const { order_id: orderId } = message;
|
|
75
|
-
if (!modalOpen) setModalOpen(true)
|
|
76
|
-
clearInterval(soundTimeout)
|
|
77
|
-
setCurrentChange(2)
|
|
78
|
-
handlePlayNotificationSound()
|
|
79
|
-
setMessageOrderId(orderId)
|
|
65
|
+
setCurrentEvent({ evt: null })
|
|
80
66
|
}
|
|
81
67
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
events.on('message_added_noification', handleMessageNotification)
|
|
85
|
-
return () => {
|
|
86
|
-
events.off('order_added_noification', handleNotification)
|
|
87
|
-
events.off('message_added_noification', handleMessageNotification)
|
|
88
|
-
}
|
|
89
|
-
}, [])
|
|
90
|
-
|
|
91
|
-
const handleUpdateOrder = useCallback(async (order: any) => {
|
|
92
|
-
if (order?.driver) {
|
|
68
|
+
const handleEventNotification = async (evtType: number, value: any) => {
|
|
69
|
+
if (value?.driver) {
|
|
93
70
|
const location = await getCurrentLocation()
|
|
94
71
|
await fetch(`${ordering.root}/users/${user.id}/locations`, {
|
|
95
72
|
method: 'POST',
|
|
@@ -98,25 +75,32 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
98
75
|
}),
|
|
99
76
|
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }
|
|
100
77
|
})
|
|
101
|
-
const assignedTimeDiff = moment.utc(
|
|
78
|
+
const assignedTimeDiff = moment.utc(value?.driver?.last_order_assigned_at).local().fromNow()
|
|
102
79
|
if (assignedTimeDiff === 'a few seconds ago') {
|
|
103
|
-
clearInterval(soundTimeout)
|
|
104
80
|
handlePlayNotificationSound()
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
setModalOpen(true)
|
|
108
|
-
}
|
|
81
|
+
clearInterval(soundTimeout)
|
|
82
|
+
setCurrentEvent({ evt: 2, orderId: value?.id })
|
|
109
83
|
}
|
|
84
|
+
return
|
|
110
85
|
}
|
|
111
|
-
|
|
86
|
+
handlePlayNotificationSound()
|
|
87
|
+
clearInterval(soundTimeout)
|
|
88
|
+
setCurrentEvent({
|
|
89
|
+
evt: evtType,
|
|
90
|
+
orderId: evtList[evtType].event === 'messages' ? value?.order_id : value?.id
|
|
91
|
+
})
|
|
92
|
+
}
|
|
112
93
|
|
|
113
94
|
useEffect(() => {
|
|
114
|
-
|
|
115
|
-
events.on('
|
|
95
|
+
events.on('message_added_notification', (o: any) => handleEventNotification(1, o))
|
|
96
|
+
events.on('order_added_notification', (o: any) => handleEventNotification(2, o))
|
|
97
|
+
events.on('order_updated_notification', (o: any) => handleEventNotification(3, o))
|
|
116
98
|
return () => {
|
|
117
|
-
events.off('
|
|
99
|
+
events.off('message_added_notification', (o: any) => handleEventNotification(1, o))
|
|
100
|
+
events.off('order_added_notification', (o: any) => handleEventNotification(2, o))
|
|
101
|
+
events.off('order_updated_notification', (o: any) => handleEventNotification(3, o))
|
|
118
102
|
}
|
|
119
|
-
}, [
|
|
103
|
+
}, [])
|
|
120
104
|
|
|
121
105
|
useEffect(() => {
|
|
122
106
|
notificationSound.setVolume(1);
|
|
@@ -125,21 +109,12 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
125
109
|
}
|
|
126
110
|
}, [])
|
|
127
111
|
|
|
128
|
-
useFocusEffect(
|
|
129
|
-
useCallback(() => {
|
|
130
|
-
setIsFocused(true)
|
|
131
|
-
return () => {
|
|
132
|
-
setIsFocused(false)
|
|
133
|
-
}
|
|
134
|
-
}, [])
|
|
135
|
-
)
|
|
136
|
-
|
|
137
112
|
return (
|
|
138
113
|
<>
|
|
139
114
|
<Modal
|
|
140
115
|
animationType='slide'
|
|
141
116
|
transparent={true}
|
|
142
|
-
visible={
|
|
117
|
+
visible={!!currentEvent?.orderId}
|
|
143
118
|
>
|
|
144
119
|
<NotificationContainer>
|
|
145
120
|
<View style={styles.modalView}>
|
|
@@ -147,40 +122,26 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
147
122
|
style={styles.wrapperIcon}
|
|
148
123
|
onPress={() => handleCloseModal()}
|
|
149
124
|
>
|
|
150
|
-
<Icon
|
|
151
|
-
name="x"
|
|
152
|
-
size={30}
|
|
153
|
-
/>
|
|
125
|
+
<Icon name="x" size={30} />
|
|
154
126
|
</TouchableOpacity>
|
|
155
127
|
<OText
|
|
156
128
|
size={18}
|
|
157
129
|
color={theme.colors.textGray}
|
|
158
130
|
weight={600}
|
|
159
131
|
>
|
|
160
|
-
{
|
|
132
|
+
{evtList[currentEvent?.evt]?.message}
|
|
161
133
|
</OText>
|
|
162
134
|
<OIcon
|
|
163
135
|
src={theme.images.general.newOrder}
|
|
164
136
|
width={250}
|
|
165
137
|
height={200}
|
|
166
138
|
/>
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
</OText>
|
|
174
|
-
)}
|
|
175
|
-
|
|
176
|
-
{messageOrderId !== null && (
|
|
177
|
-
<OText
|
|
178
|
-
color={theme.colors.textGray}
|
|
179
|
-
mBottom={15}
|
|
180
|
-
>
|
|
181
|
-
{t('ORDER_N_UNREAD_MESSAGES', 'Order #_order_id_ has unread messages.').replace('_order_id_', messageOrderId)}
|
|
182
|
-
</OText>
|
|
183
|
-
)}
|
|
139
|
+
<OText
|
|
140
|
+
color={theme.colors.textGray}
|
|
141
|
+
mBottom={15}
|
|
142
|
+
>
|
|
143
|
+
{evtList[currentEvent?.evt]?.message2}
|
|
144
|
+
</OText>
|
|
184
145
|
</View>
|
|
185
146
|
</NotificationContainer>
|
|
186
147
|
</Modal>
|