ordering-ui-react-native 0.12.56 → 0.12.60
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/AppleLogin/index.tsx +14 -8
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +8 -8
- package/themes/business/src/components/OrderDetails/styles.tsx +1 -0
- package/themes/doordash/src/components/Cart/index.tsx +1 -0
- package/themes/doordash/src/components/OrderSummary/index.tsx +1 -0
- package/themes/instacart/src/components/OrderDetails/index.tsx +2 -2
- package/themes/single-business/src/components/Cart/index.tsx +127 -16
- package/themes/single-business/src/components/Cart/styles.tsx +39 -0
- package/themes/single-business/src/components/CartContent/index.tsx +56 -52
- package/themes/single-business/src/components/CartContent/styles.tsx +2 -16
- package/themes/single-business/src/components/OrderDetails/index.tsx +724 -708
- package/themes/single-business/src/components/OrderSummary/index.tsx +189 -154
- package/themes/franchises/index.tsx +0 -111
- package/themes/franchises/src/components/ActiveOrders/index.tsx +0 -134
- package/themes/franchises/src/components/ActiveOrders/styles.tsx +0 -44
- package/themes/franchises/src/components/AddressDetails/index.tsx +0 -77
- package/themes/franchises/src/components/AddressDetails/styles.tsx +0 -21
- package/themes/franchises/src/components/AddressForm/index.tsx +0 -837
- package/themes/franchises/src/components/AddressForm/styles.tsx +0 -27
- package/themes/franchises/src/components/AddressList/index.tsx +0 -338
- package/themes/franchises/src/components/AddressList/styles.tsx +0 -20
- package/themes/franchises/src/components/AppleLogin/index.tsx +0 -149
- package/themes/franchises/src/components/AppleLogin/styles.tsx +0 -21
- package/themes/franchises/src/components/BottomWrapper/index.tsx +0 -29
- package/themes/franchises/src/components/BusinessBasicInformation/index.tsx +0 -310
- package/themes/franchises/src/components/BusinessBasicInformation/styles.tsx +0 -66
- package/themes/franchises/src/components/BusinessController/index.tsx +0 -184
- package/themes/franchises/src/components/BusinessController/styles.tsx +0 -64
- package/themes/franchises/src/components/BusinessFeaturedController/index.tsx +0 -189
- package/themes/franchises/src/components/BusinessFeaturedController/styles.tsx +0 -50
- package/themes/franchises/src/components/BusinessInformation/index.tsx +0 -202
- package/themes/franchises/src/components/BusinessInformation/styles.tsx +0 -39
- package/themes/franchises/src/components/BusinessItemAccordion/index.tsx +0 -125
- package/themes/franchises/src/components/BusinessItemAccordion/styles.tsx +0 -54
- package/themes/franchises/src/components/BusinessProductsCategories/index.tsx +0 -87
- package/themes/franchises/src/components/BusinessProductsCategories/styles.tsx +0 -8
- package/themes/franchises/src/components/BusinessProductsList/index.tsx +0 -199
- package/themes/franchises/src/components/BusinessProductsList/styles.tsx +0 -14
- package/themes/franchises/src/components/BusinessProductsListing/index.tsx +0 -292
- package/themes/franchises/src/components/BusinessProductsListing/styles.tsx +0 -30
- package/themes/franchises/src/components/BusinessReviews/index.tsx +0 -249
- package/themes/franchises/src/components/BusinessReviews/styles.tsx +0 -59
- package/themes/franchises/src/components/BusinessTypeFilter/index.tsx +0 -127
- package/themes/franchises/src/components/BusinessTypeFilter/styles.tsx +0 -40
- package/themes/franchises/src/components/BusinessesListing/index.tsx +0 -339
- package/themes/franchises/src/components/BusinessesListing/styles.tsx +0 -92
- package/themes/franchises/src/components/Cart/index.tsx +0 -332
- package/themes/franchises/src/components/Cart/styles.tsx +0 -28
- package/themes/franchises/src/components/CartContent/index.tsx +0 -60
- package/themes/franchises/src/components/CartContent/styles.tsx +0 -19
- package/themes/franchises/src/components/Checkout/index.tsx +0 -664
- package/themes/franchises/src/components/Checkout/styles.tsx +0 -89
- package/themes/franchises/src/components/CouponControl/index.tsx +0 -119
- package/themes/franchises/src/components/CouponControl/styles.tsx +0 -22
- package/themes/franchises/src/components/DriverTips/index.tsx +0 -167
- package/themes/franchises/src/components/DriverTips/styles.tsx +0 -63
- package/themes/franchises/src/components/FacebookLogin/index.tsx +0 -107
- package/themes/franchises/src/components/FacebookLogin/styles.tsx +0 -21
- package/themes/franchises/src/components/FloatingButton/index.tsx +0 -100
- package/themes/franchises/src/components/FloatingButton/styles.tsx +0 -26
- package/themes/franchises/src/components/ForgotPasswordForm/index.tsx +0 -156
- package/themes/franchises/src/components/ForgotPasswordForm/styles.tsx +0 -11
- package/themes/franchises/src/components/GPSButton/index.tsx +0 -84
- package/themes/franchises/src/components/GPSButton/styles.ts +0 -6
- package/themes/franchises/src/components/GoogleLogin/index.tsx +0 -122
- package/themes/franchises/src/components/GoogleLogin/styles.tsx +0 -23
- package/themes/franchises/src/components/GoogleMap/index.tsx +0 -229
- package/themes/franchises/src/components/Help/index.tsx +0 -56
- package/themes/franchises/src/components/Help/styles.tsx +0 -11
- package/themes/franchises/src/components/HelpAccountAndPayment/index.tsx +0 -68
- package/themes/franchises/src/components/HelpAccountAndPayment/styles.tsx +0 -6
- package/themes/franchises/src/components/HelpGuide/index.tsx +0 -67
- package/themes/franchises/src/components/HelpGuide/styles.tsx +0 -6
- package/themes/franchises/src/components/HelpOrder/index.tsx +0 -79
- package/themes/franchises/src/components/HelpOrder/styles.tsx +0 -6
- package/themes/franchises/src/components/Home/index.tsx +0 -102
- package/themes/franchises/src/components/Home/styles.tsx +0 -18
- package/themes/franchises/src/components/LanguageSelector/index.tsx +0 -98
- package/themes/franchises/src/components/LanguageSelector/styles.tsx +0 -7
- package/themes/franchises/src/components/LastOrder/index.tsx +0 -168
- package/themes/franchises/src/components/LastOrder/styles.tsx +0 -16
- package/themes/franchises/src/components/LastOrders/index.tsx +0 -104
- package/themes/franchises/src/components/LastOrders/styles.tsx +0 -17
- package/themes/franchises/src/components/LoginForm/index.tsx +0 -512
- package/themes/franchises/src/components/LoginForm/styles.tsx +0 -77
- package/themes/franchises/src/components/LogoutButton/index.tsx +0 -36
- package/themes/franchises/src/components/Messages/index.tsx +0 -359
- package/themes/franchises/src/components/Messages/styles.tsx +0 -20
- package/themes/franchises/src/components/MomentOption/index.tsx +0 -321
- package/themes/franchises/src/components/MomentOption/styles.tsx +0 -66
- package/themes/franchises/src/components/NavBar/index.tsx +0 -129
- package/themes/franchises/src/components/NotFoundSource/index.tsx +0 -50
- package/themes/franchises/src/components/NotFoundSource/styles.tsx +0 -16
- package/themes/franchises/src/components/Notifications/index.tsx +0 -120
- package/themes/franchises/src/components/Notifications/styles.ts +0 -21
- package/themes/franchises/src/components/OrderDetails/index.tsx +0 -828
- package/themes/franchises/src/components/OrderDetails/styles.tsx +0 -120
- package/themes/franchises/src/components/OrderSummary/index.tsx +0 -266
- package/themes/franchises/src/components/OrderSummary/styles.tsx +0 -41
- package/themes/franchises/src/components/OrderTypeSelector/index.tsx +0 -92
- package/themes/franchises/src/components/OrderTypeSelector/styles.tsx +0 -27
- package/themes/franchises/src/components/OrdersOption/index.tsx +0 -243
- package/themes/franchises/src/components/OrdersOption/styles.tsx +0 -5
- package/themes/franchises/src/components/PaymentOptionCash/index.tsx +0 -102
- package/themes/franchises/src/components/PaymentOptionCash/styles.tsx +0 -18
- package/themes/franchises/src/components/PaymentOptionStripe/index.tsx +0 -234
- package/themes/franchises/src/components/PaymentOptionStripe/styles.tsx +0 -71
- package/themes/franchises/src/components/PaymentOptions/index.tsx +0 -430
- package/themes/franchises/src/components/PaymentOptions/styles.tsx +0 -77
- package/themes/franchises/src/components/PhoneInputNumber/index.tsx +0 -127
- package/themes/franchises/src/components/PhoneInputNumber/styles.tsx +0 -3
- package/themes/franchises/src/components/PreviousOrders/index.tsx +0 -188
- package/themes/franchises/src/components/PreviousOrders/styles.tsx +0 -33
- package/themes/franchises/src/components/ProductForm/index.tsx +0 -695
- package/themes/franchises/src/components/ProductForm/styles.tsx +0 -78
- package/themes/franchises/src/components/ProductIngredient/index.tsx +0 -43
- package/themes/franchises/src/components/ProductIngredient/styles.tsx +0 -7
- package/themes/franchises/src/components/ProductItemAccordion/index.tsx +0 -276
- package/themes/franchises/src/components/ProductItemAccordion/styles.tsx +0 -57
- package/themes/franchises/src/components/ProductOption/index.tsx +0 -50
- package/themes/franchises/src/components/ProductOption/styles.tsx +0 -11
- package/themes/franchises/src/components/ProductOptionSubOption/index.tsx +0 -146
- package/themes/franchises/src/components/ProductOptionSubOption/styles.tsx +0 -32
- package/themes/franchises/src/components/ReviewDriver/index.tsx +0 -221
- package/themes/franchises/src/components/ReviewDriver/styles.tsx +0 -46
- package/themes/franchises/src/components/ReviewOrder/index.tsx +0 -325
- package/themes/franchises/src/components/ReviewOrder/styles.tsx +0 -46
- package/themes/franchises/src/components/ReviewProduct/index.tsx +0 -275
- package/themes/franchises/src/components/ReviewProduct/styles.tsx +0 -53
- package/themes/franchises/src/components/SearchBar/index.tsx +0 -139
- package/themes/franchises/src/components/SignupForm/index.tsx +0 -643
- package/themes/franchises/src/components/SignupForm/styles.tsx +0 -27
- package/themes/franchises/src/components/SingleProductCard/index.tsx +0 -124
- package/themes/franchises/src/components/SingleProductCard/styles.tsx +0 -23
- package/themes/franchises/src/components/StripeCardForm/index.tsx +0 -97
- package/themes/franchises/src/components/StripeCardForm/naked.tsx +0 -128
- package/themes/franchises/src/components/StripeCardForm/styles.tsx +0 -32
- package/themes/franchises/src/components/StripeCardsList/index.tsx +0 -182
- package/themes/franchises/src/components/StripeElementsForm/index.tsx +0 -204
- package/themes/franchises/src/components/StripeElementsForm/naked.tsx +0 -90
- package/themes/franchises/src/components/StripeElementsForm/styles.tsx +0 -13
- package/themes/franchises/src/components/StripeRedirectForm/index.tsx +0 -159
- package/themes/franchises/src/components/StripeRedirectForm/styles.tsx +0 -23
- package/themes/franchises/src/components/TagSelector/index.tsx +0 -94
- package/themes/franchises/src/components/TagSelector/styles.ts +0 -0
- package/themes/franchises/src/components/TaxInformation/index.tsx +0 -51
- package/themes/franchises/src/components/TaxInformation/styles.tsx +0 -9
- package/themes/franchises/src/components/UpsellingProducts/index.tsx +0 -222
- package/themes/franchises/src/components/UpsellingProducts/styles.tsx +0 -50
- package/themes/franchises/src/components/UserDetails/index.tsx +0 -134
- package/themes/franchises/src/components/UserDetails/styles.tsx +0 -26
- package/themes/franchises/src/components/UserFormDetails/index.tsx +0 -351
- package/themes/franchises/src/components/UserFormDetails/styles.tsx +0 -35
- package/themes/franchises/src/components/UserProfile/index.tsx +0 -179
- package/themes/franchises/src/components/UserProfile/styles.ts +0 -42
- package/themes/franchises/src/components/UserProfileForm/index.tsx +0 -253
- package/themes/franchises/src/components/UserProfileForm/styles.tsx +0 -29
- package/themes/franchises/src/components/VerifyPhone/index.tsx +0 -188
- package/themes/franchises/src/components/VerifyPhone/styles.tsx +0 -43
- package/themes/franchises/src/components/shared/OAlert.tsx +0 -55
- package/themes/franchises/src/components/shared/OBottomPopup.tsx +0 -73
- package/themes/franchises/src/components/shared/OBottomStickBar.tsx +0 -62
- package/themes/franchises/src/components/shared/OButton.tsx +0 -132
- package/themes/franchises/src/components/shared/ODropDown.tsx +0 -169
- package/themes/franchises/src/components/shared/OIcon.tsx +0 -53
- package/themes/franchises/src/components/shared/OIconButton.tsx +0 -127
- package/themes/franchises/src/components/shared/OIconText.tsx +0 -54
- package/themes/franchises/src/components/shared/OInput.tsx +0 -113
- package/themes/franchises/src/components/shared/OKeyButton.tsx +0 -35
- package/themes/franchises/src/components/shared/OModal.tsx +0 -172
- package/themes/franchises/src/components/shared/OText.tsx +0 -52
- package/themes/franchises/src/components/shared/OTextarea.tsx +0 -36
- package/themes/franchises/src/components/shared/OToast.tsx +0 -93
- package/themes/franchises/src/components/shared/OToggle.tsx +0 -158
- package/themes/franchises/src/components/shared/index.tsx +0 -29
- package/themes/franchises/src/config/constants.tsx +0 -57
- package/themes/franchises/src/layouts/Container.tsx +0 -23
- package/themes/franchises/src/layouts/SafeAreaContainer.tsx +0 -6
- package/themes/franchises/src/providers/AlertProvider.tsx +0 -43
- package/themes/franchises/src/providers/StoreUtil.tsx +0 -50
- package/themes/franchises/src/types/index.tsx +0 -445
- package/themes/franchises/src/utils/index.tsx +0 -222
|
@@ -1,837 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
StyleSheet,
|
|
4
|
-
View,
|
|
5
|
-
TouchableOpacity,
|
|
6
|
-
Keyboard,
|
|
7
|
-
TouchableWithoutFeedback,
|
|
8
|
-
} from 'react-native';
|
|
9
|
-
import {
|
|
10
|
-
AddressForm as AddressFormController,
|
|
11
|
-
useLanguage,
|
|
12
|
-
useConfig,
|
|
13
|
-
useSession,
|
|
14
|
-
useOrder,
|
|
15
|
-
useToast,
|
|
16
|
-
ToastType
|
|
17
|
-
} from 'ordering-components/native';
|
|
18
|
-
import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';
|
|
19
|
-
import Spinner from 'react-native-loading-spinner-overlay';
|
|
20
|
-
import { useForm, Controller } from 'react-hook-form';
|
|
21
|
-
import Geocoder from 'react-native-geocoding';
|
|
22
|
-
|
|
23
|
-
import { OInput, OButton, OText, OModal, OIcon } from '../shared';
|
|
24
|
-
import { AddressFormParams } from '../../types';
|
|
25
|
-
import { getTraduction } from '../../utils';
|
|
26
|
-
import { useTheme } from 'styled-components/native';
|
|
27
|
-
import { GoogleMap } from '../GoogleMap';
|
|
28
|
-
import NavBar from '../NavBar';
|
|
29
|
-
|
|
30
|
-
import {
|
|
31
|
-
AddressFormContainer,
|
|
32
|
-
AutocompleteInput,
|
|
33
|
-
IconsContainer,
|
|
34
|
-
GoogleMapContainer,
|
|
35
|
-
FormInput,
|
|
36
|
-
} from './styles';
|
|
37
|
-
import { GPSButton } from '../GPSButton';
|
|
38
|
-
|
|
39
|
-
const inputNames = [
|
|
40
|
-
{ name: 'address', code: 'Address' },
|
|
41
|
-
{ name: 'internal_number', code: 'Internal number' },
|
|
42
|
-
{ name: 'zipcode', code: 'Zipcode' },
|
|
43
|
-
{ name: 'address_notes', code: 'Address notes' },
|
|
44
|
-
];
|
|
45
|
-
|
|
46
|
-
const AddressFormUI = (props: AddressFormParams) => {
|
|
47
|
-
const {
|
|
48
|
-
navigation,
|
|
49
|
-
updateChanges,
|
|
50
|
-
address,
|
|
51
|
-
formState,
|
|
52
|
-
isEditing,
|
|
53
|
-
handleChangeInput,
|
|
54
|
-
addressState,
|
|
55
|
-
addressesList,
|
|
56
|
-
saveAddress,
|
|
57
|
-
userCustomerSetup,
|
|
58
|
-
isGuestUser,
|
|
59
|
-
isRequiredField,
|
|
60
|
-
isFromProductsList,
|
|
61
|
-
hasAddressDefault,
|
|
62
|
-
afterSignup,
|
|
63
|
-
isSingleBusiness,
|
|
64
|
-
singleBusiness
|
|
65
|
-
} = props;
|
|
66
|
-
|
|
67
|
-
const theme = useTheme();
|
|
68
|
-
|
|
69
|
-
const tagsName = [
|
|
70
|
-
{ icon: theme.images.general.tag_home, value: 'home' },
|
|
71
|
-
{ icon: theme.images.general.tag_building, value: 'office' },
|
|
72
|
-
{ icon: theme.images.general.tag_heart, value: 'favorite' },
|
|
73
|
-
{ icon: theme.images.general.tag_plus, value: 'other' },
|
|
74
|
-
];
|
|
75
|
-
|
|
76
|
-
const styles = StyleSheet.create({
|
|
77
|
-
iconContainer: {
|
|
78
|
-
display: 'flex',
|
|
79
|
-
justifyContent: 'center',
|
|
80
|
-
alignItems: 'center',
|
|
81
|
-
paddingHorizontal: 18,
|
|
82
|
-
paddingVertical: 5,
|
|
83
|
-
backgroundColor: theme.colors.clear
|
|
84
|
-
},
|
|
85
|
-
inputsStyle: {
|
|
86
|
-
borderColor: theme.colors.border,
|
|
87
|
-
borderRadius: 10,
|
|
88
|
-
marginBottom: 20,
|
|
89
|
-
height: 50,
|
|
90
|
-
maxHeight: 50,
|
|
91
|
-
minHeight: 50,
|
|
92
|
-
},
|
|
93
|
-
textAreaStyles: {
|
|
94
|
-
borderColor: theme.colors.border,
|
|
95
|
-
borderRadius: 10,
|
|
96
|
-
marginBottom: 20,
|
|
97
|
-
height: 104,
|
|
98
|
-
maxHeight: 104,
|
|
99
|
-
textAlignVertical: 'top',
|
|
100
|
-
alignItems: 'flex-start',
|
|
101
|
-
},
|
|
102
|
-
pinIcon: {
|
|
103
|
-
position: 'absolute',
|
|
104
|
-
end: 0,
|
|
105
|
-
top: 12,
|
|
106
|
-
zIndex: 1002,
|
|
107
|
-
},
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
const [, t] = useLanguage();
|
|
111
|
-
const [{ auth }] = useSession();
|
|
112
|
-
const [, { showToast }] = useToast();
|
|
113
|
-
const [configState] = useConfig();
|
|
114
|
-
const [orderState] = useOrder();
|
|
115
|
-
const { handleSubmit, errors, control, setValue } = useForm();
|
|
116
|
-
|
|
117
|
-
const [toggleMap, setToggleMap] = useState(false);
|
|
118
|
-
const [alertState, setAlertState] = useState<{
|
|
119
|
-
open: boolean;
|
|
120
|
-
content: Array<string>;
|
|
121
|
-
key?: string | null;
|
|
122
|
-
}>({ open: false, content: [], key: null });
|
|
123
|
-
const [addressTag, setAddressTag] = useState(addressState?.address?.tag);
|
|
124
|
-
const [firstLocationNoEdit, setFirstLocationNoEdit] = useState({
|
|
125
|
-
value: { lat: null, lng: null },
|
|
126
|
-
address: null,
|
|
127
|
-
});
|
|
128
|
-
const [isFirstTime, setIsFirstTime] = useState(true);
|
|
129
|
-
const [locationChange, setLocationChange] = useState(
|
|
130
|
-
isEditing
|
|
131
|
-
? addressState?.address?.location
|
|
132
|
-
: formState.changes?.location ?? null,
|
|
133
|
-
);
|
|
134
|
-
const [saveMapLocation, setSaveMapLocation] = useState(false);
|
|
135
|
-
const [isKeyboardShow, setIsKeyboardShow] = useState(false);
|
|
136
|
-
const [isSignUpEffect, setIsSignUpEffect] = useState(false);
|
|
137
|
-
const [hasEditing, setAddressEditing] = useState(false);
|
|
138
|
-
|
|
139
|
-
const googleInput: any = useRef(null);
|
|
140
|
-
const internalNumberRef: any = useRef(null);
|
|
141
|
-
const zipCodeRef: any = useRef(null);
|
|
142
|
-
const addressNotesRef: any = useRef(null);
|
|
143
|
-
|
|
144
|
-
const googleMapsApiKey = configState?.configs?.google_maps_api_key?.value;
|
|
145
|
-
const isLocationRequired =
|
|
146
|
-
configState.configs?.google_autocomplete_selection_required?.value ===
|
|
147
|
-
'1' ||
|
|
148
|
-
configState.configs?.google_autocomplete_selection_required?.value ===
|
|
149
|
-
'true';
|
|
150
|
-
const maxLimitLocation =
|
|
151
|
-
configState?.configs?.meters_to_change_address?.value;
|
|
152
|
-
|
|
153
|
-
const continueAsGuest = () => {
|
|
154
|
-
if (isSingleBusiness) {
|
|
155
|
-
navigation.navigate('Business', {store: singleBusiness});
|
|
156
|
-
} else {
|
|
157
|
-
navigation.navigate('BusinessList');
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
const goToBack = () => navigation?.canGoBack() && navigation.goBack();
|
|
161
|
-
|
|
162
|
-
const getAddressFormatted = (address: any) => {
|
|
163
|
-
const data: any = { address: null, error: null };
|
|
164
|
-
Geocoder.init(googleMapsApiKey);
|
|
165
|
-
Geocoder.from(address)
|
|
166
|
-
.then((json) => {
|
|
167
|
-
if (json.results && json.results?.length > 0) {
|
|
168
|
-
let postalCode = null;
|
|
169
|
-
for (const component of json.results?.[0].address_components) {
|
|
170
|
-
const addressType = component.types?.[0];
|
|
171
|
-
if (addressType === 'postal_code') {
|
|
172
|
-
postalCode = component.short_name;
|
|
173
|
-
break;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
data.address = {
|
|
177
|
-
address,
|
|
178
|
-
location: json.results[0].geometry.location,
|
|
179
|
-
map_data: {
|
|
180
|
-
library: 'google',
|
|
181
|
-
place_id: json.results?.[0].place_id,
|
|
182
|
-
},
|
|
183
|
-
};
|
|
184
|
-
if (postalCode) {
|
|
185
|
-
data.address.zipcode = postalCode;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const arrayList = isEditing
|
|
189
|
-
? addressesList?.addresses?.filter(
|
|
190
|
-
(address: any) => address.id !== addressState?.address?.id,
|
|
191
|
-
) || []
|
|
192
|
-
: addressesList || [];
|
|
193
|
-
const addressToCompare = isEditing
|
|
194
|
-
? { ...addressState.address, ...data.address, ...formState.changes }
|
|
195
|
-
: { ...data.address, ...formState?.changes };
|
|
196
|
-
|
|
197
|
-
const isAddressAlreadyExist =
|
|
198
|
-
arrayList
|
|
199
|
-
.map((address: any) => checkAddress(address, addressToCompare))
|
|
200
|
-
.some((value: any) => value) ?? false;
|
|
201
|
-
|
|
202
|
-
if (!isAddressAlreadyExist) {
|
|
203
|
-
saveAddress(data.address);
|
|
204
|
-
if (isGuestUser) {
|
|
205
|
-
continueAsGuest();
|
|
206
|
-
}
|
|
207
|
-
if (!isGuestUser && !auth) {
|
|
208
|
-
!isFromProductsList
|
|
209
|
-
? navigation.navigate('Business')
|
|
210
|
-
: navigation?.canGoBack() && navigation.goBack();
|
|
211
|
-
}
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
setAlertState({
|
|
216
|
-
open: true,
|
|
217
|
-
content: [t('ADDRESS_ALREADY_EXIST', 'The address already exists')],
|
|
218
|
-
});
|
|
219
|
-
} else {
|
|
220
|
-
setAlertState({
|
|
221
|
-
open: true,
|
|
222
|
-
content: [t('ERROR_NOT_FOUND_ADDRESS', 'Error, address not found')],
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
})
|
|
226
|
-
.catch((error) => {
|
|
227
|
-
setAlertState({
|
|
228
|
-
open: true,
|
|
229
|
-
content: [error?.message || error?.toString()],
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
const onSubmit = () => {
|
|
235
|
-
if (
|
|
236
|
-
!auth &&
|
|
237
|
-
formState?.changes?.address === '' &&
|
|
238
|
-
addressState?.address?.address
|
|
239
|
-
) {
|
|
240
|
-
setAlertState({
|
|
241
|
-
open: true,
|
|
242
|
-
content: [
|
|
243
|
-
t(
|
|
244
|
-
'VALIDATION_ERROR_ADDRESS_REQUIRED',
|
|
245
|
-
'The field Address is required',
|
|
246
|
-
),
|
|
247
|
-
],
|
|
248
|
-
});
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
if (formState?.changes?.address && !formState?.changes?.location) {
|
|
252
|
-
if (isLocationRequired) {
|
|
253
|
-
setAlertState({
|
|
254
|
-
open: true,
|
|
255
|
-
content: [
|
|
256
|
-
t(
|
|
257
|
-
'ADDRESS_REQUIRE_LOCATION',
|
|
258
|
-
'The address needs a location, please select one of the suggested',
|
|
259
|
-
),
|
|
260
|
-
],
|
|
261
|
-
});
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
getAddressFormatted(formState?.changes?.address);
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
const arrayList = isEditing
|
|
269
|
-
? addressesList?.addresses?.filter(
|
|
270
|
-
(address: any) => address.id !== addressState?.address?.id,
|
|
271
|
-
) || []
|
|
272
|
-
: addressesList || [];
|
|
273
|
-
const addressToCompare = isEditing
|
|
274
|
-
? { ...addressState.address, ...formState.changes }
|
|
275
|
-
: formState?.changes;
|
|
276
|
-
|
|
277
|
-
const isAddressAlreadyExist =
|
|
278
|
-
arrayList
|
|
279
|
-
.map((address: any) => checkAddress(address, addressToCompare))
|
|
280
|
-
.some((value: any) => value) ?? false;
|
|
281
|
-
|
|
282
|
-
if (!isAddressAlreadyExist) {
|
|
283
|
-
saveAddress();
|
|
284
|
-
if (isGuestUser) {
|
|
285
|
-
continueAsGuest();
|
|
286
|
-
}
|
|
287
|
-
if (!isGuestUser && !auth && !afterSignup) {
|
|
288
|
-
!isFromProductsList
|
|
289
|
-
? navigation.navigate('Business')
|
|
290
|
-
: navigation?.canGoBack() && navigation.goBack();
|
|
291
|
-
}
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
setAlertState({
|
|
296
|
-
open: true,
|
|
297
|
-
content: [t('ADDRESS_ALREADY_EXIST', 'The address already exists')],
|
|
298
|
-
});
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Returns true when the user made no changes
|
|
303
|
-
* @param {object} address
|
|
304
|
-
*/
|
|
305
|
-
const checkAddress = (address: any, addressToCompare: any) => {
|
|
306
|
-
const props = [
|
|
307
|
-
'address',
|
|
308
|
-
'address_notes',
|
|
309
|
-
'zipcode',
|
|
310
|
-
'location',
|
|
311
|
-
'internal_number',
|
|
312
|
-
];
|
|
313
|
-
const values: any = [];
|
|
314
|
-
props.forEach((prop) => {
|
|
315
|
-
if (addressToCompare[prop]) {
|
|
316
|
-
if (prop === 'location') {
|
|
317
|
-
values.push(
|
|
318
|
-
address[prop]?.lat === addressToCompare[prop]?.lat &&
|
|
319
|
-
address[prop]?.lng === addressToCompare[prop]?.lng,
|
|
320
|
-
);
|
|
321
|
-
} else {
|
|
322
|
-
values.push(address[prop] === addressToCompare[prop]);
|
|
323
|
-
}
|
|
324
|
-
} else {
|
|
325
|
-
values.push(!address[prop]);
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
return values.every((value: any) => value);
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
const handleChangeAddress = (data: any, details: any) => {
|
|
332
|
-
const addressSelected = {
|
|
333
|
-
address: data?.description || data?.address,
|
|
334
|
-
location: details?.geometry?.location,
|
|
335
|
-
utc_offset: details?.utc_offset || null,
|
|
336
|
-
map_data: { library: 'google', place_id: data.place_id },
|
|
337
|
-
zip_code: data?.zip_code || null,
|
|
338
|
-
};
|
|
339
|
-
updateChanges(addressSelected);
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
const handleAddressTag = (tag: string) => {
|
|
343
|
-
setAddressTag(tag);
|
|
344
|
-
handleChangeInput({
|
|
345
|
-
target: {
|
|
346
|
-
name: 'tag',
|
|
347
|
-
value: tag,
|
|
348
|
-
},
|
|
349
|
-
});
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
const handleToggleMap = () => {
|
|
353
|
-
setToggleMap(!toggleMap);
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
useEffect(() => {
|
|
357
|
-
if (
|
|
358
|
-
orderState.loading &&
|
|
359
|
-
!addressesList &&
|
|
360
|
-
orderState.options.address &&
|
|
361
|
-
auth &&
|
|
362
|
-
!afterSignup
|
|
363
|
-
) {
|
|
364
|
-
!isFromProductsList
|
|
365
|
-
? navigation.navigate('BottomTab')
|
|
366
|
-
: navigation.navigate('Business');
|
|
367
|
-
}
|
|
368
|
-
}, [orderState.options.address]);
|
|
369
|
-
|
|
370
|
-
useEffect(() => {
|
|
371
|
-
if (alertState.open && alertState?.key !== 'ERROR_MAX_LIMIT_LOCATION') {
|
|
372
|
-
alertState.content && showToast(ToastType.Error, alertState.content);
|
|
373
|
-
}
|
|
374
|
-
}, [alertState.content]);
|
|
375
|
-
|
|
376
|
-
useEffect(() => {
|
|
377
|
-
if (!auth) {
|
|
378
|
-
inputNames.forEach((field) =>
|
|
379
|
-
setValue(
|
|
380
|
-
field.name,
|
|
381
|
-
formState?.changes[field.name] ||
|
|
382
|
-
(orderState?.options?.address &&
|
|
383
|
-
orderState?.options?.address[field.name]) ||
|
|
384
|
-
'',
|
|
385
|
-
),
|
|
386
|
-
);
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
if (!formState.loading && formState.result?.error) {
|
|
391
|
-
setAlertState({
|
|
392
|
-
open: true,
|
|
393
|
-
content: formState.result?.result || [t('ERROR', 'Error')],
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
setValue(
|
|
398
|
-
'address',
|
|
399
|
-
formState?.changes?.address ?? addressState.address?.address ?? '',
|
|
400
|
-
);
|
|
401
|
-
if (!isEditing) {
|
|
402
|
-
formState?.changes?.address &&
|
|
403
|
-
setLocationChange(formState?.changes?.location);
|
|
404
|
-
if (
|
|
405
|
-
formState?.changes?.address &&
|
|
406
|
-
formState?.changes?.address !== firstLocationNoEdit?.address &&
|
|
407
|
-
formState?.changes?.location &&
|
|
408
|
-
formState?.changes?.location?.lat !== firstLocationNoEdit.value?.lat &&
|
|
409
|
-
formState?.changes?.location?.lng !== firstLocationNoEdit.value?.lng
|
|
410
|
-
) {
|
|
411
|
-
setFirstLocationNoEdit({
|
|
412
|
-
value: formState?.changes?.location,
|
|
413
|
-
address: formState?.changes?.address,
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
if (isEditing) {
|
|
419
|
-
if (formState?.changes?.location) {
|
|
420
|
-
const prevLocation = {
|
|
421
|
-
lat: Math.trunc(locationChange.lat),
|
|
422
|
-
lng: Math.trunc(locationChange.lng),
|
|
423
|
-
};
|
|
424
|
-
const newLocation = {
|
|
425
|
-
lat: Math.trunc(formState?.changes?.location?.lat),
|
|
426
|
-
lng: Math.trunc(formState?.changes?.location?.lng),
|
|
427
|
-
};
|
|
428
|
-
if (
|
|
429
|
-
prevLocation.lat !== newLocation.lat &&
|
|
430
|
-
prevLocation.lng !== newLocation.lng
|
|
431
|
-
) {
|
|
432
|
-
setLocationChange(formState?.changes?.location);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
}, [formState]);
|
|
437
|
-
|
|
438
|
-
useEffect(() => {
|
|
439
|
-
if (formState?.result?.result && !formState?.loading) {
|
|
440
|
-
if (formState.result?.error) {
|
|
441
|
-
showToast(ToastType.Error, formState.result.result);
|
|
442
|
-
} else {
|
|
443
|
-
showToast(
|
|
444
|
-
ToastType.Success,
|
|
445
|
-
t('UPDATE_SUCCESSFULLY', 'Update successfully'),
|
|
446
|
-
);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}, [formState.result]);
|
|
450
|
-
|
|
451
|
-
useEffect(() => {
|
|
452
|
-
if (Object.keys(errors).length > 0) {
|
|
453
|
-
// Convert all errors in one string to show in toast provider
|
|
454
|
-
const list = Object.values(errors);
|
|
455
|
-
let stringError = '';
|
|
456
|
-
list.map((item: any, i: number) => {
|
|
457
|
-
stringError +=
|
|
458
|
-
i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
|
|
459
|
-
});
|
|
460
|
-
showToast(ToastType.Error, stringError);
|
|
461
|
-
}
|
|
462
|
-
}, [errors]);
|
|
463
|
-
|
|
464
|
-
useEffect(() => {
|
|
465
|
-
if (googleInput?.current) {
|
|
466
|
-
googleInput?.current?.setAddressText(
|
|
467
|
-
address?.address ||
|
|
468
|
-
formState.changes?.address ||
|
|
469
|
-
addressState.address.address ||
|
|
470
|
-
'',
|
|
471
|
-
);
|
|
472
|
-
}
|
|
473
|
-
}, []);
|
|
474
|
-
|
|
475
|
-
useEffect(() => {
|
|
476
|
-
const keyboardDidShowListener = Keyboard.addListener(
|
|
477
|
-
'keyboardDidShow',
|
|
478
|
-
() => {
|
|
479
|
-
setIsKeyboardShow(true);
|
|
480
|
-
},
|
|
481
|
-
);
|
|
482
|
-
const keyboardDidHideListener = Keyboard.addListener(
|
|
483
|
-
'keyboardDidHide',
|
|
484
|
-
() => {
|
|
485
|
-
setIsKeyboardShow(false);
|
|
486
|
-
},
|
|
487
|
-
);
|
|
488
|
-
return () => {
|
|
489
|
-
keyboardDidShowListener.remove();
|
|
490
|
-
keyboardDidHideListener.remove();
|
|
491
|
-
};
|
|
492
|
-
}, []);
|
|
493
|
-
|
|
494
|
-
useEffect(() => {
|
|
495
|
-
if (!orderState.loading && auth && !hasAddressDefault && isSignUpEffect) {
|
|
496
|
-
navigation.navigate('BottomTab');
|
|
497
|
-
}
|
|
498
|
-
setIsSignUpEffect(true);
|
|
499
|
-
}, [orderState.loading]);
|
|
500
|
-
|
|
501
|
-
return (
|
|
502
|
-
<>
|
|
503
|
-
<NavBar
|
|
504
|
-
title={t('WHERE_DO_WE_DELIVERY', 'Where do we delivery?')}
|
|
505
|
-
titleAlign={'center'}
|
|
506
|
-
onActionLeft={goToBack}
|
|
507
|
-
showCall={false}
|
|
508
|
-
paddingTop={20}
|
|
509
|
-
btnStyle={{ paddingLeft: 40 }}
|
|
510
|
-
titleStyle={{ fontSize: 14 }}
|
|
511
|
-
titleWrapStyle={{ flexBasis: '75%' }}
|
|
512
|
-
/>
|
|
513
|
-
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
|
|
514
|
-
<AddressFormContainer style={{ height: 600, overflow: 'scroll' }}>
|
|
515
|
-
<View>
|
|
516
|
-
<FormInput>
|
|
517
|
-
<AutocompleteInput>
|
|
518
|
-
<Controller
|
|
519
|
-
control={control}
|
|
520
|
-
name="address"
|
|
521
|
-
defaultValue={
|
|
522
|
-
address?.address ||
|
|
523
|
-
formState.changes?.address ||
|
|
524
|
-
addressState.address.address ||
|
|
525
|
-
''
|
|
526
|
-
}
|
|
527
|
-
rules={{
|
|
528
|
-
required:
|
|
529
|
-
isRequiredField && isRequiredField('address')
|
|
530
|
-
? t(
|
|
531
|
-
`VALIDATION_ERROR_ADDRESS_REQUIRED`,
|
|
532
|
-
`The field Address is required`,
|
|
533
|
-
)
|
|
534
|
-
: null,
|
|
535
|
-
}}
|
|
536
|
-
render={() => (
|
|
537
|
-
<GooglePlacesAutocomplete
|
|
538
|
-
placeholder={t('ADD_ADDRESS', 'Add a address')}
|
|
539
|
-
onPress={(data, details: any) => {
|
|
540
|
-
handleChangeAddress(data, details);
|
|
541
|
-
}}
|
|
542
|
-
query={{ key: googleMapsApiKey }}
|
|
543
|
-
fetchDetails
|
|
544
|
-
ref={googleInput}
|
|
545
|
-
textInputProps={{
|
|
546
|
-
onChangeText: (text) => {
|
|
547
|
-
if (!isFirstTime) {
|
|
548
|
-
handleChangeInput({
|
|
549
|
-
target: { name: 'address', value: text },
|
|
550
|
-
});
|
|
551
|
-
setValue('address', text);
|
|
552
|
-
}
|
|
553
|
-
setIsFirstTime(false);
|
|
554
|
-
setAddressEditing(text.length == 0);
|
|
555
|
-
},
|
|
556
|
-
onSubmitEditing: () =>
|
|
557
|
-
internalNumberRef?.current?.focus?.(),
|
|
558
|
-
autoCorrect: false,
|
|
559
|
-
blurOnSubmit: false,
|
|
560
|
-
returnKeyType: 'next',
|
|
561
|
-
}}
|
|
562
|
-
onFail={(error) =>
|
|
563
|
-
setAlertState({
|
|
564
|
-
open: true,
|
|
565
|
-
content: getTraduction(error),
|
|
566
|
-
})
|
|
567
|
-
}
|
|
568
|
-
styles={{
|
|
569
|
-
listView: {
|
|
570
|
-
position: 'relative',
|
|
571
|
-
borderBottomStartRadius: 15,
|
|
572
|
-
borderBottomEndRadius: 15,
|
|
573
|
-
elevation: 2,
|
|
574
|
-
borderWidth: 1,
|
|
575
|
-
borderColor: '#ddd',
|
|
576
|
-
bottom: 20,
|
|
577
|
-
},
|
|
578
|
-
container: {
|
|
579
|
-
zIndex: 100,
|
|
580
|
-
},
|
|
581
|
-
textInput: {
|
|
582
|
-
borderWidth: 1,
|
|
583
|
-
borderRadius: 7.6,
|
|
584
|
-
borderColor: theme.colors.border,
|
|
585
|
-
flexGrow: 1,
|
|
586
|
-
fontSize: 15,
|
|
587
|
-
paddingHorizontal: 16,
|
|
588
|
-
minHeight: 50,
|
|
589
|
-
fontFamily: 'Poppins-Regular',
|
|
590
|
-
marginBottom: 24,
|
|
591
|
-
},
|
|
592
|
-
}}
|
|
593
|
-
/>
|
|
594
|
-
)}
|
|
595
|
-
/>
|
|
596
|
-
{hasEditing ? (
|
|
597
|
-
<View style={styles.pinIcon}>
|
|
598
|
-
<GPSButton
|
|
599
|
-
apiKey={googleMapsApiKey}
|
|
600
|
-
handleGPS={(data: any, detail: any) => {
|
|
601
|
-
handleChangeAddress(data, detail);
|
|
602
|
-
setValue(data.address);
|
|
603
|
-
if (googleInput?.current) {
|
|
604
|
-
googleInput?.current?.setAddressText( data.address );
|
|
605
|
-
}
|
|
606
|
-
}}
|
|
607
|
-
IconButton={<OIcon src={theme.images.general.pin} width={16} />}
|
|
608
|
-
/>
|
|
609
|
-
</View>
|
|
610
|
-
) : null}
|
|
611
|
-
</AutocompleteInput>
|
|
612
|
-
|
|
613
|
-
{/* {!isKeyboardShow && (addressState?.address?.location || formState?.changes?.location) && (
|
|
614
|
-
<TouchableOpacity onPress={handleToggleMap} style={{ marginBottom: 10 }}>
|
|
615
|
-
<OText
|
|
616
|
-
color={theme.colors.primary}
|
|
617
|
-
style={{ textAlign: 'center' }}
|
|
618
|
-
>
|
|
619
|
-
{t('VIEW_MAP', 'View map to modify the exact location')}
|
|
620
|
-
</OText>
|
|
621
|
-
</TouchableOpacity>
|
|
622
|
-
)} */}
|
|
623
|
-
|
|
624
|
-
{(locationChange || formState.changes?.location) && (
|
|
625
|
-
<View
|
|
626
|
-
style={{
|
|
627
|
-
height: 189,
|
|
628
|
-
borderRadius: 7.6,
|
|
629
|
-
overflow: 'hidden',
|
|
630
|
-
marginBottom: 24,
|
|
631
|
-
}}>
|
|
632
|
-
<GoogleMapContainer>
|
|
633
|
-
<GoogleMap
|
|
634
|
-
location={locationChange || formState.changes?.location}
|
|
635
|
-
handleChangeAddressMap={handleChangeAddress}
|
|
636
|
-
maxLimitLocation={maxLimitLocation}
|
|
637
|
-
saveLocation={saveMapLocation}
|
|
638
|
-
setSaveLocation={setSaveMapLocation}
|
|
639
|
-
handleToggleMap={handleToggleMap}
|
|
640
|
-
/>
|
|
641
|
-
</GoogleMapContainer>
|
|
642
|
-
</View>
|
|
643
|
-
)}
|
|
644
|
-
|
|
645
|
-
<View style={{ flexDirection: 'row', flexBasis: '50%' }}>
|
|
646
|
-
<Controller
|
|
647
|
-
control={control}
|
|
648
|
-
name="internal_number"
|
|
649
|
-
rules={{
|
|
650
|
-
required:
|
|
651
|
-
isRequiredField && isRequiredField('internal_number')
|
|
652
|
-
? t(
|
|
653
|
-
`VALIDATION_ERROR_INTERNAL_NUMBER_REQUIRED`,
|
|
654
|
-
`The field internal number is required`,
|
|
655
|
-
)
|
|
656
|
-
: null,
|
|
657
|
-
}}
|
|
658
|
-
defaultValue={
|
|
659
|
-
address?.internal_number ||
|
|
660
|
-
formState.changes?.internal_number ||
|
|
661
|
-
addressState?.address?.internal_number ||
|
|
662
|
-
''
|
|
663
|
-
}
|
|
664
|
-
render={() => (
|
|
665
|
-
<OInput
|
|
666
|
-
name="internal_number"
|
|
667
|
-
placeholder={t('INTERNAL_NUMBER', 'Internal number')}
|
|
668
|
-
onChange={(text: string) => {
|
|
669
|
-
handleChangeInput(text);
|
|
670
|
-
setValue('internal_number', text);
|
|
671
|
-
}}
|
|
672
|
-
value={
|
|
673
|
-
address?.internal_number ||
|
|
674
|
-
formState.changes?.internal_number ||
|
|
675
|
-
addressState?.address?.internal_number ||
|
|
676
|
-
''
|
|
677
|
-
}
|
|
678
|
-
style={{ ...styles.inputsStyle, marginRight: 24 }}
|
|
679
|
-
forwardRef={internalNumberRef}
|
|
680
|
-
returnKeyType="next"
|
|
681
|
-
onSubmitEditing={() => zipCodeRef?.current?.focus?.()}
|
|
682
|
-
blurOnSubmit={false}
|
|
683
|
-
/>
|
|
684
|
-
)}
|
|
685
|
-
/>
|
|
686
|
-
|
|
687
|
-
<Controller
|
|
688
|
-
control={control}
|
|
689
|
-
name="zipcode"
|
|
690
|
-
rules={{
|
|
691
|
-
required:
|
|
692
|
-
isRequiredField && isRequiredField('zipcode')
|
|
693
|
-
? t(
|
|
694
|
-
`VALIDATION_ERROR_ZIP_CODE_REQUIRED`,
|
|
695
|
-
`The field Zip Code is required`,
|
|
696
|
-
)
|
|
697
|
-
: null,
|
|
698
|
-
}}
|
|
699
|
-
defaultValue={
|
|
700
|
-
address?.zipcode ||
|
|
701
|
-
formState.changes?.zipcode ||
|
|
702
|
-
addressState.address.zipcode ||
|
|
703
|
-
''
|
|
704
|
-
}
|
|
705
|
-
render={() => (
|
|
706
|
-
<OInput
|
|
707
|
-
name="zipcode"
|
|
708
|
-
placeholder={t('ZIP_CODE', 'Zip code')}
|
|
709
|
-
onChange={(text: string) => {
|
|
710
|
-
handleChangeInput(text);
|
|
711
|
-
setValue('zipcode', text);
|
|
712
|
-
}}
|
|
713
|
-
value={
|
|
714
|
-
address?.zipcode ||
|
|
715
|
-
formState.changes?.zipcode ||
|
|
716
|
-
addressState.address.zipcode ||
|
|
717
|
-
''
|
|
718
|
-
}
|
|
719
|
-
style={styles.inputsStyle}
|
|
720
|
-
forwardRef={zipCodeRef}
|
|
721
|
-
returnKeyType="next"
|
|
722
|
-
onSubmitEditing={() => addressNotesRef?.current?.focus?.()}
|
|
723
|
-
blurOnSubmit={false}
|
|
724
|
-
/>
|
|
725
|
-
)}
|
|
726
|
-
/>
|
|
727
|
-
</View>
|
|
728
|
-
|
|
729
|
-
<Controller
|
|
730
|
-
control={control}
|
|
731
|
-
name="address_notes"
|
|
732
|
-
rules={{
|
|
733
|
-
required:
|
|
734
|
-
isRequiredField && isRequiredField('address_notes')
|
|
735
|
-
? t(
|
|
736
|
-
`VALIDATION_ERROR_ADDRESS_NOTES_REQUIRED`,
|
|
737
|
-
`The field address notes is required`,
|
|
738
|
-
)
|
|
739
|
-
: null,
|
|
740
|
-
}}
|
|
741
|
-
defaultValue={
|
|
742
|
-
address?.address_notes ||
|
|
743
|
-
formState.changes?.address_notes ||
|
|
744
|
-
addressState.address.address_notes ||
|
|
745
|
-
''
|
|
746
|
-
}
|
|
747
|
-
render={() => (
|
|
748
|
-
<OInput
|
|
749
|
-
name="address_notes"
|
|
750
|
-
placeholder={t('ADDRESS_NOTES', 'Address notes')}
|
|
751
|
-
onChange={(text: any) => {
|
|
752
|
-
handleChangeInput(text);
|
|
753
|
-
setValue('address_notes', text);
|
|
754
|
-
}}
|
|
755
|
-
value={
|
|
756
|
-
address?.address_notes ||
|
|
757
|
-
formState.changes?.address_notes ||
|
|
758
|
-
addressState.address.address_notes ||
|
|
759
|
-
''
|
|
760
|
-
}
|
|
761
|
-
multiline
|
|
762
|
-
style={styles.textAreaStyles}
|
|
763
|
-
returnKeyType="done"
|
|
764
|
-
forwardRef={addressNotesRef}
|
|
765
|
-
blurOnSubmit
|
|
766
|
-
/>
|
|
767
|
-
)}
|
|
768
|
-
/>
|
|
769
|
-
</FormInput>
|
|
770
|
-
{!isKeyboardShow && (
|
|
771
|
-
<IconsContainer>
|
|
772
|
-
{tagsName.map((tag) => (
|
|
773
|
-
<TouchableOpacity
|
|
774
|
-
key={tag.value}
|
|
775
|
-
onPress={() => handleAddressTag(tag.value)}>
|
|
776
|
-
<View
|
|
777
|
-
style={{
|
|
778
|
-
...styles.iconContainer,
|
|
779
|
-
}}>
|
|
780
|
-
<OIcon
|
|
781
|
-
src={tag.icon}
|
|
782
|
-
width={24}
|
|
783
|
-
color={
|
|
784
|
-
addressTag === tag.value ?
|
|
785
|
-
theme.colors.primary : theme.colors.disabled
|
|
786
|
-
}
|
|
787
|
-
/>
|
|
788
|
-
</View>
|
|
789
|
-
</TouchableOpacity>
|
|
790
|
-
))}
|
|
791
|
-
</IconsContainer>
|
|
792
|
-
)}
|
|
793
|
-
</View>
|
|
794
|
-
|
|
795
|
-
<View>
|
|
796
|
-
{Object.keys(formState?.changes).length > 0 ? (
|
|
797
|
-
<OButton
|
|
798
|
-
text={
|
|
799
|
-
!formState.loading
|
|
800
|
-
? isEditing ||
|
|
801
|
-
(!auth && orderState.options?.address?.address)
|
|
802
|
-
? t('UPDATE', 'Update')
|
|
803
|
-
: t('CONTINUE', 'Continue')
|
|
804
|
-
: t('LOADING', 'Loading')
|
|
805
|
-
}
|
|
806
|
-
onClick={handleSubmit(onSubmit)}
|
|
807
|
-
bgColor={theme.colors.primary}
|
|
808
|
-
borderColor={theme.colors.primary}
|
|
809
|
-
textStyle={{ color: theme.colors.white }}
|
|
810
|
-
isDisabled={formState.loading}
|
|
811
|
-
style={{ borderRadius: 7.6, shadowOpacity: 0 }}
|
|
812
|
-
/>
|
|
813
|
-
) : (
|
|
814
|
-
<OButton
|
|
815
|
-
text={t('CANCEL', 'Cancel')}
|
|
816
|
-
bgColor={theme.colors.white}
|
|
817
|
-
borderColor={theme.colors.primary}
|
|
818
|
-
style={{ borderRadius: 7.6, borderWidth: 1, shadowOpacity: 0 }}
|
|
819
|
-
onClick={() => navigation?.canGoBack() && navigation.goBack()}
|
|
820
|
-
/>
|
|
821
|
-
)}
|
|
822
|
-
</View>
|
|
823
|
-
|
|
824
|
-
<Spinner visible={saveMapLocation} />
|
|
825
|
-
</AddressFormContainer>
|
|
826
|
-
</TouchableWithoutFeedback>
|
|
827
|
-
</>
|
|
828
|
-
);
|
|
829
|
-
};
|
|
830
|
-
|
|
831
|
-
export const AddressForm = (props: AddressFormParams) => {
|
|
832
|
-
const addressFormProps = {
|
|
833
|
-
...props,
|
|
834
|
-
UIComponent: AddressFormUI,
|
|
835
|
-
};
|
|
836
|
-
return <AddressFormController {...addressFormProps} />;
|
|
837
|
-
};
|