ordering-ui-react-native 0.22.68 → 0.22.69-release
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -7
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Checkout/index.tsx +40 -39
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/context/OfflineActions/index.tsx +236 -0
- package/src/providers/AlertProvider.tsx +3 -1
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +5 -3
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
- package/themes/business/src/components/BusinessController/index.tsx +8 -3
- package/themes/business/src/components/BusinessProductList/index.tsx +3 -2
- package/themes/business/src/components/Chat/index.tsx +15 -3
- package/themes/business/src/components/DriverMap/index.tsx +44 -33
- package/themes/business/src/components/FloatingButton/index.tsx +3 -2
- package/themes/business/src/components/LanguageSelector/index.tsx +1 -1
- package/themes/business/src/components/LoginForm/index.tsx +123 -98
- package/themes/business/src/components/LogoutButton/index.tsx +13 -4
- package/themes/business/src/components/MapView/RenderMarker.tsx +146 -0
- package/themes/business/src/components/MapView/index.tsx +68 -142
- package/themes/business/src/components/NewOrderNotification/index.tsx +38 -54
- package/themes/business/src/components/OrderDetails/Business.tsx +56 -20
- package/themes/business/src/components/OrderDetails/Delivery.tsx +123 -54
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +146 -36
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +51 -28
- package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
- package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +17 -16
- package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
- package/themes/business/src/components/OrderSummary/index.tsx +271 -176
- package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
- package/themes/business/src/components/OrdersOption/index.tsx +231 -150
- package/themes/business/src/components/OrdersOption/styles.tsx +14 -0
- package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
- package/themes/business/src/components/PreviousOrders/OrderItem.tsx +20 -8
- package/themes/business/src/components/PreviousOrders/index.tsx +74 -66
- package/themes/business/src/components/PreviousOrders/styles.tsx +2 -1
- package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
- package/themes/business/src/components/PrinterEdition/index.tsx +143 -75
- package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
- package/themes/business/src/components/PrinterSettings/index.tsx +1 -1
- package/themes/business/src/components/ProductItemAccordion/index.tsx +13 -10
- package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
- package/themes/business/src/components/StoresList/index.tsx +2 -2
- package/themes/business/src/components/UserProfileForm/index.tsx +48 -10
- package/themes/business/src/components/UserProfileForm/styles.tsx +7 -0
- package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
- package/themes/business/src/config/currency.tsx +1010 -0
- package/themes/business/src/hooks/useLocation.tsx +16 -12
- package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
- package/themes/business/src/types/index.tsx +28 -4
- package/themes/business/src/utils/index.tsx +28 -3
- package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
- package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/kiosk/src/components/Checkout/index.tsx +9 -5
- package/themes/kiosk/src/components/CustomerName/index.tsx +1 -1
- package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
- package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
- package/themes/kiosk/src/components/PaymentOptions/index.tsx +121 -57
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/original/index.tsx +223 -219
- package/themes/original/src/components/AddressForm/index.tsx +922 -888
- package/themes/original/src/components/AppleLogin/index.tsx +3 -4
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +1 -1
- package/themes/original/src/components/BusinessController/index.tsx +4 -2
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +10 -4
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +103 -92
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +7 -3
- package/themes/original/src/components/BusinessListingSearch/index.tsx +8 -13
- package/themes/original/src/components/BusinessPreorder/index.tsx +30 -17
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +73 -70
- package/themes/original/src/components/BusinessProductsList/index.tsx +6 -7
- package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
- package/themes/original/src/components/BusinessProductsListing/index.tsx +5 -4
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +9 -8
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
- package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
- package/themes/original/src/components/Cart/index.tsx +44 -12
- package/themes/original/src/components/CartContent/index.tsx +0 -2
- package/themes/original/src/components/Checkout/index.tsx +125 -97
- package/themes/original/src/components/ForgotPasswordForm/index.tsx +1 -2
- package/themes/original/src/components/GPSButton/index.tsx +2 -1
- package/themes/original/src/components/GoogleMap/index.tsx +5 -4
- package/themes/original/src/components/Help/functions.tsx +76 -0
- package/themes/original/src/components/Help/index.tsx +74 -29
- package/themes/original/src/components/Help/styles.tsx +4 -1
- package/themes/original/src/components/HelpOptions/index.tsx +53 -0
- package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
- package/themes/original/src/components/Home/index.tsx +36 -11
- package/themes/original/src/components/LastOrder/index.tsx +1 -1
- package/themes/original/src/components/LoginForm/index.tsx +11 -5
- package/themes/original/src/components/MessageListing/index.tsx +1 -1
- package/themes/original/src/components/Messages/index.tsx +562 -555
- package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
- package/themes/original/src/components/MomentOption/index.tsx +67 -49
- package/themes/original/src/components/MomentSelector/index.tsx +5 -2
- package/themes/original/src/components/MultiCheckout/index.tsx +78 -36
- package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +2 -2
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +2 -2
- package/themes/original/src/components/NavBar/index.tsx +6 -2
- package/themes/original/src/components/NotFoundSource/index.tsx +40 -39
- package/themes/original/src/components/NotFoundSource/styles.tsx +18 -9
- package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
- package/themes/original/src/components/OrderDetails/OrderHistory.tsx +11 -4
- package/themes/original/src/components/OrderDetails/index.tsx +45 -21
- package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
- package/themes/original/src/components/OrderProgress/index.tsx +5 -4
- package/themes/original/src/components/OrderSummary/index.tsx +32 -11
- package/themes/original/src/components/OrderTypeSelector/index.tsx +120 -120
- package/themes/original/src/components/OrdersOption/index.tsx +325 -325
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +1 -0
- package/themes/original/src/components/PaymentOptions/index.tsx +471 -459
- package/themes/original/src/components/PhoneInputNumber/index.tsx +92 -7
- package/themes/original/src/components/ProductForm/ActionButton.tsx +6 -10
- package/themes/original/src/components/ProductItemAccordion/index.tsx +28 -37
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +15 -14
- package/themes/original/src/components/ServiceForm/index.tsx +2 -2
- package/themes/original/src/components/SignupForm/index.tsx +40 -24
- package/themes/original/src/components/SingleOrderCard/index.tsx +8 -5
- package/themes/original/src/components/SingleProductCard/index.tsx +3 -4
- package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
- package/themes/original/src/components/StripeCardsList/index.tsx +9 -4
- package/themes/original/src/components/StripeElementsForm/index.tsx +2 -2
- package/themes/original/src/components/TaxInformation/index.tsx +3 -2
- package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +7 -2
- package/themes/original/src/components/UserDetails/index.tsx +17 -16
- package/themes/original/src/components/UserFormDetails/index.tsx +109 -67
- package/themes/original/src/components/UserVerification/index.tsx +18 -5
- package/themes/original/src/components/VerifyPhone/index.tsx +1 -1
- package/themes/original/src/components/shared/OButton.tsx +2 -2
- package/themes/original/src/components/shared/OInput.tsx +97 -97
- package/themes/original/src/components/shared/OModal.tsx +7 -2
- package/themes/original/src/providers/AlertProvider.tsx +1 -1
- package/themes/original/src/types/index.tsx +700 -693
- package/themes/original/src/utils/index.tsx +50 -34
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/original/src/components/HelpAccountAndPayment/index.tsx +0 -62
- package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +0 -12
- package/themes/original/src/components/HelpGuide/index.tsx +0 -68
- package/themes/original/src/components/HelpGuide/styles.tsx +0 -12
- package/themes/original/src/components/HelpOrder/index.tsx +0 -71
- package/themes/original/src/components/HelpOrder/styles.tsx +0 -13
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import React, { useEffect, useState, useRef } from 'react';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
StyleSheet,
|
|
4
|
+
View,
|
|
5
|
+
TouchableOpacity,
|
|
6
|
+
Keyboard,
|
|
7
|
+
TouchableWithoutFeedback,
|
|
8
|
+
Platform,
|
|
9
9
|
} from 'react-native';
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
AddressForm as AddressFormController,
|
|
12
|
+
useLanguage,
|
|
13
|
+
useConfig,
|
|
14
|
+
useSession,
|
|
15
|
+
useOrder,
|
|
16
|
+
useToast,
|
|
17
|
+
ToastType
|
|
18
18
|
} from 'ordering-components/native';
|
|
19
19
|
import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
|
|
20
20
|
|
|
@@ -31,11 +31,11 @@ import { GoogleMap } from '../GoogleMap';
|
|
|
31
31
|
import NavBar from '../NavBar';
|
|
32
32
|
|
|
33
33
|
import {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
AddressFormContainer,
|
|
35
|
+
AutocompleteInput,
|
|
36
|
+
IconsContainer,
|
|
37
|
+
GoogleMapContainer,
|
|
38
|
+
FormInput,
|
|
39
39
|
} from './styles';
|
|
40
40
|
import { GPSButton } from '../GPSButton';
|
|
41
41
|
import { ScrollView } from 'react-native-gesture-handler';
|
|
@@ -43,880 +43,914 @@ import { ScrollView } from 'react-native-gesture-handler';
|
|
|
43
43
|
const { useDeviceOrientation } = DeviceOrientationMethods
|
|
44
44
|
|
|
45
45
|
const inputNames = [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
{ name: 'address', code: 'Address' },
|
|
47
|
+
{ name: 'internal_number', code: 'Internal number' },
|
|
48
|
+
{ name: 'zipcode', code: 'Zipcode' },
|
|
49
|
+
{ name: 'address_notes', code: 'Address notes' },
|
|
50
50
|
];
|
|
51
51
|
|
|
52
52
|
const AddressFormUI = (props: AddressFormParams) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
53
|
+
const {
|
|
54
|
+
navigation,
|
|
55
|
+
updateChanges,
|
|
56
|
+
address,
|
|
57
|
+
formState,
|
|
58
|
+
isEditing,
|
|
59
|
+
handleChangeInput,
|
|
60
|
+
addressState,
|
|
61
|
+
addressesList,
|
|
62
|
+
saveAddress,
|
|
63
|
+
isGuestUser,
|
|
64
|
+
isRequiredField,
|
|
65
|
+
showField,
|
|
66
|
+
isFromProductsList,
|
|
67
|
+
hasAddressDefault,
|
|
68
|
+
afterSignup,
|
|
69
|
+
businessSlug,
|
|
70
|
+
isFromCheckout,
|
|
71
|
+
onNavigationRedirect
|
|
72
|
+
} = props;
|
|
73
|
+
|
|
74
|
+
const theme = useTheme();
|
|
75
|
+
const [orientationState] = useDeviceOrientation();
|
|
76
|
+
|
|
77
|
+
const [autoCompleteInputFocused, setAutoCompleteInputFocused] = useState(false)
|
|
78
|
+
|
|
79
|
+
const isEmptyField = (key: any, str: any) => isRequiredField && isRequiredField(key) && (!str || str.trim().length === 0)
|
|
80
|
+
|
|
81
|
+
const tagsName = [
|
|
82
|
+
{ icon: theme.images.general.tag_home, value: 'home' },
|
|
83
|
+
{ icon: theme.images.general.tag_building, value: 'office' },
|
|
84
|
+
{ icon: theme.images.general.tag_heart, value: 'favorite' },
|
|
85
|
+
{ icon: theme.images.general.tag_plus, value: 'other' },
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
const HEIGHT_SCREEN = orientationState?.dimensions?.height
|
|
89
|
+
|
|
90
|
+
const styles = StyleSheet.create({
|
|
91
|
+
iconContainer: {
|
|
92
|
+
display: 'flex',
|
|
93
|
+
justifyContent: 'center',
|
|
94
|
+
alignItems: 'center',
|
|
95
|
+
paddingHorizontal: 18,
|
|
96
|
+
paddingVertical: 5,
|
|
97
|
+
backgroundColor: theme.colors.clear
|
|
98
|
+
},
|
|
99
|
+
inputsStyle: {
|
|
100
|
+
borderRadius: 10,
|
|
101
|
+
marginBottom: 20,
|
|
102
|
+
height: 50,
|
|
103
|
+
maxHeight: 50,
|
|
104
|
+
minHeight: 50,
|
|
105
|
+
flex: 1,
|
|
106
|
+
},
|
|
107
|
+
textAreaStyles: {
|
|
108
|
+
borderRadius: 10,
|
|
109
|
+
marginBottom: 20,
|
|
110
|
+
height: 104,
|
|
111
|
+
maxHeight: 104,
|
|
112
|
+
minHeight: 104,
|
|
113
|
+
textAlignVertical: 'top',
|
|
114
|
+
alignItems: 'flex-start',
|
|
115
|
+
},
|
|
116
|
+
pinIcon: {
|
|
117
|
+
position: 'absolute',
|
|
118
|
+
end: 0,
|
|
119
|
+
top: 12,
|
|
120
|
+
zIndex: 1002,
|
|
121
|
+
right: autoCompleteInputFocused && (
|
|
122
|
+
!!address?.address ||
|
|
123
|
+
!!formState.changes?.address ||
|
|
124
|
+
!!addressState.address.address
|
|
125
|
+
) ? 30 : 15,
|
|
126
|
+
width: 16
|
|
127
|
+
},
|
|
128
|
+
wrapperNavbar: Platform.OS === 'ios'
|
|
129
|
+
? { paddingVertical: 0, paddingLeft: 20, paddingRight: 20 }
|
|
130
|
+
: { paddingVertical: 10, paddingLeft: 20, paddingRight: 20 }
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const [, t] = useLanguage();
|
|
134
|
+
const [{ auth }] = useSession();
|
|
135
|
+
const [, { showToast }] = useToast();
|
|
136
|
+
const [configState] = useConfig();
|
|
137
|
+
const [orderState] = useOrder();
|
|
138
|
+
const { handleSubmit, errors, control, setValue } = useForm();
|
|
139
|
+
const [autoCompleteAddress, setAutoCompleteAddress] = useState(false)
|
|
140
|
+
|
|
141
|
+
const [toggleMap, setToggleMap] = useState(false);
|
|
142
|
+
const [alertState, setAlertState] = useState<{
|
|
143
|
+
open: boolean;
|
|
144
|
+
content: Array<string>;
|
|
145
|
+
key?: string | null;
|
|
146
|
+
}>({ open: false, content: [], key: null });
|
|
147
|
+
const [addressTag, setAddressTag] = useState(addressState?.address?.tag);
|
|
148
|
+
const [firstLocationNoEdit, setFirstLocationNoEdit] = useState({
|
|
149
|
+
value: { lat: null, lng: null },
|
|
150
|
+
address: null,
|
|
151
|
+
});
|
|
152
|
+
const [isFirstTime, setIsFirstTime] = useState(true);
|
|
153
|
+
const [locationChange, setLocationChange] = useState(
|
|
154
|
+
isEditing
|
|
155
|
+
? addressState?.address?.location
|
|
156
|
+
: formState.changes?.location ?? null,
|
|
157
|
+
);
|
|
158
|
+
const [saveMapLocation, setSaveMapLocation] = useState(false);
|
|
159
|
+
const [isKeyboardShow, setIsKeyboardShow] = useState(false);
|
|
160
|
+
const [isSignUpEffect, setIsSignUpEffect] = useState(false);
|
|
161
|
+
const [hasEditing, setAddressEditing] = useState(false);
|
|
162
|
+
|
|
163
|
+
const googleInput: any = useRef(null);
|
|
164
|
+
const internalNumberRef: any = useRef(null);
|
|
165
|
+
const zipCodeRef: any = useRef(null);
|
|
166
|
+
const addressNotesRef: any = useRef(null);
|
|
167
|
+
|
|
168
|
+
const googleMapsApiKey = configState?.configs?.google_maps_api_key?.value;
|
|
169
|
+
const isLocationRequired =
|
|
170
|
+
configState.configs?.google_autocomplete_selection_required?.value ===
|
|
171
|
+
'1' ||
|
|
172
|
+
configState.configs?.google_autocomplete_selection_required?.value ===
|
|
173
|
+
'true';
|
|
174
|
+
const maxLimitLocation =
|
|
175
|
+
configState?.configs?.meters_to_change_address?.value;
|
|
176
|
+
const countryCode = configState?.configs?.country_autocomplete?.value
|
|
177
|
+
const isHideMap = theme?.address?.components?.map?.hidden
|
|
178
|
+
const isHideIcons = theme?.address?.components?.icons?.hidden
|
|
179
|
+
const continueAsGuest = () => navigation.navigate(!!businessSlug ? 'Business' : 'BusinessList', { isGuestUser: true });
|
|
180
|
+
const unaddressedTypes = configState?.configs?.unaddressed_order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
|
|
181
|
+
const isAllowUnaddressOrderType = unaddressedTypes.includes(orderState?.options?.type)
|
|
182
|
+
const goToBack = () => navigation?.canGoBack() && navigation.goBack();
|
|
183
|
+
|
|
184
|
+
const getAddressFormatted = (address: any) => {
|
|
185
|
+
const data: any = { address: null, error: null };
|
|
186
|
+
Geocoder.from(address)
|
|
187
|
+
.then((json) => {
|
|
188
|
+
if (json.results && json.results?.length > 0) {
|
|
189
|
+
let postalCode = null;
|
|
190
|
+
for (const component of json.results?.[0].address_components) {
|
|
191
|
+
const addressType = component.types?.[0];
|
|
192
|
+
if (addressType === 'postal_code') {
|
|
193
|
+
postalCode = component.short_name;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
data.address = {
|
|
198
|
+
address,
|
|
199
|
+
location: json.results[0].geometry.location,
|
|
200
|
+
map_data: {
|
|
201
|
+
library: 'google',
|
|
202
|
+
place_id: json.results?.[0].place_id,
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
if (postalCode) {
|
|
206
|
+
data.address.zipcode = postalCode;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const arrayList = isEditing
|
|
210
|
+
? addressesList?.addresses?.filter(
|
|
211
|
+
(address: any) => address.id !== addressState?.address?.id,
|
|
212
|
+
) || []
|
|
213
|
+
: addressesList || [];
|
|
214
|
+
const addressToCompare = isEditing
|
|
215
|
+
? { ...addressState.address, ...data.address, ...formState.changes }
|
|
216
|
+
: { ...data.address, ...formState?.changes };
|
|
217
|
+
|
|
218
|
+
const isAddressAlreadyExist =
|
|
219
|
+
arrayList
|
|
220
|
+
.map((address: any) => checkAddress(address, addressToCompare))
|
|
221
|
+
.some((value: any) => value) ?? false;
|
|
222
|
+
|
|
223
|
+
if (!isAddressAlreadyExist) {
|
|
224
|
+
saveAddress(data.address);
|
|
225
|
+
if (isGuestUser) {
|
|
226
|
+
continueAsGuest();
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (!isGuestUser && !auth) {
|
|
230
|
+
!isFromProductsList
|
|
231
|
+
? navigation.navigate('Business')
|
|
232
|
+
: navigation?.canGoBack() && navigation.goBack();
|
|
233
|
+
}
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
setAlertState({
|
|
238
|
+
open: true,
|
|
239
|
+
content: [t('ADDRESS_ALREADY_EXIST', 'The address already exists')],
|
|
240
|
+
});
|
|
241
|
+
} else {
|
|
242
|
+
setAlertState({
|
|
243
|
+
open: true,
|
|
244
|
+
content: [t('ERROR_NOT_FOUND_ADDRESS', 'Error, address not found')],
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
})
|
|
248
|
+
.catch((error) => {
|
|
249
|
+
setAlertState({
|
|
250
|
+
open: true,
|
|
251
|
+
content: [error?.message || error?.toString()],
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const onSubmit = () => {
|
|
257
|
+
if (
|
|
258
|
+
!auth &&
|
|
259
|
+
formState?.changes?.address === '' &&
|
|
260
|
+
addressState?.address?.address
|
|
261
|
+
) {
|
|
262
|
+
setAlertState({
|
|
263
|
+
open: true,
|
|
264
|
+
content: [
|
|
265
|
+
t(
|
|
266
|
+
'VALIDATION_ERROR_ADDRESS_REQUIRED',
|
|
267
|
+
'The field Address is required',
|
|
268
|
+
),
|
|
269
|
+
],
|
|
270
|
+
});
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (formState?.changes?.address && !formState?.changes?.location) {
|
|
274
|
+
if (isLocationRequired) {
|
|
275
|
+
setAlertState({
|
|
276
|
+
open: true,
|
|
277
|
+
content: [
|
|
278
|
+
t(
|
|
279
|
+
'ADDRESS_REQUIRE_LOCATION',
|
|
280
|
+
'The address needs a location, please select one of the suggested',
|
|
281
|
+
),
|
|
282
|
+
],
|
|
283
|
+
});
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
getAddressFormatted(formState?.changes?.address);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const arrayList = isEditing
|
|
291
|
+
? addressesList?.addresses?.filter(
|
|
292
|
+
(address: any) => address.id !== addressState?.address?.id,
|
|
293
|
+
) || []
|
|
294
|
+
: addressesList || [];
|
|
295
|
+
const addressToCompare = isEditing
|
|
296
|
+
? { ...addressState.address, ...formState.changes }
|
|
297
|
+
: formState?.changes;
|
|
298
|
+
|
|
299
|
+
const isAddressAlreadyExist =
|
|
300
|
+
arrayList
|
|
301
|
+
.map((address: any) => checkAddress(address, addressToCompare))
|
|
302
|
+
.some((value: any) => value) ?? false;
|
|
303
|
+
|
|
304
|
+
if (!isAddressAlreadyExist) {
|
|
305
|
+
saveAddress();
|
|
306
|
+
if (isGuestUser) {
|
|
307
|
+
continueAsGuest();
|
|
308
|
+
}
|
|
309
|
+
if (!isGuestUser && !auth && !afterSignup) {
|
|
310
|
+
!isFromProductsList
|
|
311
|
+
? navigation.navigate('Business')
|
|
312
|
+
: navigation?.canGoBack() && navigation.goBack();
|
|
313
|
+
}
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
setAlertState({
|
|
318
|
+
open: true,
|
|
319
|
+
content: [t('ADDRESS_ALREADY_EXIST', 'The address already exists')],
|
|
320
|
+
});
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Returns true when the user made no changes
|
|
325
|
+
* @param {object} address
|
|
326
|
+
*/
|
|
327
|
+
const checkAddress = (address: any, addressToCompare: any) => {
|
|
328
|
+
const props = [
|
|
329
|
+
'address',
|
|
330
|
+
'address_notes',
|
|
331
|
+
'zipcode',
|
|
332
|
+
'location',
|
|
333
|
+
'internal_number',
|
|
334
|
+
];
|
|
335
|
+
const values: any = [];
|
|
336
|
+
props.forEach((prop) => {
|
|
337
|
+
if (addressToCompare[prop]) {
|
|
338
|
+
if (prop === 'location') {
|
|
339
|
+
values.push(
|
|
340
|
+
address[prop]?.lat === addressToCompare[prop]?.lat &&
|
|
341
|
+
address[prop]?.lng === addressToCompare[prop]?.lng,
|
|
342
|
+
);
|
|
343
|
+
} else {
|
|
344
|
+
values.push(address[prop] === addressToCompare[prop]);
|
|
345
|
+
}
|
|
346
|
+
} else {
|
|
347
|
+
values.push(!address[prop]);
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
return values.every((value: any) => value);
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
const handleChangeAddress = (data: any, details: any) => {
|
|
354
|
+
const addressObj: any = {}
|
|
355
|
+
if (details?.address_components) {
|
|
356
|
+
details.address_components.map((component: any) => {
|
|
357
|
+
const addressType = component.types[0]
|
|
358
|
+
if (addressType === 'postal_code') {
|
|
359
|
+
addressObj.zipcode = component.short_name
|
|
360
|
+
}
|
|
361
|
+
if (addressType === 'street_number') {
|
|
362
|
+
addressObj.street_number = component.long_name
|
|
363
|
+
}
|
|
364
|
+
if (addressType === 'neighborhood') {
|
|
365
|
+
addressObj.neighborhood = component.long_name
|
|
366
|
+
}
|
|
367
|
+
if (addressType === 'route') {
|
|
368
|
+
addressObj.route = component.short_name
|
|
369
|
+
}
|
|
370
|
+
if (addressType === 'locality') {
|
|
371
|
+
addressObj.locality = component.long_name
|
|
372
|
+
}
|
|
373
|
+
if (component.types?.includes('sublocality')) {
|
|
374
|
+
addressObj.sublocality = component.long_name
|
|
375
|
+
}
|
|
376
|
+
if (addressType === 'country') {
|
|
377
|
+
addressObj.country = component.long_name
|
|
378
|
+
addressObj.country_code = component.short_name
|
|
379
|
+
}
|
|
380
|
+
if (addressType === 'administrative_area_level_1') {
|
|
381
|
+
addressObj.state = component.long_name
|
|
382
|
+
}
|
|
383
|
+
if (addressType === 'administrative_area_level_2') {
|
|
384
|
+
addressObj.city = component.long_name
|
|
385
|
+
}
|
|
386
|
+
})
|
|
387
|
+
}
|
|
388
|
+
const addressSelected = {
|
|
389
|
+
address: data?.description || data?.address,
|
|
390
|
+
location: details?.geometry?.location,
|
|
391
|
+
utc_offset: details?.utc_offset || null,
|
|
392
|
+
map_data: { library: 'google', place_id: data.place_id },
|
|
393
|
+
zipcode: data?.zipcode || null,
|
|
394
|
+
...addressObj
|
|
395
|
+
};
|
|
396
|
+
updateChanges(addressSelected);
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
const handleAddressTag = (tag: string) => {
|
|
400
|
+
setAddressTag(tag);
|
|
401
|
+
handleChangeInput({
|
|
402
|
+
target: {
|
|
403
|
+
name: 'tag',
|
|
404
|
+
value: tag,
|
|
405
|
+
},
|
|
406
|
+
});
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
const handleToggleMap = () => {
|
|
410
|
+
setToggleMap(!toggleMap);
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
const showFieldWithTheme = (name) => {
|
|
414
|
+
return !theme?.address?.components?.[name]?.hidden
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
useEffect(() => {
|
|
418
|
+
if (
|
|
419
|
+
orderState.loading &&
|
|
420
|
+
!addressesList &&
|
|
421
|
+
orderState?.options?.address &&
|
|
422
|
+
auth &&
|
|
423
|
+
!afterSignup
|
|
424
|
+
) {
|
|
425
|
+
isFromCheckout
|
|
426
|
+
? navigation.goBack()
|
|
427
|
+
: !isFromProductsList
|
|
428
|
+
? navigation.navigate('BottomTab')
|
|
429
|
+
: navigation.navigate('Business');
|
|
430
|
+
}
|
|
431
|
+
}, [orderState?.options?.address]);
|
|
432
|
+
|
|
433
|
+
useEffect(() => {
|
|
434
|
+
if (alertState.open && alertState?.key !== 'ERROR_MAX_LIMIT_LOCATION') {
|
|
435
|
+
alertState.content && showToast(ToastType.Error, alertState.content);
|
|
436
|
+
}
|
|
437
|
+
}, [alertState.content]);
|
|
438
|
+
|
|
439
|
+
useEffect(() => {
|
|
440
|
+
if (!auth) {
|
|
441
|
+
inputNames.forEach((field) =>
|
|
442
|
+
setValue(
|
|
443
|
+
field.name,
|
|
444
|
+
formState?.changes[field.name] ||
|
|
445
|
+
(orderState?.options?.address &&
|
|
446
|
+
orderState?.options?.address[field.name]) ||
|
|
447
|
+
'',
|
|
448
|
+
),
|
|
449
|
+
);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
if (!formState.loading && formState.result?.error) {
|
|
454
|
+
setAlertState({
|
|
455
|
+
open: true,
|
|
456
|
+
content: formState.result?.result || [t('ERROR', 'Error')],
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
setValue(
|
|
461
|
+
'address',
|
|
462
|
+
formState?.changes?.address ?? addressState.address?.address ?? '',
|
|
463
|
+
);
|
|
464
|
+
if (!isEditing) {
|
|
465
|
+
formState?.changes?.address &&
|
|
466
|
+
setLocationChange(formState?.changes?.location);
|
|
467
|
+
if (
|
|
468
|
+
formState?.changes?.address &&
|
|
469
|
+
formState?.changes?.address !== firstLocationNoEdit?.address &&
|
|
470
|
+
formState?.changes?.location &&
|
|
471
|
+
formState?.changes?.location?.lat !== firstLocationNoEdit.value?.lat &&
|
|
472
|
+
formState?.changes?.location?.lng !== firstLocationNoEdit.value?.lng
|
|
473
|
+
) {
|
|
474
|
+
setFirstLocationNoEdit({
|
|
475
|
+
value: formState?.changes?.location,
|
|
476
|
+
address: formState?.changes?.address,
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (isEditing) {
|
|
482
|
+
if (formState?.changes?.location) {
|
|
483
|
+
const prevLocation = {
|
|
484
|
+
lat: locationChange?.lat?.toFixed(5),
|
|
485
|
+
lng: locationChange?.lng?.toFixed(5),
|
|
486
|
+
};
|
|
487
|
+
const newLocation = {
|
|
488
|
+
lat: formState?.changes?.location?.lat?.toFixed(5),
|
|
489
|
+
lng: formState?.changes?.location?.lng?.toFixed(5),
|
|
490
|
+
};
|
|
491
|
+
if (
|
|
492
|
+
prevLocation?.lat !== newLocation?.lat &&
|
|
493
|
+
prevLocation?.lng !== newLocation?.lng
|
|
494
|
+
) {
|
|
495
|
+
setLocationChange(formState?.changes?.location);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}, [formState]);
|
|
500
|
+
|
|
501
|
+
useEffect(() => {
|
|
502
|
+
if (formState?.result && !formState?.loading) {
|
|
503
|
+
if (formState?.error) {
|
|
504
|
+
showToast(ToastType.Error, formState.error[0]);
|
|
505
|
+
} else {
|
|
506
|
+
showToast(
|
|
507
|
+
ToastType.Success,
|
|
508
|
+
t('UPDATE_SUCCESSFULLY', 'Update successfully'),
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}, [formState.result]);
|
|
513
|
+
|
|
514
|
+
useEffect(() => {
|
|
515
|
+
if (Object.keys(errors).length > 0) {
|
|
516
|
+
// Convert all errors in one string to show in toast provider
|
|
517
|
+
const list = Object.values(errors);
|
|
518
|
+
let stringError = '';
|
|
519
|
+
list.map((item: any, i: number) => {
|
|
520
|
+
stringError +=
|
|
521
|
+
i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
|
|
522
|
+
});
|
|
523
|
+
showToast(ToastType.Error, stringError);
|
|
524
|
+
}
|
|
525
|
+
}, [errors]);
|
|
526
|
+
|
|
527
|
+
useEffect(() => {
|
|
528
|
+
if (googleInput?.current) {
|
|
529
|
+
googleInput?.current?.setAddressText(
|
|
530
|
+
address?.address ||
|
|
531
|
+
formState.changes?.address ||
|
|
532
|
+
addressState.address.address ||
|
|
533
|
+
'',
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
}, []);
|
|
537
|
+
|
|
538
|
+
useEffect(() => {
|
|
539
|
+
Geocoder.init(googleMapsApiKey);
|
|
540
|
+
}, [googleMapsApiKey]);
|
|
541
|
+
|
|
542
|
+
useEffect(() => {
|
|
543
|
+
const keyboardDidShowListener = Keyboard.addListener(
|
|
544
|
+
'keyboardDidShow',
|
|
545
|
+
() => {
|
|
546
|
+
setIsKeyboardShow(true);
|
|
547
|
+
},
|
|
548
|
+
);
|
|
549
|
+
const keyboardDidHideListener = Keyboard.addListener(
|
|
550
|
+
'keyboardDidHide',
|
|
551
|
+
() => {
|
|
552
|
+
setIsKeyboardShow(false);
|
|
553
|
+
},
|
|
554
|
+
);
|
|
555
|
+
return () => {
|
|
556
|
+
keyboardDidShowListener.remove();
|
|
557
|
+
keyboardDidHideListener.remove();
|
|
558
|
+
};
|
|
559
|
+
}, []);
|
|
560
|
+
|
|
561
|
+
useEffect(() => {
|
|
562
|
+
if (!orderState.loading && auth && !hasAddressDefault && isSignUpEffect) {
|
|
563
|
+
navigation.navigate('BottomTab');
|
|
564
|
+
}
|
|
565
|
+
setIsSignUpEffect(true);
|
|
566
|
+
}, [orderState.loading]);
|
|
567
|
+
|
|
568
|
+
useEffect(() => {
|
|
569
|
+
if (isAllowUnaddressOrderType) {
|
|
570
|
+
onNavigationRedirect && onNavigationRedirect(!!businessSlug ? 'Business' : 'BusinessList')
|
|
571
|
+
}
|
|
572
|
+
}, [isAllowUnaddressOrderType])
|
|
573
|
+
|
|
574
|
+
return (
|
|
575
|
+
<ScrollView
|
|
576
|
+
keyboardShouldPersistTaps='always'
|
|
577
|
+
listViewDisplayed={false}
|
|
578
|
+
>
|
|
579
|
+
<View style={styles.wrapperNavbar}>
|
|
580
|
+
<NavBar
|
|
581
|
+
title={t('WHERE_DO_WE_DELIVERY', 'Where do we delivery?')}
|
|
582
|
+
titleAlign={'center'}
|
|
583
|
+
onActionLeft={goToBack}
|
|
584
|
+
showCall={false}
|
|
585
|
+
btnStyle={{ paddingLeft: 0, paddingRight: 5 }}
|
|
586
|
+
style={{ marginTop: Platform.OS === 'ios' ? 0 : 10 }}
|
|
587
|
+
titleWrapStyle={{ paddingHorizontal: 0, width: '100%' }}
|
|
588
|
+
titleStyle={{ marginRight: 0, marginLeft: 0, paddingRight: 5 }}
|
|
589
|
+
/>
|
|
590
|
+
</View>
|
|
591
|
+
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
|
|
592
|
+
<AddressFormContainer style={{ overflow: 'scroll' }}>
|
|
593
|
+
<View>
|
|
594
|
+
<FormInput>
|
|
595
|
+
<AutocompleteInput>
|
|
596
|
+
<Controller
|
|
597
|
+
control={control}
|
|
598
|
+
name="address"
|
|
599
|
+
defaultValue={
|
|
600
|
+
address?.address ||
|
|
601
|
+
formState.changes?.address ||
|
|
602
|
+
addressState.address.address ||
|
|
603
|
+
''
|
|
604
|
+
}
|
|
605
|
+
rules={{
|
|
606
|
+
required:
|
|
607
|
+
isRequiredField && isRequiredField('address')
|
|
608
|
+
? t(
|
|
609
|
+
`VALIDATION_ERROR_ADDRESS_REQUIRED`,
|
|
610
|
+
`The field Address is required`,
|
|
611
|
+
)
|
|
612
|
+
: null,
|
|
613
|
+
}}
|
|
614
|
+
render={() => (
|
|
615
|
+
<GooglePlacesAutocomplete
|
|
616
|
+
placeholder={t('ADD_ADDRESS', 'Add a address')}
|
|
617
|
+
onPress={(data, details: any) => {
|
|
618
|
+
handleChangeAddress(data, details);
|
|
619
|
+
setAutoCompleteAddress(true);
|
|
620
|
+
}}
|
|
621
|
+
query={{
|
|
622
|
+
key: googleMapsApiKey,
|
|
623
|
+
components: countryCode && countryCode !== '*' ? `country:${countryCode}` : ''
|
|
624
|
+
}}
|
|
625
|
+
fetchDetails
|
|
626
|
+
ref={googleInput}
|
|
627
|
+
textInputProps={{
|
|
628
|
+
onChangeText: (text) => {
|
|
629
|
+
if (!isFirstTime) {
|
|
630
|
+
handleChangeInput({
|
|
631
|
+
target: { name: 'address', value: text },
|
|
632
|
+
});
|
|
633
|
+
setValue('address', text);
|
|
634
|
+
setAutoCompleteAddress(true)
|
|
635
|
+
}
|
|
636
|
+
setIsFirstTime(false);
|
|
637
|
+
setAddressEditing(text.length == 0);
|
|
638
|
+
},
|
|
639
|
+
onSubmitEditing: () =>
|
|
640
|
+
internalNumberRef?.current?.focus?.(),
|
|
641
|
+
autoCorrect: false,
|
|
642
|
+
blurOnSubmit: false,
|
|
643
|
+
returnKeyType: 'next',
|
|
644
|
+
onFocus: () => setAutoCompleteInputFocused(true),
|
|
645
|
+
onBlur: () => setAutoCompleteInputFocused(false)
|
|
646
|
+
}}
|
|
647
|
+
onFail={(error) =>
|
|
648
|
+
setAlertState({
|
|
649
|
+
open: true,
|
|
650
|
+
content: getTraduction(error, t),
|
|
651
|
+
})
|
|
652
|
+
}
|
|
653
|
+
styles={{
|
|
654
|
+
listView: {
|
|
655
|
+
position: 'relative',
|
|
656
|
+
borderBottomStartRadius: 15,
|
|
657
|
+
borderBottomEndRadius: 15,
|
|
658
|
+
elevation: 2,
|
|
659
|
+
borderWidth: 1,
|
|
660
|
+
borderColor: '#ddd',
|
|
661
|
+
bottom: 20,
|
|
662
|
+
},
|
|
663
|
+
container: {
|
|
664
|
+
zIndex: 100,
|
|
665
|
+
},
|
|
666
|
+
textInput: {
|
|
667
|
+
borderWidth: 1,
|
|
668
|
+
borderRadius: 7.6,
|
|
669
|
+
borderColor: autoCompleteInputFocused ? theme.colors.primary : theme.colors.border,
|
|
670
|
+
flexGrow: 1,
|
|
671
|
+
fontSize: 15,
|
|
672
|
+
paddingLeft: 16,
|
|
673
|
+
paddingRight: 32,
|
|
674
|
+
minHeight: 50,
|
|
675
|
+
fontFamily: 'Poppins-Regular',
|
|
676
|
+
marginBottom: 24
|
|
677
|
+
},
|
|
678
|
+
}}
|
|
679
|
+
/>
|
|
680
|
+
)}
|
|
681
|
+
/>
|
|
682
|
+
|
|
683
|
+
{(
|
|
684
|
+
((!isEditing && !isGuestUser) ||
|
|
685
|
+
(isEditing && !isGuestUser)) ||
|
|
686
|
+
(isGuestUser)) &&
|
|
687
|
+
(
|
|
688
|
+
<View style={styles.pinIcon}>
|
|
689
|
+
<GPSButton
|
|
690
|
+
apiKey={googleMapsApiKey}
|
|
691
|
+
handleGPS={(data: any, detail: any) => {
|
|
692
|
+
handleChangeAddress(data, detail);
|
|
693
|
+
setValue('address', data.address);
|
|
694
|
+
if (googleInput?.current) {
|
|
695
|
+
googleInput?.current?.setAddressText(data.address);
|
|
696
|
+
}
|
|
697
|
+
}}
|
|
698
|
+
IconButton={<OIcon src={theme.images.general.pin} width={16} />}
|
|
699
|
+
isIntGeoCoder
|
|
700
|
+
/>
|
|
701
|
+
</View>
|
|
702
|
+
)}
|
|
703
|
+
</AutocompleteInput>
|
|
704
|
+
|
|
705
|
+
{!isHideMap && (locationChange || formState.changes?.location) && (
|
|
706
|
+
<View
|
|
707
|
+
style={{
|
|
708
|
+
height: 189,
|
|
709
|
+
borderRadius: 7.6,
|
|
710
|
+
overflow: 'hidden',
|
|
711
|
+
marginBottom: 24,
|
|
712
|
+
}}>
|
|
713
|
+
<GoogleMapContainer>
|
|
714
|
+
<GoogleMap
|
|
715
|
+
location={locationChange || formState.changes?.location}
|
|
716
|
+
handleChangeAddressMap={handleChangeAddress}
|
|
717
|
+
maxLimitLocation={maxLimitLocation}
|
|
718
|
+
saveLocation={saveMapLocation}
|
|
719
|
+
setSaveLocation={setSaveMapLocation}
|
|
720
|
+
handleToggleMap={handleToggleMap}
|
|
721
|
+
isIntGeoCoder
|
|
722
|
+
setAutoCompleteAddress={setAutoCompleteAddress}
|
|
723
|
+
autoCompleteAddress={autoCompleteAddress}
|
|
724
|
+
/>
|
|
725
|
+
</GoogleMapContainer>
|
|
726
|
+
</View>
|
|
727
|
+
)}
|
|
728
|
+
|
|
729
|
+
<View style={{ flexDirection: 'row', flexBasis: '50%' }}>
|
|
730
|
+
{showField?.('internal_number') && ((isRequiredField && isRequiredField('internal_number')) || showFieldWithTheme('internal_number')) && (
|
|
731
|
+
<Controller
|
|
732
|
+
control={control}
|
|
733
|
+
name="internal_number"
|
|
734
|
+
rules={{
|
|
735
|
+
required:
|
|
736
|
+
isRequiredField && isRequiredField('internal_number')
|
|
737
|
+
? t(
|
|
738
|
+
`VALIDATION_ERROR_INTERNAL_NUMBER_REQUIRED`,
|
|
739
|
+
`The field internal number is required`,
|
|
740
|
+
)
|
|
741
|
+
: null,
|
|
742
|
+
}}
|
|
743
|
+
defaultValue={
|
|
744
|
+
address?.internal_number ||
|
|
745
|
+
formState.changes?.internal_number ||
|
|
746
|
+
addressState?.address?.internal_number ||
|
|
747
|
+
''
|
|
748
|
+
}
|
|
749
|
+
render={() => (
|
|
750
|
+
<OInput
|
|
751
|
+
name="internal_number"
|
|
752
|
+
placeholder={t('INTERNAL_NUMBER', 'Internal number')}
|
|
753
|
+
onChange={(data: any) => {
|
|
754
|
+
handleChangeInput(data);
|
|
755
|
+
setValue('internal_number', isEmptyField('internal_number', data?.target?.value) ? null : data);
|
|
756
|
+
}}
|
|
757
|
+
value={
|
|
758
|
+
address?.internal_number ||
|
|
759
|
+
formState.changes?.internal_number ||
|
|
760
|
+
addressState?.address?.internal_number ||
|
|
761
|
+
''
|
|
762
|
+
}
|
|
763
|
+
isFocusHighlight
|
|
764
|
+
style={{
|
|
765
|
+
...styles.inputsStyle,
|
|
766
|
+
marginRight: showField?.('internal_number') && showField?.('zipcode') ? 24 : 0
|
|
767
|
+
}}
|
|
768
|
+
forwardRef={internalNumberRef}
|
|
769
|
+
returnKeyType="next"
|
|
770
|
+
onSubmitEditing={() => zipCodeRef?.current?.focus?.()}
|
|
771
|
+
blurOnSubmit={false}
|
|
772
|
+
/>
|
|
773
|
+
)}
|
|
774
|
+
/>
|
|
775
|
+
)}
|
|
776
|
+
|
|
777
|
+
{showField?.('zipcode') && ((isRequiredField && isRequiredField('zipcode')) || showFieldWithTheme('zipcode')) && (
|
|
778
|
+
<Controller
|
|
779
|
+
control={control}
|
|
780
|
+
name="zipcode"
|
|
781
|
+
rules={{
|
|
782
|
+
required:
|
|
783
|
+
isRequiredField && isRequiredField('zipcode')
|
|
784
|
+
? t(
|
|
785
|
+
`VALIDATION_ERROR_ZIP_CODE_REQUIRED`,
|
|
786
|
+
`The field Zip Code is required`,
|
|
787
|
+
)
|
|
788
|
+
: null,
|
|
789
|
+
}}
|
|
790
|
+
defaultValue={
|
|
791
|
+
address?.zipcode ||
|
|
792
|
+
formState.changes?.zipcode ||
|
|
793
|
+
addressState.address.zipcode ||
|
|
794
|
+
''
|
|
795
|
+
}
|
|
796
|
+
render={() => (
|
|
797
|
+
<OInput
|
|
798
|
+
name="zipcode"
|
|
799
|
+
placeholder={t('ZIP_CODE', 'Zip code')}
|
|
800
|
+
onChange={(data: any) => {
|
|
801
|
+
handleChangeInput(data);
|
|
802
|
+
setValue('zipcode', isEmptyField('zipcode', data?.target?.value) ? null : data);
|
|
803
|
+
}}
|
|
804
|
+
value={
|
|
805
|
+
address?.zipcode ||
|
|
806
|
+
formState.changes?.zipcode ||
|
|
807
|
+
addressState.address.zipcode ||
|
|
808
|
+
''
|
|
809
|
+
}
|
|
810
|
+
isFocusHighlight
|
|
811
|
+
style={styles.inputsStyle}
|
|
812
|
+
forwardRef={zipCodeRef}
|
|
813
|
+
returnKeyType="next"
|
|
814
|
+
onSubmitEditing={() => addressNotesRef?.current?.focus?.()}
|
|
815
|
+
blurOnSubmit={false}
|
|
816
|
+
/>
|
|
817
|
+
)}
|
|
818
|
+
/>
|
|
819
|
+
)}
|
|
820
|
+
</View>
|
|
821
|
+
|
|
822
|
+
{showField?.('address_notes') && ((isRequiredField && isRequiredField('address_notes')) || showFieldWithTheme('address_notes')) && (
|
|
823
|
+
<Controller
|
|
824
|
+
control={control}
|
|
825
|
+
name="address_notes"
|
|
826
|
+
rules={{
|
|
827
|
+
required:
|
|
828
|
+
isRequiredField && isRequiredField('address_notes')
|
|
829
|
+
? t(
|
|
830
|
+
`VALIDATION_ERROR_ADDRESS_NOTES_REQUIRED`,
|
|
831
|
+
`The field address notes is required`,
|
|
832
|
+
)
|
|
833
|
+
: null,
|
|
834
|
+
}}
|
|
835
|
+
defaultValue={
|
|
836
|
+
address?.address_notes ||
|
|
837
|
+
formState.changes?.address_notes ||
|
|
838
|
+
addressState.address.address_notes ||
|
|
839
|
+
''
|
|
840
|
+
}
|
|
841
|
+
render={() => (
|
|
842
|
+
<OInput
|
|
843
|
+
name="address_notes"
|
|
844
|
+
placeholder={t('ADDRESS_NOTES', 'Address notes')}
|
|
845
|
+
onChange={(text: any) => {
|
|
846
|
+
handleChangeInput(text);
|
|
847
|
+
setValue('address_notes', text);
|
|
848
|
+
}}
|
|
849
|
+
value={
|
|
850
|
+
address?.address_notes ||
|
|
851
|
+
formState.changes?.address_notes ||
|
|
852
|
+
addressState.address.address_notes ||
|
|
853
|
+
''
|
|
854
|
+
}
|
|
855
|
+
multiline
|
|
856
|
+
isFocusHighlight
|
|
857
|
+
style={styles.textAreaStyles}
|
|
858
|
+
returnKeyType="done"
|
|
859
|
+
forwardRef={addressNotesRef}
|
|
860
|
+
blurOnSubmit
|
|
861
|
+
/>
|
|
862
|
+
)}
|
|
863
|
+
/>
|
|
864
|
+
)}
|
|
865
|
+
</FormInput>
|
|
866
|
+
{!isHideIcons && (
|
|
867
|
+
<IconsContainer>
|
|
868
|
+
{tagsName.map((tag) => (
|
|
869
|
+
<TouchableOpacity
|
|
870
|
+
key={tag.value}
|
|
871
|
+
onPress={() => handleAddressTag(tag.value)}>
|
|
872
|
+
<View
|
|
873
|
+
style={{
|
|
874
|
+
...styles.iconContainer,
|
|
875
|
+
}}>
|
|
876
|
+
<OIcon
|
|
877
|
+
src={tag.icon}
|
|
878
|
+
width={24}
|
|
879
|
+
color={
|
|
880
|
+
addressTag === tag.value ?
|
|
881
|
+
theme.colors.primary : theme.colors.disabled
|
|
882
|
+
}
|
|
883
|
+
/>
|
|
884
|
+
</View>
|
|
885
|
+
</TouchableOpacity>
|
|
886
|
+
))}
|
|
887
|
+
</IconsContainer>
|
|
888
|
+
)}
|
|
889
|
+
</View>
|
|
890
|
+
|
|
891
|
+
<View>
|
|
892
|
+
{Object.keys(formState?.changes).length > 0 ? (
|
|
893
|
+
<OButton
|
|
894
|
+
text={
|
|
895
|
+
!formState.loading
|
|
896
|
+
? isEditing ||
|
|
897
|
+
(!auth && orderState.options?.address?.address)
|
|
898
|
+
? t('UPDATE', 'Update')
|
|
899
|
+
: t('CONTINUE', 'Continue')
|
|
900
|
+
: t('LOADING', 'Loading')
|
|
901
|
+
}
|
|
902
|
+
onClick={handleSubmit(onSubmit)}
|
|
903
|
+
isDisabled={formState.loading}
|
|
904
|
+
style={{ borderRadius: 7.6, shadowOpacity: 0 }}
|
|
905
|
+
showNextIcon
|
|
906
|
+
/>
|
|
907
|
+
) : (
|
|
908
|
+
<OButton
|
|
909
|
+
text={t('CANCEL', 'Cancel')}
|
|
910
|
+
bgColor={theme.colors.secundary}
|
|
911
|
+
borderColor={theme.colors.secundary}
|
|
912
|
+
textStyle={{ color: theme.colors.textNormal }}
|
|
913
|
+
style={{ borderRadius: 7.6, borderWidth: 1, shadowOpacity: 0 }}
|
|
914
|
+
onClick={() => navigation?.canGoBack() && navigation.goBack()}
|
|
915
|
+
/>
|
|
916
|
+
)}
|
|
917
|
+
</View>
|
|
918
|
+
<OModal
|
|
919
|
+
open={toggleMap}
|
|
920
|
+
onClose={() => handleToggleMap()}
|
|
921
|
+
entireModal
|
|
922
|
+
customClose>
|
|
923
|
+
{(locationChange || formState.changes?.location) && (
|
|
924
|
+
<GoogleMapContainer>
|
|
925
|
+
<GoogleMap
|
|
926
|
+
location={locationChange || formState.changes?.location}
|
|
927
|
+
handleChangeAddressMap={handleChangeAddress}
|
|
928
|
+
maxLimitLocation={maxLimitLocation}
|
|
929
|
+
saveLocation={saveMapLocation}
|
|
930
|
+
setSaveLocation={setSaveMapLocation}
|
|
931
|
+
handleToggleMap={handleToggleMap}
|
|
932
|
+
isIntGeoCoder
|
|
933
|
+
/>
|
|
934
|
+
</GoogleMapContainer>
|
|
935
|
+
)}
|
|
936
|
+
<OButton
|
|
937
|
+
text={t('SAVE', 'Save')}
|
|
938
|
+
imgRightSrc={null}
|
|
939
|
+
style={{ marginHorizontal: 30, marginBottom: 10 }}
|
|
940
|
+
onClick={() => setSaveMapLocation(true)}
|
|
941
|
+
/>
|
|
942
|
+
</OModal>
|
|
943
|
+
<Spinner visible={saveMapLocation} />
|
|
944
|
+
</AddressFormContainer>
|
|
945
|
+
</TouchableWithoutFeedback>
|
|
946
|
+
</ScrollView>
|
|
947
|
+
);
|
|
914
948
|
};
|
|
915
949
|
|
|
916
950
|
export const AddressForm = (props: AddressFormParams) => {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
951
|
+
const addressFormProps = {
|
|
952
|
+
...props,
|
|
953
|
+
UIComponent: AddressFormUI,
|
|
954
|
+
};
|
|
955
|
+
return <AddressFormController {...addressFormProps} />;
|
|
922
956
|
};
|