ordering-ui-react-native 0.12.14 → 0.12.18
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/src/components/AddressList/index.tsx +3 -1
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +168 -156
- package/themes/business/src/components/NewOrderNotification/index.tsx +14 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +3 -1
- package/themes/business/src/components/OrdersOption/index.tsx +19 -15
- package/themes/business/src/components 2/AcceptOrRejectOrder/index.tsx +389 -0
- package/themes/business/src/components 2/AcceptOrRejectOrder/styles.tsx +36 -0
- package/themes/business/src/components 2/BusinessController/index.tsx +155 -0
- package/themes/business/src/components 2/BusinessController/styles.tsx +19 -0
- package/themes/business/src/components 2/Chat/index.tsx +1152 -0
- package/themes/business/src/components 2/Chat/styles.tsx +12 -0
- package/themes/business/src/components 2/Contacts/index.tsx +299 -0
- package/themes/business/src/components 2/Contacts/styles.tsx +42 -0
- package/themes/business/src/components 2/DriverMap/index.tsx +525 -0
- package/themes/business/src/components 2/FloatingButton/index.tsx +141 -0
- package/themes/business/src/components 2/FloatingButton/styles.tsx +35 -0
- package/themes/business/src/components 2/ForgotPasswordForm/index.tsx +204 -0
- package/themes/business/src/components 2/ForgotPasswordForm/styles.tsx +11 -0
- package/themes/business/src/components 2/GoogleMap/index.tsx +347 -0
- package/themes/business/src/components 2/Home/index.tsx +111 -0
- package/themes/business/src/components 2/Home/styles.tsx +27 -0
- package/themes/business/src/components 2/LanguageSelector/index.tsx +124 -0
- package/themes/business/src/components 2/LanguageSelector/lang_country.json +152 -0
- package/themes/business/src/components 2/LanguageSelector/styles.tsx +17 -0
- package/themes/business/src/components 2/LoginForm/index.tsx +663 -0
- package/themes/business/src/components 2/LoginForm/styles.tsx +48 -0
- package/themes/business/src/components 2/LogoutButton/index.tsx +63 -0
- package/themes/business/src/components 2/MapView/index.tsx +317 -0
- package/themes/business/src/components 2/MessagesOption/index.tsx +337 -0
- package/themes/business/src/components 2/MessagesOption/styles.tsx +27 -0
- package/themes/business/src/components 2/NewOrderNotification/index.tsx +167 -0
- package/themes/business/src/components 2/NewOrderNotification/styles.tsx +8 -0
- package/themes/business/src/components 2/NotFoundSource/index.tsx +52 -0
- package/themes/business/src/components 2/NotFoundSource/styles.tsx +17 -0
- package/themes/business/src/components 2/OrderDetails/Business.tsx +683 -0
- package/themes/business/src/components 2/OrderDetails/Delivery.tsx +454 -0
- package/themes/business/src/components 2/OrderDetails/OrderContentComponent.tsx +391 -0
- package/themes/business/src/components 2/OrderDetails/OrderHeaderComponent.tsx +148 -0
- package/themes/business/src/components 2/OrderDetails/styles.tsx +84 -0
- package/themes/business/src/components 2/OrderMessage/index.tsx +344 -0
- package/themes/business/src/components 2/OrderMessage/styles.tsx +5 -0
- package/themes/business/src/components 2/OrderSummary/index.tsx +700 -0
- package/themes/business/src/components 2/OrderSummary/styles.tsx +61 -0
- package/themes/business/src/components 2/OrdersOption/index.tsx +755 -0
- package/themes/business/src/components 2/OrdersOption/styles.tsx +54 -0
- package/themes/business/src/components 2/OrdersOptionBusiness/index.tsx +51 -0
- package/themes/business/src/components 2/OrdersOptionBusiness/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionCity/index.tsx +52 -0
- package/themes/business/src/components 2/OrdersOptionCity/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionDate/index.tsx +52 -0
- package/themes/business/src/components 2/OrdersOptionDate/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionDelivery/index.tsx +35 -0
- package/themes/business/src/components 2/OrdersOptionDelivery/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionDriver/index.tsx +50 -0
- package/themes/business/src/components 2/OrdersOptionDriver/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionPaymethod/index.tsx +49 -0
- package/themes/business/src/components 2/OrdersOptionPaymethod/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionStatus/index.tsx +46 -0
- package/themes/business/src/components 2/OrdersOptionStatus/styles.tsx +8 -0
- package/themes/business/src/components 2/PhoneInputNumber/index.tsx +160 -0
- package/themes/business/src/components 2/PhoneInputNumber/styles.tsx +3 -0
- package/themes/business/src/components 2/PreviousMessages/index.tsx +304 -0
- package/themes/business/src/components 2/PreviousMessages/styles.tsx +32 -0
- package/themes/business/src/components 2/PreviousOrders/index.tsx +180 -0
- package/themes/business/src/components 2/PreviousOrders/styles.tsx +38 -0
- package/themes/business/src/components 2/ProductItemAccordion/index.tsx +301 -0
- package/themes/business/src/components 2/ProductItemAccordion/styles.tsx +61 -0
- package/themes/business/src/components 2/SearchBar/index.tsx +112 -0
- package/themes/business/src/components 2/SignupForm/index.tsx +530 -0
- package/themes/business/src/components 2/SignupForm/styles.tsx +16 -0
- package/themes/business/src/components 2/StoresList/index.tsx +208 -0
- package/themes/business/src/components 2/StoresList/styles.tsx +26 -0
- package/themes/business/src/components 2/UserFormDetails/index.tsx +513 -0
- package/themes/business/src/components 2/UserFormDetails/styles.tsx +40 -0
- package/themes/business/src/components 2/UserProfileForm/index.tsx +496 -0
- package/themes/business/src/components 2/UserProfileForm/styles.tsx +36 -0
- package/themes/business/src/components 2/VerifyPhone/index.tsx +201 -0
- package/themes/business/src/components 2/VerifyPhone/styles.tsx +43 -0
- package/themes/business/src/components 2/shared/OAlert.tsx +52 -0
- package/themes/business/src/components 2/shared/OButton.tsx +149 -0
- package/themes/business/src/components 2/shared/OChatBubble.tsx +100 -0
- package/themes/business/src/components 2/shared/ODropDown.tsx +195 -0
- package/themes/business/src/components 2/shared/ODropDownCalendar.tsx +328 -0
- package/themes/business/src/components 2/shared/OFab.tsx +54 -0
- package/themes/business/src/components 2/shared/OIcon.tsx +67 -0
- package/themes/business/src/components 2/shared/OIconButton.tsx +127 -0
- package/themes/business/src/components 2/shared/OInput.tsx +144 -0
- package/themes/business/src/components 2/shared/OLink.tsx +76 -0
- package/themes/business/src/components 2/shared/OModal.tsx +275 -0
- package/themes/business/src/components 2/shared/OSegment.tsx +86 -0
- package/themes/business/src/components 2/shared/OText.tsx +55 -0
- package/themes/business/src/components 2/shared/OTextarea.tsx +46 -0
- package/themes/business/src/components 2/shared/OToast.tsx +92 -0
- package/themes/business/src/components 2/shared/index.tsx +27 -0
- package/themes/business/src/types/index.tsx +4 -1
- package/themes/kiosk/src/components/CategoriesMenu/index.tsx +128 -83
- package/themes/kiosk/src/components/DrawerView/index.tsx +57 -0
- package/themes/kiosk/src/components/DrawerView/styles.tsx +30 -0
- package/themes/kiosk/src/components/LanguageSelector/index.tsx +78 -58
- package/themes/kiosk/src/components/OrderDetails/index.tsx +3 -1
- package/themes/kiosk/src/components/ProductForm/index.tsx +129 -127
- package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
- package/themes/original/src/components/BusinessesListing/index.tsx +9 -6
- package/themes/original/src/components/OrderProgress/index.tsx +32 -18
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import { useForm, Controller } from 'react-hook-form';
|
|
4
|
+
import {
|
|
5
|
+
ToastType,
|
|
6
|
+
useToast,
|
|
7
|
+
ForgotPasswordForm as ForgotPasswordController,
|
|
8
|
+
useLanguage,
|
|
9
|
+
} from 'ordering-components/native';
|
|
10
|
+
import { useTheme } from 'styled-components/native';
|
|
11
|
+
import { Container, FormInput } from './styles';
|
|
12
|
+
import { OButton, OInput, OText, OIconButton } from '../shared';
|
|
13
|
+
|
|
14
|
+
const ForgotPasswordUI = (props: any) => {
|
|
15
|
+
const { navigation, formState, handleButtonForgotPasswordClick } = props;
|
|
16
|
+
|
|
17
|
+
const theme = useTheme();
|
|
18
|
+
const [, t] = useLanguage();
|
|
19
|
+
const [, { showToast }] = useToast();
|
|
20
|
+
const { control, handleSubmit, errors } = useForm();
|
|
21
|
+
|
|
22
|
+
const [emailSent, setEmailSent] = useState(null);
|
|
23
|
+
|
|
24
|
+
const onSubmit = (values: any) => {
|
|
25
|
+
setEmailSent(values.email);
|
|
26
|
+
handleButtonForgotPasswordClick && handleButtonForgotPasswordClick(values);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const handleChangeInputEmail = (value: string, onChange: any) => {
|
|
30
|
+
onChange(value.toLowerCase().replace(/[&,()%";:ç?<>{}\\[\]\s]/g, ''));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!formState.loading && emailSent) {
|
|
35
|
+
if (formState.result?.error) {
|
|
36
|
+
setEmailSent(null);
|
|
37
|
+
formState.result?.result &&
|
|
38
|
+
showToast(ToastType.Error, formState.result?.result[0]);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
showToast(
|
|
42
|
+
ToastType.Success,
|
|
43
|
+
`${t(
|
|
44
|
+
'SUCCESS_SEND_FORGOT_PASSWORD',
|
|
45
|
+
'Your link has been sent to the email',
|
|
46
|
+
)}: ${emailSent}`,
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}, [formState]);
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (Object.keys(errors).length > 0) {
|
|
53
|
+
// Convert all errors in one string to show in toast provider
|
|
54
|
+
const list = Object.values(errors);
|
|
55
|
+
let stringError = '';
|
|
56
|
+
list.map((item: any, i: number) => {
|
|
57
|
+
stringError +=
|
|
58
|
+
i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
|
|
59
|
+
});
|
|
60
|
+
showToast(ToastType.Error, stringError);
|
|
61
|
+
}
|
|
62
|
+
}, [errors]);
|
|
63
|
+
|
|
64
|
+
const styles = StyleSheet.create({
|
|
65
|
+
header: {
|
|
66
|
+
marginTop: 0,
|
|
67
|
+
marginBottom: 30,
|
|
68
|
+
flexDirection: 'row',
|
|
69
|
+
alignItems: 'center',
|
|
70
|
+
width: '100%',
|
|
71
|
+
},
|
|
72
|
+
text: {
|
|
73
|
+
fontFamily: 'Poppins',
|
|
74
|
+
fontStyle: 'normal',
|
|
75
|
+
color: theme.colors.textGray,
|
|
76
|
+
},
|
|
77
|
+
arrowLeft: {
|
|
78
|
+
maxWidth: 40,
|
|
79
|
+
height: 25,
|
|
80
|
+
justifyContent: 'flex-end',
|
|
81
|
+
},
|
|
82
|
+
inputStyle: {
|
|
83
|
+
marginBottom: 25,
|
|
84
|
+
borderWidth: 1,
|
|
85
|
+
borderColor: theme.colors.disabled,
|
|
86
|
+
borderRadius: 7.6,
|
|
87
|
+
},
|
|
88
|
+
ButtonText: {
|
|
89
|
+
color: theme.colors.primaryContrast,
|
|
90
|
+
fontFamily: 'Poppins',
|
|
91
|
+
fontStyle: 'normal',
|
|
92
|
+
fontWeight: 'normal',
|
|
93
|
+
fontSize: 17,
|
|
94
|
+
},
|
|
95
|
+
button: {
|
|
96
|
+
borderRadius: 7.6,
|
|
97
|
+
height: 44,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<Container>
|
|
103
|
+
<View style={styles.header}>
|
|
104
|
+
<OIconButton
|
|
105
|
+
icon={theme.images.general.arrow_left}
|
|
106
|
+
borderColor={theme.colors.clear}
|
|
107
|
+
iconStyle={{ width: 20, height: 20 }}
|
|
108
|
+
style={styles.arrowLeft}
|
|
109
|
+
onClick={() => navigation?.canGoBack() && navigation.goBack()}
|
|
110
|
+
/>
|
|
111
|
+
|
|
112
|
+
<OText size={26} weight="600" style={styles.text}>
|
|
113
|
+
{t('FORGOT_YOUR_PASSWORD', 'Forgot your password?')}
|
|
114
|
+
</OText>
|
|
115
|
+
</View>
|
|
116
|
+
|
|
117
|
+
<OText
|
|
118
|
+
size={16}
|
|
119
|
+
weight="normal"
|
|
120
|
+
style={{ ...styles.text, marginBottom: 30 }}>
|
|
121
|
+
{t(
|
|
122
|
+
'FORGOT_PASSWORD_TEXT_MESSAGE',
|
|
123
|
+
"Enter your email address and we'll sent a link to reset your password.",
|
|
124
|
+
)}
|
|
125
|
+
</OText>
|
|
126
|
+
|
|
127
|
+
<FormInput>
|
|
128
|
+
<Controller
|
|
129
|
+
control={control}
|
|
130
|
+
render={({ onChange, value }: any) => (
|
|
131
|
+
<OInput
|
|
132
|
+
placeholder={t('EMAIL', 'Email')}
|
|
133
|
+
placeholderTextColor={theme.colors.arrowColor}
|
|
134
|
+
style={styles.inputStyle}
|
|
135
|
+
icon={theme.images.logos.emailInputIcon}
|
|
136
|
+
onChange={(e: any) => {
|
|
137
|
+
handleChangeInputEmail(e, onChange);
|
|
138
|
+
}}
|
|
139
|
+
value={value}
|
|
140
|
+
autoCapitalize="none"
|
|
141
|
+
autoCorrect={false}
|
|
142
|
+
type="email-address"
|
|
143
|
+
selectionColor={theme.colors.primary}
|
|
144
|
+
color={theme.colors.textGray}
|
|
145
|
+
autoCompleteType="email"
|
|
146
|
+
returnKeyType="done"
|
|
147
|
+
blurOnSubmit
|
|
148
|
+
onSubmitEditing={handleSubmit(onSubmit)}
|
|
149
|
+
/>
|
|
150
|
+
)}
|
|
151
|
+
name="email"
|
|
152
|
+
rules={{
|
|
153
|
+
required: t(
|
|
154
|
+
'VALIDATION_ERROR_EMAIL_REQUIRED',
|
|
155
|
+
'The field Email is required',
|
|
156
|
+
).replace('_attribute_', t('EMAIL', 'Email')),
|
|
157
|
+
pattern: {
|
|
158
|
+
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
|
|
159
|
+
message: t(
|
|
160
|
+
'INVALID_ERROR_EMAIL',
|
|
161
|
+
'Invalid email address',
|
|
162
|
+
).replace('_attribute_', t('EMAIL', 'Email')),
|
|
163
|
+
},
|
|
164
|
+
}}
|
|
165
|
+
defaultValue=""
|
|
166
|
+
/>
|
|
167
|
+
|
|
168
|
+
<OButton
|
|
169
|
+
text={
|
|
170
|
+
emailSent && !formState.result?.error
|
|
171
|
+
? t('LINK_SEND_FORGOT_PASSWORD', 'Link Sent')
|
|
172
|
+
: t('FRONT_RECOVER_PASSWORD', 'Recover Password')
|
|
173
|
+
}
|
|
174
|
+
textStyle={styles.ButtonText}
|
|
175
|
+
style={styles.button}
|
|
176
|
+
bgColor={
|
|
177
|
+
emailSent && !formState.result?.error
|
|
178
|
+
? theme.colors.disabled
|
|
179
|
+
: theme.colors.primary
|
|
180
|
+
}
|
|
181
|
+
borderColor={
|
|
182
|
+
emailSent && !formState.result?.error
|
|
183
|
+
? theme.colors.disabled
|
|
184
|
+
: theme.colors.primary
|
|
185
|
+
}
|
|
186
|
+
isLoading={formState.loading}
|
|
187
|
+
onClick={
|
|
188
|
+
emailSent && !formState.result?.error
|
|
189
|
+
? () => {}
|
|
190
|
+
: handleSubmit(onSubmit)
|
|
191
|
+
}
|
|
192
|
+
/>
|
|
193
|
+
</FormInput>
|
|
194
|
+
</Container>
|
|
195
|
+
);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export const ForgotPasswordForm = (props: any) => {
|
|
199
|
+
const ForgotPasswordProps = {
|
|
200
|
+
...props,
|
|
201
|
+
UIComponent: ForgotPasswordUI,
|
|
202
|
+
};
|
|
203
|
+
return <ForgotPasswordController {...ForgotPasswordProps} />;
|
|
204
|
+
};
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import { Dimensions, StyleSheet, View, SafeAreaView } from 'react-native';
|
|
3
|
+
import MapView, { PROVIDER_GOOGLE, Marker, Region } from 'react-native-maps';
|
|
4
|
+
import Geocoder from 'react-native-geocoding';
|
|
5
|
+
import { useLanguage, useConfig, useUtils } from 'ordering-components/native';
|
|
6
|
+
import { GoogleMapsParams } from '../../types';
|
|
7
|
+
import Alert from '../../providers/AlertProvider';
|
|
8
|
+
import { OIconButton, OIcon } from '../shared';
|
|
9
|
+
import { FloatingButton } from '../FloatingButton';
|
|
10
|
+
import Icon from 'react-native-vector-icons/FontAwesome5';
|
|
11
|
+
import { useTheme } from 'styled-components/native';
|
|
12
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
13
|
+
|
|
14
|
+
export const GoogleMap = (props: GoogleMapsParams) => {
|
|
15
|
+
const {
|
|
16
|
+
location,
|
|
17
|
+
handleChangeAddressMap,
|
|
18
|
+
maxLimitLocation,
|
|
19
|
+
readOnly,
|
|
20
|
+
handleViewActionOrder,
|
|
21
|
+
markerTitle,
|
|
22
|
+
showAcceptOrReject,
|
|
23
|
+
driverLocation,
|
|
24
|
+
saveLocation,
|
|
25
|
+
handleOpenMapView,
|
|
26
|
+
setSaveLocation,
|
|
27
|
+
handleToggleMap,
|
|
28
|
+
locations,
|
|
29
|
+
isSetInputs,
|
|
30
|
+
navigation,
|
|
31
|
+
} = props;
|
|
32
|
+
|
|
33
|
+
const { top } = useSafeAreaInsets();
|
|
34
|
+
const theme = useTheme();
|
|
35
|
+
const [, t] = useLanguage();
|
|
36
|
+
const [configState] = useConfig();
|
|
37
|
+
const [{ optimizeImage }] = useUtils();
|
|
38
|
+
const { width, height } = Dimensions.get('window');
|
|
39
|
+
const ASPECT_RATIO = width / height;
|
|
40
|
+
const [isMapReady, setIsMapReady] = useState(false);
|
|
41
|
+
const [markerPosition, setMarkerPosition] = useState({
|
|
42
|
+
latitude: locations ? locations[locations.length - 1].lat : location.lat,
|
|
43
|
+
longitude: locations ? locations[locations.length - 1].lng : location.lng,
|
|
44
|
+
});
|
|
45
|
+
const [region, setRegion] = useState({
|
|
46
|
+
latitude: location.lat,
|
|
47
|
+
longitude: location.lng,
|
|
48
|
+
latitudeDelta: 0.001,
|
|
49
|
+
longitudeDelta: 0.001 * ASPECT_RATIO,
|
|
50
|
+
});
|
|
51
|
+
let mapRef = useRef<any>(null);
|
|
52
|
+
const googleMapsApiKey = configState?.configs?.google_maps_api_key?.value;
|
|
53
|
+
|
|
54
|
+
const center = { lat: location?.lat, lng: location?.lng };
|
|
55
|
+
|
|
56
|
+
const [alertState, setAlertState] = useState<{
|
|
57
|
+
open: boolean;
|
|
58
|
+
content: Array<string>;
|
|
59
|
+
key?: string | null;
|
|
60
|
+
}>({ open: false, content: [], key: null });
|
|
61
|
+
|
|
62
|
+
const mapErrors: any = {
|
|
63
|
+
ERROR_NOT_FOUND_ADDRESS: "Sorry, we couldn't find an address",
|
|
64
|
+
ERROR_MAX_LIMIT_LOCATION_TO: 'Sorry, You can only set the position to',
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const MARKERS =
|
|
68
|
+
locations &&
|
|
69
|
+
locations.map((location: { lat: number; lng: number; level: number }) => {
|
|
70
|
+
return location.level === 4 && driverLocation?.lat
|
|
71
|
+
? {
|
|
72
|
+
latitude: driverLocation?.lat,
|
|
73
|
+
longitude: driverLocation?.lng,
|
|
74
|
+
}
|
|
75
|
+
: { latitude: location.lat, longitude: location.lng };
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const handleArrowBack: any = () => {
|
|
79
|
+
handleOpenMapView && handleOpenMapView();
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const geocodePosition = (pos: { latitude: number; longitude: number }) => {
|
|
83
|
+
Geocoder.from({
|
|
84
|
+
latitude: pos.latitude,
|
|
85
|
+
longitude: pos.longitude,
|
|
86
|
+
})
|
|
87
|
+
.then(({ results }) => {
|
|
88
|
+
let zipcode = null;
|
|
89
|
+
if (results && results.length > 0) {
|
|
90
|
+
for (const component of results[0].address_components) {
|
|
91
|
+
const addressType = component.types[0];
|
|
92
|
+
if (addressType === 'postal_code') {
|
|
93
|
+
zipcode = component.short_name;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
let data = null;
|
|
98
|
+
const details = {
|
|
99
|
+
geometry: { location: { lat: pos.latitude, lng: pos.longitude } },
|
|
100
|
+
};
|
|
101
|
+
if (isSetInputs) {
|
|
102
|
+
data = {
|
|
103
|
+
address: results[0]?.formatted_address,
|
|
104
|
+
location: results[0]?.geometry?.location,
|
|
105
|
+
zipcode,
|
|
106
|
+
place_id: results[0]?.place_id,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
handleChangeAddressMap && handleChangeAddressMap(data, details);
|
|
110
|
+
setSaveLocation && setSaveLocation(false);
|
|
111
|
+
handleToggleMap && handleToggleMap();
|
|
112
|
+
} else {
|
|
113
|
+
setMapErrors && setMapErrors('ERROR_NOT_FOUND_ADDRESS');
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
.catch(err => {
|
|
117
|
+
setMapErrors && setMapErrors(err.message);
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const validateResult = (curPos: { latitude: number; longitude: number }) => {
|
|
122
|
+
const loc1 = center;
|
|
123
|
+
const loc2 = curPos;
|
|
124
|
+
const distance = calculateDistance(loc1, loc2);
|
|
125
|
+
|
|
126
|
+
if (!maxLimitLocation) {
|
|
127
|
+
geocodePosition(curPos);
|
|
128
|
+
setMarkerPosition(curPos);
|
|
129
|
+
setRegion({
|
|
130
|
+
...region,
|
|
131
|
+
longitude: curPos.longitude,
|
|
132
|
+
latitude: curPos.latitude,
|
|
133
|
+
});
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (distance <= maxLimitLocation) {
|
|
138
|
+
setMarkerPosition(curPos);
|
|
139
|
+
setRegion({
|
|
140
|
+
...region,
|
|
141
|
+
longitude: curPos.longitude,
|
|
142
|
+
latitude: curPos.latitude,
|
|
143
|
+
});
|
|
144
|
+
} else {
|
|
145
|
+
setMapErrors && setMapErrors('ERROR_MAX_LIMIT_LOCATION');
|
|
146
|
+
setMarkerPosition({ latitude: center.lat, longitude: center.lng });
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const calculateDistance = (
|
|
151
|
+
pointA: { lat: number; lng: number },
|
|
152
|
+
pointB: { latitude: number; longitude: number },
|
|
153
|
+
) => {
|
|
154
|
+
const lat1 = pointA.lat;
|
|
155
|
+
const lon1 = pointA.lng;
|
|
156
|
+
|
|
157
|
+
const lat2 = pointB.latitude;
|
|
158
|
+
const lon2 = pointB.longitude;
|
|
159
|
+
|
|
160
|
+
const R = 6371e3;
|
|
161
|
+
const φ1 = lat1 * (Math.PI / 180);
|
|
162
|
+
const φ2 = lat2 * (Math.PI / 180);
|
|
163
|
+
const Δφ = (lat2 - lat1) * (Math.PI / 180);
|
|
164
|
+
const Δλ = (lon2 - lon1) * (Math.PI / 180);
|
|
165
|
+
|
|
166
|
+
const a =
|
|
167
|
+
Math.sin(Δφ / 2) * Math.sin(Δφ / 2) +
|
|
168
|
+
Math.cos(φ1) * Math.cos(φ2) * (Math.sin(Δλ / 2) * Math.sin(Δλ / 2));
|
|
169
|
+
|
|
170
|
+
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
171
|
+
|
|
172
|
+
const distance = R * c;
|
|
173
|
+
return distance;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const handleChangeRegion = (coordinates: Region) => {
|
|
177
|
+
validateResult(coordinates);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const closeAlert = () => {
|
|
181
|
+
setAlertState({
|
|
182
|
+
open: false,
|
|
183
|
+
content: [],
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const setMapErrors = (errKey: string) => {
|
|
188
|
+
setAlertState({
|
|
189
|
+
open: true,
|
|
190
|
+
content: !(errKey === 'ERROR_MAX_LIMIT_LOCATION_TO')
|
|
191
|
+
? [t(errKey, mapErrors[errKey])]
|
|
192
|
+
: [
|
|
193
|
+
`${t(errKey, mapErrors[errKey])} ${maxLimitLocation} ${t(
|
|
194
|
+
'METTERS',
|
|
195
|
+
'meters',
|
|
196
|
+
)}`,
|
|
197
|
+
],
|
|
198
|
+
key: errKey,
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const fitAllMarkers = () => {
|
|
203
|
+
mapRef.current.fitToCoordinates(MARKERS, {
|
|
204
|
+
edgePadding: { top: 80, right: 80, bottom: 80, left: 80 },
|
|
205
|
+
animated: true,
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
useEffect(() => {
|
|
210
|
+
Geocoder.init(googleMapsApiKey);
|
|
211
|
+
}, []);
|
|
212
|
+
|
|
213
|
+
useEffect(() => {
|
|
214
|
+
if (saveLocation) {
|
|
215
|
+
geocodePosition(markerPosition);
|
|
216
|
+
}
|
|
217
|
+
}, [saveLocation]);
|
|
218
|
+
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
if (mapRef.current && locations && isMapReady) {
|
|
221
|
+
fitAllMarkers();
|
|
222
|
+
}
|
|
223
|
+
}, [isMapReady]);
|
|
224
|
+
|
|
225
|
+
const styles = StyleSheet.create({
|
|
226
|
+
map: {
|
|
227
|
+
flex: 1,
|
|
228
|
+
...StyleSheet.absoluteFillObject,
|
|
229
|
+
},
|
|
230
|
+
image: {
|
|
231
|
+
borderRadius: 50,
|
|
232
|
+
},
|
|
233
|
+
view: {
|
|
234
|
+
width: 25,
|
|
235
|
+
position: 'absolute',
|
|
236
|
+
top: 6,
|
|
237
|
+
left: 6,
|
|
238
|
+
bottom: 0,
|
|
239
|
+
right: 0,
|
|
240
|
+
},
|
|
241
|
+
buttonBack: {
|
|
242
|
+
borderRadius: 7.6,
|
|
243
|
+
borderWidth: 0,
|
|
244
|
+
paddingLeft: 0,
|
|
245
|
+
},
|
|
246
|
+
buttonContainer: {
|
|
247
|
+
position: 'absolute',
|
|
248
|
+
top: 0,
|
|
249
|
+
left: 15,
|
|
250
|
+
marginTop: top,
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
return (
|
|
255
|
+
<SafeAreaView style={{ flex: 1 }}>
|
|
256
|
+
<View style={{ flex: 1, position: 'relative' }}>
|
|
257
|
+
<MapView
|
|
258
|
+
provider={PROVIDER_GOOGLE}
|
|
259
|
+
initialRegion={region}
|
|
260
|
+
style={{ flex: 1 }}
|
|
261
|
+
onRegionChangeComplete={
|
|
262
|
+
!readOnly
|
|
263
|
+
? coordinates => handleChangeRegion(coordinates)
|
|
264
|
+
: () => {}
|
|
265
|
+
}
|
|
266
|
+
zoomTapEnabled
|
|
267
|
+
zoomEnabled
|
|
268
|
+
zoomControlEnabled
|
|
269
|
+
cacheEnabled
|
|
270
|
+
moveOnMarkerPress
|
|
271
|
+
ref={mapRef}
|
|
272
|
+
onMapReady={() => setIsMapReady(true)}>
|
|
273
|
+
{locations ? (
|
|
274
|
+
<>
|
|
275
|
+
{MARKERS &&
|
|
276
|
+
MARKERS.map(
|
|
277
|
+
(
|
|
278
|
+
location: { latitude: number; longitude: number },
|
|
279
|
+
i: number,
|
|
280
|
+
) => (
|
|
281
|
+
<React.Fragment key={i}>
|
|
282
|
+
<Marker coordinate={location} title={locations[i]?.title}>
|
|
283
|
+
<Icon
|
|
284
|
+
name="map-marker"
|
|
285
|
+
size={50}
|
|
286
|
+
color={theme.colors.primary}
|
|
287
|
+
/>
|
|
288
|
+
<View style={styles.view}>
|
|
289
|
+
<OIcon
|
|
290
|
+
style={styles.image}
|
|
291
|
+
url={optimizeImage(
|
|
292
|
+
locations[i].icon,
|
|
293
|
+
'h_300,c_limit',
|
|
294
|
+
)}
|
|
295
|
+
width={25}
|
|
296
|
+
height={25}
|
|
297
|
+
/>
|
|
298
|
+
</View>
|
|
299
|
+
</Marker>
|
|
300
|
+
</React.Fragment>
|
|
301
|
+
),
|
|
302
|
+
)}
|
|
303
|
+
</>
|
|
304
|
+
) : (
|
|
305
|
+
<Marker
|
|
306
|
+
coordinate={markerPosition}
|
|
307
|
+
title={markerTitle || t('YOUR_LOCATION', 'Your Location')}
|
|
308
|
+
/>
|
|
309
|
+
)}
|
|
310
|
+
</MapView>
|
|
311
|
+
<Alert
|
|
312
|
+
open={alertState.open}
|
|
313
|
+
onAccept={closeAlert}
|
|
314
|
+
onClose={closeAlert}
|
|
315
|
+
content={alertState.content}
|
|
316
|
+
title={t('ERROR', 'Error')}
|
|
317
|
+
/>
|
|
318
|
+
</View>
|
|
319
|
+
{showAcceptOrReject && (
|
|
320
|
+
<FloatingButton
|
|
321
|
+
btnText={t('ACCEPT', 'Accept')}
|
|
322
|
+
isSecondaryBtn={false}
|
|
323
|
+
color={theme.colors.green}
|
|
324
|
+
secondButtonClick={() =>
|
|
325
|
+
handleViewActionOrder && handleViewActionOrder('accept')
|
|
326
|
+
}
|
|
327
|
+
firstButtonClick={() =>
|
|
328
|
+
handleViewActionOrder && handleViewActionOrder('accept')
|
|
329
|
+
}
|
|
330
|
+
secondButton={false}
|
|
331
|
+
firstColorCustom={theme.colors.red}
|
|
332
|
+
secondColorCustom={theme.colors.green}
|
|
333
|
+
widthButton={'100%'}
|
|
334
|
+
isPadding
|
|
335
|
+
/>
|
|
336
|
+
)}
|
|
337
|
+
<View style={styles.buttonContainer}>
|
|
338
|
+
<OIconButton
|
|
339
|
+
icon={theme.images.general.close}
|
|
340
|
+
iconStyle={{ width: 32, height: 32 }}
|
|
341
|
+
style={styles.buttonBack}
|
|
342
|
+
onClick={() => handleArrowBack()}
|
|
343
|
+
/>
|
|
344
|
+
</View>
|
|
345
|
+
</SafeAreaView>
|
|
346
|
+
);
|
|
347
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { StyleSheet, View, Dimensions, Platform } from 'react-native';
|
|
3
|
+
import { useLanguage } from 'ordering-components/native';
|
|
4
|
+
import { useTheme } from 'styled-components/native';
|
|
5
|
+
import { LogoWrapper, Container, BackgroundImage } from './styles';
|
|
6
|
+
import { OButton, OIcon, OText } from '../shared';
|
|
7
|
+
import { _setStoreData } from '../../providers/StoreUtil';
|
|
8
|
+
|
|
9
|
+
export const Home = (props: any) => {
|
|
10
|
+
const { onNavigationRedirect } = props;
|
|
11
|
+
const safeHeight = Platform.OS === 'ios' ? 80 : 40;
|
|
12
|
+
|
|
13
|
+
const theme = useTheme();
|
|
14
|
+
const [, t] = useLanguage();
|
|
15
|
+
|
|
16
|
+
const [orientation, setOrientation] = useState(
|
|
17
|
+
Dimensions.get('window').width < Dimensions.get('window').height
|
|
18
|
+
? 'Portrait'
|
|
19
|
+
: 'Landscape',
|
|
20
|
+
);
|
|
21
|
+
const [windowHeight, setWindowHeight] = useState(
|
|
22
|
+
parseInt(parseFloat(String(Dimensions.get('window').height)).toFixed(0)),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
Dimensions.addEventListener('change', ({ window: { width, height } }) => {
|
|
26
|
+
setWindowHeight(
|
|
27
|
+
parseInt(parseFloat(String(Dimensions.get('window').height)).toFixed(0)),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
if (width < height) {
|
|
31
|
+
setOrientation('Portrait');
|
|
32
|
+
} else {
|
|
33
|
+
setOrientation('Landscape');
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Container height={windowHeight - safeHeight} orientation={orientation}>
|
|
39
|
+
<BackgroundImage
|
|
40
|
+
source={theme.images.backgroundsImages.login}
|
|
41
|
+
resizeMode="cover">
|
|
42
|
+
<LogoWrapper>
|
|
43
|
+
<OIcon src={theme.images.logos.logotypeInvert} style={styles.logo} />
|
|
44
|
+
</LogoWrapper>
|
|
45
|
+
|
|
46
|
+
<View style={styles.wrapperContent}>
|
|
47
|
+
<View style={styles.wrapperText}>
|
|
48
|
+
<OText style={styles.textTitle} color={theme.colors.inputChat}>
|
|
49
|
+
{t('TITLE_SIGN_UP', 'Welcome')}
|
|
50
|
+
</OText>
|
|
51
|
+
|
|
52
|
+
<OText style={styles.textSubtitle} color={theme.colors.inputChat}>
|
|
53
|
+
{t(props.title.key, props.title.value)}
|
|
54
|
+
</OText>
|
|
55
|
+
</View>
|
|
56
|
+
|
|
57
|
+
<View style={styles.wrapperBtn}>
|
|
58
|
+
<OButton
|
|
59
|
+
text={t('LOGIN', 'Login')}
|
|
60
|
+
textStyle={{
|
|
61
|
+
...styles.btnText,
|
|
62
|
+
color: theme.colors.inputTextColor,
|
|
63
|
+
}}
|
|
64
|
+
bgColor={theme.colors.primary}
|
|
65
|
+
borderColor={theme.colors.primary}
|
|
66
|
+
style={styles.btn}
|
|
67
|
+
imgRightSrc={false}
|
|
68
|
+
onClick={() => onNavigationRedirect('Login')}
|
|
69
|
+
/>
|
|
70
|
+
</View>
|
|
71
|
+
</View>
|
|
72
|
+
</BackgroundImage>
|
|
73
|
+
</Container>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
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
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import styled from 'styled-components/native';
|
|
2
|
+
|
|
3
|
+
export const Container = styled.View`
|
|
4
|
+
width: 100%;
|
|
5
|
+
flex: 1;
|
|
6
|
+
height: ${(props: any) =>
|
|
7
|
+
props?.orientation === 'Portrait' && props?.height
|
|
8
|
+
? `${props.height}px`
|
|
9
|
+
: 'auto'};
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
export const LogoWrapper = styled.View`
|
|
13
|
+
margin-vertical: 50px;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
export const BackgroundImage = styled.ImageBackground`
|
|
19
|
+
width: 100%;
|
|
20
|
+
height: 100%;
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
flex: 1;
|
|
24
|
+
justify-content: space-between;
|
|
25
|
+
align-items: center;
|
|
26
|
+
padding: 20px 40px;
|
|
27
|
+
`;
|