ordering-ui-react-native 0.16.25 → 0.16.26-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 +7 -4
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/ActiveOrders/index.tsx +61 -63
- package/src/components/ActiveOrders/styles.tsx +8 -14
- package/src/components/AddressForm/index.tsx +18 -2
- package/src/components/BusinessBasicInformation/index.tsx +11 -19
- package/src/components/BusinessInformation/index.tsx +33 -4
- package/src/components/BusinessInformation/styles.tsx +2 -2
- package/src/components/BusinessProductsList/index.tsx +10 -10
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Checkout/index.tsx +2 -1
- package/src/components/LanguageSelector/index.tsx +21 -16
- package/src/components/LoginForm/index.tsx +15 -0
- package/src/components/Messages/index.tsx +2 -2
- package/src/components/NotificationSetting/index.tsx +85 -0
- package/src/components/OrderDetails/index.tsx +2 -20
- package/src/components/OrdersOption/index.tsx +54 -56
- package/src/components/PaymentOptions/index.tsx +335 -365
- package/src/components/PaymentOptionsWebView/index.tsx +120 -121
- package/src/components/ReviewDriver/index.tsx +1 -1
- package/src/components/ReviewOrder/index.tsx +2 -1
- package/src/components/ReviewProducts/index.tsx +11 -0
- package/src/components/SignupForm/index.tsx +15 -0
- package/src/components/SingleProductReview/index.tsx +8 -5
- package/src/components/StripeElementsForm/index.tsx +25 -16
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/components/shared/OBottomPopup.tsx +6 -2
- package/src/index.tsx +2 -0
- package/src/pages/BusinessesListing.tsx +7 -6
- package/src/pages/OrderDetails.tsx +1 -1
- package/src/pages/ReviewDriver.tsx +2 -2
- package/src/pages/ReviewOrder.tsx +2 -2
- package/src/types/@fatnlazycat/react-native-recaptcha-v3/index.d.ts +1 -0
- package/src/utils/index.tsx +0 -1
- package/themes/business/index.tsx +4 -0
- package/themes/business/src/components/BusinessController/index.tsx +2 -2
- package/themes/business/src/components/Chat/index.tsx +42 -34
- package/themes/business/src/components/DriverMap/index.tsx +7 -5
- package/themes/business/src/components/DriverSchedule/index.tsx +71 -0
- package/themes/business/src/components/DriverSchedule/styles.tsx +6 -0
- package/themes/business/src/components/LoginForm/index.tsx +111 -74
- package/themes/business/src/components/MapView/index.tsx +12 -1
- package/themes/business/src/components/MessagesOption/index.tsx +11 -1
- package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +25 -19
- package/themes/business/src/components/OrdersListManager/index.tsx +10 -3
- package/themes/business/src/components/OrdersOption/index.tsx +65 -21
- package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
- package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
- package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
- package/themes/business/src/components/PreviousMessages/index.tsx +17 -18
- package/themes/business/src/components/PreviousOrders/index.tsx +21 -23
- package/themes/business/src/components/ProductItemAccordion/index.tsx +5 -4
- package/themes/business/src/components/ReviewCustomer/index.tsx +1 -1
- package/themes/business/src/components/ScheduleBlocked/index.tsx +53 -0
- package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
- package/themes/business/src/components/UserProfileForm/index.tsx +28 -4
- package/themes/business/src/components/shared/ODropDown.tsx +42 -8
- package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
- package/themes/business/src/components/shared/OModal.tsx +40 -37
- package/themes/business/src/types/index.tsx +15 -9
- package/themes/business/src/utils/index.tsx +10 -0
- 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 +6 -0
- package/themes/kiosk/src/components/LoginForm/index.tsx +121 -10
- package/themes/kiosk/src/components/LoginForm/styles.tsx +5 -0
- 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/shared/OButton.tsx +5 -18
- package/themes/kiosk/src/types/index.d.ts +2 -0
- package/themes/original/index.tsx +12 -0
- package/themes/original/src/components/AddressForm/index.tsx +139 -135
- package/themes/original/src/components/AddressList/index.tsx +1 -1
- package/themes/original/src/components/AppleLogin/index.tsx +4 -4
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +311 -161
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
- package/themes/original/src/components/BusinessController/index.tsx +190 -113
- package/themes/original/src/components/BusinessController/styles.tsx +0 -7
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +4 -4
- package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
- package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
- package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
- package/themes/original/src/components/BusinessListingSearch/index.tsx +81 -128
- package/themes/original/src/components/BusinessListingSearch/styles.tsx +10 -12
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
- package/themes/original/src/components/BusinessProductsList/index.tsx +49 -52
- package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
- package/themes/original/src/components/BusinessProductsListing/index.tsx +289 -175
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -8
- package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +109 -40
- package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +561 -0
- package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Appointment/styles.tsx} +24 -10
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +676 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +137 -0
- package/themes/original/src/components/BusinessesListing/index.tsx +105 -519
- package/themes/original/src/components/Cart/index.tsx +42 -10
- package/themes/original/src/components/Cart/styles.tsx +4 -0
- package/themes/original/src/components/CartContent/index.tsx +22 -16
- package/themes/original/src/components/Checkout/index.tsx +93 -53
- package/themes/original/src/components/Checkout/styles.tsx +0 -1
- package/themes/original/src/components/DriverTips/index.tsx +4 -4
- package/themes/original/src/components/DriverTips/styles.tsx +2 -1
- package/themes/original/src/components/Favorite/index.tsx +1 -0
- package/themes/original/src/components/FavoriteList/index.tsx +32 -2
- package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
- package/themes/original/src/components/GPSButton/index.tsx +20 -19
- package/themes/original/src/components/GoogleMap/index.tsx +20 -12
- package/themes/original/src/components/HelpAccountAndPayment/index.tsx +8 -3
- package/themes/original/src/components/HelpGuide/index.tsx +8 -3
- package/themes/original/src/components/HelpOrder/index.tsx +8 -3
- package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
- package/themes/original/src/components/LoginForm/Otp/index.tsx +95 -72
- package/themes/original/src/components/LoginForm/index.tsx +82 -44
- package/themes/original/src/components/LottieAnimation/index.tsx +69 -0
- package/themes/original/src/components/Messages/index.tsx +17 -17
- package/themes/original/src/components/MomentSelector/index.tsx +197 -0
- package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +92 -92
- package/themes/original/src/components/MultiCheckout/index.tsx +6 -0
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +20 -16
- package/themes/original/src/components/MyOrders/index.tsx +70 -6
- package/themes/original/src/components/NavBar/index.tsx +15 -9
- package/themes/original/src/components/NetworkError/index.tsx +5 -3
- package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
- package/themes/original/src/components/Notifications/index.tsx +148 -0
- package/themes/original/src/components/Notifications/styles.tsx +17 -0
- package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
- package/themes/original/src/components/OrderDetails/index.tsx +190 -35
- package/themes/original/src/components/OrderDetails/styles.tsx +15 -2
- package/themes/original/src/components/OrderItAgain/index.tsx +75 -0
- package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
- package/themes/original/src/components/OrderProgress/index.tsx +8 -2
- package/themes/original/src/components/OrderSummary/index.tsx +1 -34
- package/themes/original/src/components/OrderTypeSelector/index.tsx +85 -36
- package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
- package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +100 -106
- package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +17 -12
- package/themes/original/src/components/OrdersOption/index.tsx +71 -55
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
- package/themes/original/src/components/PaymentOptions/index.tsx +41 -23
- package/themes/original/src/components/PhoneInputNumber/index.tsx +4 -10
- package/themes/original/src/components/PlaceSpot/index.tsx +243 -47
- package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
- package/themes/original/src/components/PreviousOrders/index.tsx +3 -2
- package/themes/original/src/components/ProductForm/index.tsx +710 -653
- package/themes/original/src/components/ProductForm/styles.tsx +9 -7
- package/themes/original/src/components/ProductItemAccordion/index.tsx +199 -128
- package/themes/original/src/components/ProductOption/index.tsx +1 -1
- package/themes/original/src/components/ProfessionalFilter/index.tsx +129 -0
- package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
- package/themes/original/src/components/ProfessionalProfile/index.tsx +309 -0
- package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
- package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
- package/themes/original/src/components/ReviewOrder/index.tsx +18 -3
- package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
- package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
- package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
- package/themes/original/src/components/SearchBar/index.tsx +5 -3
- package/themes/original/src/components/ServiceForm/index.tsx +631 -0
- package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
- package/themes/original/src/components/SignupForm/index.tsx +350 -206
- package/themes/original/src/components/SingleOrderCard/index.tsx +229 -181
- package/themes/original/src/components/SingleOrderCard/styles.tsx +0 -7
- package/themes/original/src/components/SingleProductCard/index.tsx +207 -107
- package/themes/original/src/components/SingleProductCard/styles.tsx +1 -10
- package/themes/original/src/components/SingleProductReview/index.tsx +38 -5
- package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
- package/themes/original/src/components/StripeElementsForm/index.tsx +15 -7
- package/themes/original/src/components/UpsellingProducts/index.tsx +15 -5
- package/themes/original/src/components/UserDetails/index.tsx +31 -17
- package/themes/original/src/components/UserFormDetails/index.tsx +74 -81
- package/themes/original/src/components/UserProfile/index.tsx +54 -29
- package/themes/original/src/components/UserProfile/styles.ts +17 -0
- package/themes/original/src/components/UserProfileForm/index.tsx +15 -10
- package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
- package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
- package/themes/original/src/components/Wallets/index.tsx +174 -162
- package/themes/original/src/components/Wallets/styles.tsx +10 -8
- package/themes/original/src/components/shared/CardAnimation.tsx +47 -0
- package/themes/original/src/components/shared/OBottomPopup.tsx +47 -14
- package/themes/original/src/components/shared/OButton.tsx +10 -3
- package/themes/original/src/components/shared/OIcon.tsx +8 -1
- package/themes/original/src/components/shared/OInput.tsx +3 -2
- package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
- package/themes/original/src/types/index.tsx +121 -30
- package/themes/original/src/utils/index.tsx +77 -0
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
useValidationFields,
|
|
9
9
|
} from 'ordering-components/native';
|
|
10
10
|
import { useTheme } from 'styled-components/native';
|
|
11
|
-
import { CContainer, CheckoutAction, Divider } from './styles';
|
|
11
|
+
import { CContainer, CheckoutAction, Divider, DriverTipsContainer } from './styles';
|
|
12
12
|
|
|
13
13
|
import { OSBill, OSTable, OSCoupon, OSTotal, OSRow } from '../OrderSummary/styles';
|
|
14
14
|
|
|
@@ -25,6 +25,7 @@ import { TaxInformation } from '../TaxInformation';
|
|
|
25
25
|
import { CartStoresListing } from '../CartStoresListing';
|
|
26
26
|
import { OAlert } from '../../../../../src/components/shared'
|
|
27
27
|
import { PlaceSpot } from '../PlaceSpot'
|
|
28
|
+
import { DriverTips } from '../DriverTips'
|
|
28
29
|
|
|
29
30
|
const CartUI = (props: any) => {
|
|
30
31
|
const {
|
|
@@ -60,11 +61,16 @@ const CartUI = (props: any) => {
|
|
|
60
61
|
|
|
61
62
|
const isCartPending = cart?.status === 2
|
|
62
63
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
|
|
63
|
-
|
|
64
|
+
const isCheckoutMultiBusinessEnabled: Boolean = configs?.checkout_multi_business_enabled?.value === '1'
|
|
65
|
+
const openCarts = (Object.values(orderState?.carts)?.filter((cart: any) => cart?.products && cart?.products?.length && cart?.status !== 2 && cart?.valid_schedule && cart?.valid_products && cart?.valid_address && cart?.valid_maximum && cart?.valid_minimum && !cart?.wallets) || null) || []
|
|
64
66
|
|
|
65
67
|
const business: any = (orderState?.carts && Object.values(orderState.carts).find((_cart: any) => _cart?.uuid === props.cartuuid)) ?? {}
|
|
66
68
|
const businessId = business?.business_id ?? null
|
|
67
|
-
const placeSpotTypes = [
|
|
69
|
+
const placeSpotTypes = [4]
|
|
70
|
+
|
|
71
|
+
const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
|
|
72
|
+
? JSON.parse(configs?.driver_tip_options?.value) || []
|
|
73
|
+
: configs?.driver_tip_options?.value || []
|
|
68
74
|
|
|
69
75
|
const momentFormatted = !orderState?.option?.moment
|
|
70
76
|
? t('RIGHT_NOW', 'Right Now')
|
|
@@ -98,11 +104,11 @@ const CartUI = (props: any) => {
|
|
|
98
104
|
const handleUpsellingPage = () => {
|
|
99
105
|
setOpenUpselling(false)
|
|
100
106
|
setCanOpenUpselling(false)
|
|
101
|
-
if (isCheckoutMultiBusinessEnabled) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
if (isCheckoutMultiBusinessEnabled && openCarts.length > 1) {
|
|
108
|
+
props.onNavigationRedirect('CheckoutNavigator', {
|
|
109
|
+
screen: 'MultiCheckout'
|
|
110
|
+
})
|
|
111
|
+
} else {
|
|
106
112
|
props.onNavigationRedirect('CheckoutNavigator', {
|
|
107
113
|
screen: 'CheckoutPage',
|
|
108
114
|
cartUuid: cart?.uuid,
|
|
@@ -355,13 +361,39 @@ const CartUI = (props: any) => {
|
|
|
355
361
|
</OSTable>
|
|
356
362
|
)}
|
|
357
363
|
|
|
364
|
+
{isMultiCheckout &&
|
|
365
|
+
cart &&
|
|
366
|
+
cart?.valid &&
|
|
367
|
+
orderState?.options?.type === 1 &&
|
|
368
|
+
cart?.status !== 2 &&
|
|
369
|
+
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
370
|
+
driverTipsOptions && driverTipsOptions?.length > 0 &&
|
|
371
|
+
(
|
|
372
|
+
<DriverTipsContainer>
|
|
373
|
+
<OText size={14} lineHeight={20} color={theme.colors.textNormal}>
|
|
374
|
+
{t('DRIVER_TIPS', 'Driver Tips')}
|
|
375
|
+
</OText>
|
|
376
|
+
<DriverTips
|
|
377
|
+
uuid={cart?.uuid}
|
|
378
|
+
businessId={cart?.business_id}
|
|
379
|
+
driverTipsOptions={driverTipsOptions}
|
|
380
|
+
isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)}
|
|
381
|
+
isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
|
|
382
|
+
driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1 || !!parseInt(configs?.driver_tip_use_custom?.value, 10)
|
|
383
|
+
? cart?.driver_tip
|
|
384
|
+
: cart?.driver_tip_rate}
|
|
385
|
+
useOrderContext
|
|
386
|
+
/>
|
|
387
|
+
</DriverTipsContainer>
|
|
388
|
+
)}
|
|
389
|
+
|
|
358
390
|
<OSTotal>
|
|
359
391
|
<OSTable style={{ marginTop: 15 }}>
|
|
360
392
|
<OText size={14} lineHeight={21} weight={'600'}>
|
|
361
393
|
{t('TOTAL', 'Total')}
|
|
362
394
|
</OText>
|
|
363
395
|
<OText size={14} lineHeight={21} weight={'600'}>
|
|
364
|
-
{parsePrice(cart?.
|
|
396
|
+
{parsePrice(cart?.balance >= 0 ? cart?.balance : 0)}
|
|
365
397
|
</OText>
|
|
366
398
|
</OSTable>
|
|
367
399
|
</OSTotal>
|
|
@@ -446,7 +478,7 @@ const CartUI = (props: any) => {
|
|
|
446
478
|
</OText>
|
|
447
479
|
</View>
|
|
448
480
|
)}
|
|
449
|
-
</>
|
|
481
|
+
</>
|
|
450
482
|
)}
|
|
451
483
|
</BusinessItemAccordion>
|
|
452
484
|
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import {
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { useLanguage } from 'ordering-components/native';
|
|
3
4
|
import { useTheme } from 'styled-components/native';
|
|
4
5
|
import { CCContainer, CCNotCarts, CCList } from './styles';
|
|
5
6
|
|
|
6
7
|
import { Cart } from '../Cart';
|
|
7
|
-
import {
|
|
8
|
+
import { OButton, OText } from '../shared';
|
|
8
9
|
import Spinner from 'react-native-loading-spinner-overlay';
|
|
9
|
-
import { View } from 'react-native';
|
|
10
10
|
|
|
11
11
|
export const CartContent = (props: any) => {
|
|
12
12
|
const {
|
|
13
13
|
carts,
|
|
14
|
-
isOrderStateCarts
|
|
14
|
+
isOrderStateCarts,
|
|
15
|
+
onNavigationRedirect
|
|
15
16
|
} = props
|
|
16
17
|
|
|
17
18
|
const theme = useTheme();
|
|
@@ -22,18 +23,15 @@ export const CartContent = (props: any) => {
|
|
|
22
23
|
<CCContainer>
|
|
23
24
|
{isOrderStateCarts && carts?.length > 0 && (
|
|
24
25
|
<>
|
|
25
|
-
{/* <OText size={24} lineHeight={36} weight={'600'} style={{ marginBottom: 20 }}>
|
|
26
|
-
{carts.length > 1 ? t('MY_CARTS', 'My Carts') : t('CART', 'Cart')}
|
|
27
|
-
</OText> */}
|
|
28
26
|
{carts.map((cart: any, i: number) => (
|
|
29
27
|
<CCList key={i} style={{ overflow: 'visible' }}>
|
|
30
28
|
{cart.products.length > 0 && (
|
|
31
29
|
<>
|
|
32
30
|
<Cart
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
singleBusiness={props.singleBusiness}
|
|
32
|
+
isFranchiseApp={props.isFranchiseApp}
|
|
35
33
|
cart={cart}
|
|
36
|
-
|
|
34
|
+
cartuuid={cart.uuid}
|
|
37
35
|
onNavigationRedirect={props.onNavigationRedirect}
|
|
38
36
|
isCartsLoading={isCartsLoading}
|
|
39
37
|
setIsCartsLoading={setIsCartsLoading}
|
|
@@ -48,14 +46,22 @@ export const CartContent = (props: any) => {
|
|
|
48
46
|
)}
|
|
49
47
|
{(!carts || carts?.length === 0) && (
|
|
50
48
|
<CCNotCarts>
|
|
51
|
-
{/* <OIcon
|
|
52
|
-
url={props.icon}
|
|
53
|
-
width={200}
|
|
54
|
-
height={122}
|
|
55
|
-
/> */}
|
|
56
49
|
<OText size={24} style={{ textAlign: 'center' }}>
|
|
57
50
|
{t('CARTS_NOT_FOUND', 'You don\'t have carts available')}
|
|
58
51
|
</OText>
|
|
52
|
+
<OButton
|
|
53
|
+
text={t('START_SHOPPING', 'Start shopping')}
|
|
54
|
+
bgColor={theme.colors.primary}
|
|
55
|
+
borderColor={theme.colors.primary}
|
|
56
|
+
textStyle={{
|
|
57
|
+
color: theme.colors.white,
|
|
58
|
+
fontSize: 14,
|
|
59
|
+
paddingRight: 0
|
|
60
|
+
}}
|
|
61
|
+
style={{ height: 35, marginVertical: 20, borderRadius: 8 }}
|
|
62
|
+
imgRightSrc={null}
|
|
63
|
+
onClick={() => onNavigationRedirect('BusinessList')}
|
|
64
|
+
/>
|
|
59
65
|
</CCNotCarts>
|
|
60
66
|
)}
|
|
61
67
|
<Spinner visible={isCartsLoading} />
|
|
@@ -24,6 +24,7 @@ import { DriverTips } from '../DriverTips';
|
|
|
24
24
|
import { NotFoundSource } from '../NotFoundSource';
|
|
25
25
|
import { UserDetails } from '../UserDetails';
|
|
26
26
|
import { PaymentOptionWallet } from '../PaymentOptionWallet';
|
|
27
|
+
import { PlaceSpot } from '../PlaceSpot'
|
|
27
28
|
|
|
28
29
|
import {
|
|
29
30
|
ChContainer,
|
|
@@ -105,8 +106,7 @@ const CheckoutUI = (props: any) => {
|
|
|
105
106
|
padding: 20
|
|
106
107
|
},
|
|
107
108
|
pagePadding: {
|
|
108
|
-
|
|
109
|
-
paddingRight: 40
|
|
109
|
+
paddingHorizontal: 40
|
|
110
110
|
},
|
|
111
111
|
icon: {
|
|
112
112
|
top: 15,
|
|
@@ -114,6 +114,10 @@ const CheckoutUI = (props: any) => {
|
|
|
114
114
|
position: 'absolute',
|
|
115
115
|
fontSize: 20
|
|
116
116
|
},
|
|
117
|
+
detailWrapper: {
|
|
118
|
+
paddingHorizontal: 40,
|
|
119
|
+
width: '100%'
|
|
120
|
+
},
|
|
117
121
|
wrapperNavbar: Platform.OS === 'ios'
|
|
118
122
|
? { paddingVertical: 0, paddingHorizontal: 40 }
|
|
119
123
|
: { paddingVertical: 20, paddingHorizontal: 40 }
|
|
@@ -136,8 +140,11 @@ const CheckoutUI = (props: any) => {
|
|
|
136
140
|
const [isDeliveryOptionModalVisible, setIsDeliveryOptionModalVisible] = useState(false)
|
|
137
141
|
const [showGateway, setShowGateway] = useState<any>({ closedByUsed: false, open: false });
|
|
138
142
|
const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
|
|
143
|
+
const [isOpen, setIsOpen] = useState(false)
|
|
144
|
+
const [requiredFields, setRequiredFields] = useState<any>([])
|
|
139
145
|
|
|
140
|
-
const placeSpotTypes = [3, 4]
|
|
146
|
+
const placeSpotTypes = [3, 4, 5]
|
|
147
|
+
const placeSpotsEnabled = placeSpotTypes.includes(options?.type)
|
|
141
148
|
const businessConfigs = businessDetails?.business?.configs ?? []
|
|
142
149
|
const isWalletCashEnabled = businessConfigs.find((config: any) => config.key === 'wallet_cash_enabled')?.value === '1'
|
|
143
150
|
const isWalletCreditPointsEnabled = businessConfigs.find((config: any) => config.key === 'wallet_credit_point_enabled')?.value === '1'
|
|
@@ -145,8 +152,9 @@ const CheckoutUI = (props: any) => {
|
|
|
145
152
|
const isBusinessChangeEnabled = configs?.cart_change_business_validation?.value === '1'
|
|
146
153
|
|
|
147
154
|
const isPreOrder = configs?.preorder_status_enabled?.value === '1'
|
|
148
|
-
const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) ||
|
|
149
|
-
|
|
155
|
+
const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) ||
|
|
156
|
+
placing || errorCash || cart?.subtotal < cart?.minimum ||
|
|
157
|
+
// (placeSpotTypes.includes(options?.type) && !cart?.place) ||
|
|
150
158
|
(options.type === 1 &&
|
|
151
159
|
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
152
160
|
validationFields?.fields?.checkout?.driver_tip?.required &&
|
|
@@ -172,11 +180,15 @@ const CheckoutUI = (props: any) => {
|
|
|
172
180
|
}
|
|
173
181
|
}
|
|
174
182
|
|
|
175
|
-
const handlePlaceOrder = (confirmPayment) => {
|
|
176
|
-
if (!userErrors.length) {
|
|
183
|
+
const handlePlaceOrder = (confirmPayment: any, forcePlace: boolean = false) => {
|
|
184
|
+
if (!userErrors.length && !requiredFields?.length || forcePlace) {
|
|
177
185
|
handlerClickPlaceOrder && handlerClickPlaceOrder(null, null, confirmPayment)
|
|
178
186
|
return
|
|
179
187
|
}
|
|
188
|
+
if (requiredFields?.length) {
|
|
189
|
+
setIsOpen(true)
|
|
190
|
+
return
|
|
191
|
+
}
|
|
180
192
|
let stringError = ''
|
|
181
193
|
Object.values(userErrors).map((item: any, i: number) => {
|
|
182
194
|
stringError += (i + 1) === userErrors.length ? `- ${item?.message || item}` : `- ${item?.message || item}\n`
|
|
@@ -204,11 +216,12 @@ const CheckoutUI = (props: any) => {
|
|
|
204
216
|
setUserErrors([])
|
|
205
217
|
const errors = []
|
|
206
218
|
const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes']
|
|
219
|
+
const _requiredFields: any = []
|
|
207
220
|
|
|
208
221
|
Object.values(validationFields?.fields?.checkout).map((field: any) => {
|
|
209
|
-
if (field?.required && !notFields.includes(field.code)) {
|
|
222
|
+
if (field?.required && !notFields.includes(field.code) && field?.enabled) {
|
|
210
223
|
if (!user[field?.code]) {
|
|
211
|
-
|
|
224
|
+
_requiredFields.push(field?.code)
|
|
212
225
|
}
|
|
213
226
|
}
|
|
214
227
|
})
|
|
@@ -219,8 +232,9 @@ const CheckoutUI = (props: any) => {
|
|
|
219
232
|
validationFields?.fields?.checkout?.cellphone?.required) ||
|
|
220
233
|
configs?.verification_phone_required?.value === '1')
|
|
221
234
|
) {
|
|
222
|
-
|
|
235
|
+
_requiredFields.push('cellphone')
|
|
223
236
|
}
|
|
237
|
+
setRequiredFields(_requiredFields)
|
|
224
238
|
|
|
225
239
|
if (phoneUpdate) {
|
|
226
240
|
errors.push(t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number'))
|
|
@@ -315,10 +329,10 @@ const CheckoutUI = (props: any) => {
|
|
|
315
329
|
!businessDetails?.error &&
|
|
316
330
|
(
|
|
317
331
|
<Placeholder Animation={Fade}>
|
|
318
|
-
<PlaceholderLine height={20}
|
|
319
|
-
<PlaceholderLine height={
|
|
320
|
-
<PlaceholderLine height={
|
|
321
|
-
<PlaceholderLine height={
|
|
332
|
+
<PlaceholderLine height={20} />
|
|
333
|
+
<PlaceholderLine height={12} />
|
|
334
|
+
<PlaceholderLine height={12} />
|
|
335
|
+
<PlaceholderLine height={12} style={{ marginBottom: 20 }} />
|
|
322
336
|
</Placeholder>
|
|
323
337
|
)}
|
|
324
338
|
{
|
|
@@ -364,10 +378,10 @@ const CheckoutUI = (props: any) => {
|
|
|
364
378
|
<ChUserDetails>
|
|
365
379
|
{cartState.loading ? (
|
|
366
380
|
<Placeholder Animation={Fade}>
|
|
367
|
-
<PlaceholderLine height={20}
|
|
368
|
-
<PlaceholderLine height={
|
|
369
|
-
<PlaceholderLine height={
|
|
370
|
-
<PlaceholderLine height={
|
|
381
|
+
<PlaceholderLine height={20} />
|
|
382
|
+
<PlaceholderLine height={12} />
|
|
383
|
+
<PlaceholderLine height={12} />
|
|
384
|
+
<PlaceholderLine height={12} style={{ marginBottom: 20 }} />
|
|
371
385
|
</Placeholder>
|
|
372
386
|
) : (
|
|
373
387
|
<UserDetails
|
|
@@ -391,8 +405,8 @@ const CheckoutUI = (props: any) => {
|
|
|
391
405
|
{cartState.loading || deliveryOptionSelected === undefined ? (
|
|
392
406
|
<View style={{ height: 110 }}>
|
|
393
407
|
<Placeholder Animation={Fade}>
|
|
394
|
-
<PlaceholderLine height={20}
|
|
395
|
-
<PlaceholderLine height={40}
|
|
408
|
+
<PlaceholderLine height={20} />
|
|
409
|
+
<PlaceholderLine height={40} />
|
|
396
410
|
</Placeholder>
|
|
397
411
|
</View>
|
|
398
412
|
) : (
|
|
@@ -583,6 +597,20 @@ const CheckoutUI = (props: any) => {
|
|
|
583
597
|
)}
|
|
584
598
|
|
|
585
599
|
|
|
600
|
+
{!cartState.loading && placeSpotsEnabled && (
|
|
601
|
+
<>
|
|
602
|
+
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 30, marginHorizontal: -40 }} />
|
|
603
|
+
<PlaceSpot
|
|
604
|
+
isCheckout
|
|
605
|
+
isInputMode
|
|
606
|
+
cart={cart}
|
|
607
|
+
spotNumberDefault={cartState?.cart?.spot_number ?? cart?.spot_number}
|
|
608
|
+
vehicleDefault={cart?.vehicle}
|
|
609
|
+
/>
|
|
610
|
+
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
611
|
+
</>
|
|
612
|
+
)}
|
|
613
|
+
|
|
586
614
|
{!cartState.loading && cart && (
|
|
587
615
|
<ChSection>
|
|
588
616
|
<ChCart>
|
|
@@ -634,6 +662,7 @@ const CheckoutUI = (props: any) => {
|
|
|
634
662
|
cart={cart}
|
|
635
663
|
isCartPending={cart?.status === 2}
|
|
636
664
|
onNavigationRedirect={onNavigationRedirect}
|
|
665
|
+
placeSpotTypes={placeSpotTypes}
|
|
637
666
|
/>
|
|
638
667
|
</>
|
|
639
668
|
)}
|
|
@@ -670,14 +699,6 @@ const CheckoutUI = (props: any) => {
|
|
|
670
699
|
{t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
|
|
671
700
|
</OText>
|
|
672
701
|
)}
|
|
673
|
-
{placeSpotTypes.includes(options?.type) && !cart?.place && (
|
|
674
|
-
<OText
|
|
675
|
-
color={theme.colors.error}
|
|
676
|
-
size={12}
|
|
677
|
-
>
|
|
678
|
-
{t('WARNING_PLACE_SPOT', 'Please, select your spot to place order.')}
|
|
679
|
-
</OText>
|
|
680
|
-
)}
|
|
681
702
|
{options.type === 1 &&
|
|
682
703
|
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
683
704
|
validationFields?.fields?.checkout?.driver_tip?.required &&
|
|
@@ -703,11 +724,36 @@ const CheckoutUI = (props: any) => {
|
|
|
703
724
|
onClose={() => setOpenChangeStore(false)}
|
|
704
725
|
/>
|
|
705
726
|
</OModal>
|
|
727
|
+
<OModal
|
|
728
|
+
open={isOpen}
|
|
729
|
+
onClose={() => setIsOpen(false)}
|
|
730
|
+
>
|
|
731
|
+
<View style={styles.detailWrapper}>
|
|
732
|
+
<UserDetails
|
|
733
|
+
isUserDetailsEdit
|
|
734
|
+
cartStatus={cart?.status}
|
|
735
|
+
businessId={cart?.business_id}
|
|
736
|
+
useValidationFields
|
|
737
|
+
useDefualtSessionManager
|
|
738
|
+
useSessionUser
|
|
739
|
+
isCheckout
|
|
740
|
+
isEdit
|
|
741
|
+
phoneUpdate={phoneUpdate}
|
|
742
|
+
togglePhoneUpdate={togglePhoneUpdate}
|
|
743
|
+
requiredFields={requiredFields}
|
|
744
|
+
hideUpdateButton
|
|
745
|
+
onClose={() => {
|
|
746
|
+
setIsOpen(false)
|
|
747
|
+
handlePlaceOrder(null, true)
|
|
748
|
+
}}
|
|
749
|
+
/>
|
|
750
|
+
</View>
|
|
751
|
+
</OModal>
|
|
706
752
|
</ChContainer>
|
|
707
753
|
</Container>
|
|
708
754
|
{!cartState.loading && cart && cart?.status !== 2 && (
|
|
709
755
|
<FloatingButton
|
|
710
|
-
handleClick={() => handlePlaceOrder()}
|
|
756
|
+
handleClick={() => handlePlaceOrder(null)}
|
|
711
757
|
isSecondaryBtn={isDisabledButtonPlace}
|
|
712
758
|
disabled={isDisabledButtonPlace}
|
|
713
759
|
btnText={cart?.subtotal >= cart?.minimum
|
|
@@ -721,7 +767,7 @@ const CheckoutUI = (props: any) => {
|
|
|
721
767
|
: (`${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`)
|
|
722
768
|
}
|
|
723
769
|
btnRightValueShow
|
|
724
|
-
btnRightValue={parsePrice(cart?.
|
|
770
|
+
btnRightValue={parsePrice(cart?.balance)}
|
|
725
771
|
iosBottom={30}
|
|
726
772
|
/>
|
|
727
773
|
)}
|
|
@@ -737,19 +783,6 @@ const CheckoutUI = (props: any) => {
|
|
|
737
783
|
setShowGateway={setShowGateway}
|
|
738
784
|
/>
|
|
739
785
|
)}
|
|
740
|
-
{webviewPaymethod?.gateway === 'square' && showGateway.open && (
|
|
741
|
-
<PaymentOptionsWebView
|
|
742
|
-
onNavigationRedirect={onNavigationRedirect}
|
|
743
|
-
uri={`https://test-square-f50f7.web.app`}
|
|
744
|
-
user={user}
|
|
745
|
-
token={token}
|
|
746
|
-
cart={cart}
|
|
747
|
-
currency={currency}
|
|
748
|
-
webviewPaymethod={webviewPaymethod}
|
|
749
|
-
setShowGateway={setShowGateway}
|
|
750
|
-
locationId={'L1NGAY5M6KJRX'}
|
|
751
|
-
/>
|
|
752
|
-
)}
|
|
753
786
|
</>
|
|
754
787
|
)
|
|
755
788
|
}
|
|
@@ -775,16 +808,23 @@ export const Checkout = (props: any) => {
|
|
|
775
808
|
|
|
776
809
|
const getOrder = async (cartId: any) => {
|
|
777
810
|
try {
|
|
778
|
-
|
|
779
|
-
const
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
811
|
+
let result: any = {}
|
|
812
|
+
const cart = orderState?.carts.find((cart: any) => cart.uuid === cartId)
|
|
813
|
+
if (cart) {
|
|
814
|
+
result = { ...cart }
|
|
815
|
+
} else {
|
|
816
|
+
setCartState({ ...cartState, loading: true })
|
|
817
|
+
const url = `${ordering.root}/carts/${cartId}`
|
|
818
|
+
const response = await fetch(url, {
|
|
819
|
+
method: 'GET',
|
|
820
|
+
headers: {
|
|
821
|
+
'Content-Type': 'application/json',
|
|
822
|
+
Authorization: `Bearer ${token}`
|
|
823
|
+
}
|
|
824
|
+
})
|
|
825
|
+
const content = await response.json();
|
|
826
|
+
result = content.result
|
|
827
|
+
}
|
|
788
828
|
|
|
789
829
|
let publicKey = null
|
|
790
830
|
try {
|
|
@@ -35,8 +35,8 @@ const DriverTipsUI = (props: any) => {
|
|
|
35
35
|
const theme = useTheme();
|
|
36
36
|
|
|
37
37
|
const style = StyleSheet.create({
|
|
38
|
-
|
|
39
|
-
borderRadius:
|
|
38
|
+
semicircle: {
|
|
39
|
+
borderRadius: 8
|
|
40
40
|
},
|
|
41
41
|
inputStyle: {
|
|
42
42
|
flex: 1,
|
|
@@ -75,10 +75,10 @@ const DriverTipsUI = (props: any) => {
|
|
|
75
75
|
onPress={() => handlerChangeOption(option)}
|
|
76
76
|
>
|
|
77
77
|
<DTCard
|
|
78
|
-
style={style.
|
|
78
|
+
style={style.semicircle}
|
|
79
79
|
isActive={option === optionSelected}
|
|
80
80
|
>
|
|
81
|
-
<OText size={12} numberOfLines={
|
|
81
|
+
<OText size={12} numberOfLines={2} color={option === optionSelected ? '#FFF' : theme.colors.textSecondary}>
|
|
82
82
|
{`${isFixedPrice ? parsePrice(option) : `${option}%`}`}
|
|
83
83
|
</OText>
|
|
84
84
|
</DTCard>
|
|
@@ -26,11 +26,12 @@ export const DTCard = styled.View`
|
|
|
26
26
|
text-transform: capitalize;
|
|
27
27
|
min-height: 55px;
|
|
28
28
|
min-width: 55px;
|
|
29
|
-
max-width:
|
|
29
|
+
max-width: 80px;
|
|
30
30
|
max-height: 55px;
|
|
31
31
|
margin-right: 10px;
|
|
32
32
|
margin-left: 10px;
|
|
33
33
|
margin-top: 10px;
|
|
34
|
+
padding-horizontal: 10px;
|
|
34
35
|
|
|
35
36
|
${(props: any) => props.isActive && css`
|
|
36
37
|
background-color: ${(props: any) => props.theme.colors.primary};
|
|
@@ -14,6 +14,7 @@ import { Container, WrappButton } from './styles'
|
|
|
14
14
|
import { OButton } from '../shared';
|
|
15
15
|
import { BusinessController } from '../BusinessController';
|
|
16
16
|
import { SingleProductCard } from '../SingleProductCard';
|
|
17
|
+
import { NotFoundSource } from '../NotFoundSource';
|
|
17
18
|
import moment from 'moment';
|
|
18
19
|
|
|
19
20
|
|
|
@@ -73,6 +74,17 @@ const FavoriteListUI = (props: FavoriteParams) => {
|
|
|
73
74
|
return objectStatus && objectStatus
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
const onProductClick = (product: any) => {
|
|
78
|
+
const categoryId = product?.category?.id
|
|
79
|
+
const businessId = product?.category?.business?.id
|
|
80
|
+
if (!categoryId || !businessId) return
|
|
81
|
+
onNavigationRedirect && onNavigationRedirect('ProductDetails', {
|
|
82
|
+
productId: product?.id,
|
|
83
|
+
categoryId: categoryId,
|
|
84
|
+
businessId: businessId
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
76
88
|
useEffect(() => {
|
|
77
89
|
const _businessId = 'businessId:' + reorderState?.result?.business_id
|
|
78
90
|
if (reorderState?.error) {
|
|
@@ -213,6 +225,12 @@ const FavoriteListUI = (props: FavoriteParams) => {
|
|
|
213
225
|
<BusinessSkeleton key={i} />
|
|
214
226
|
))
|
|
215
227
|
)}
|
|
228
|
+
{!favoriteList?.loading && !favoriteList?.favorites?.length && (
|
|
229
|
+
<NotFoundSource
|
|
230
|
+
content={t('NOT_FOUND_FAVORITES_LIST', 'No favorites to show at this time.')
|
|
231
|
+
}
|
|
232
|
+
/>
|
|
233
|
+
)}
|
|
216
234
|
</>
|
|
217
235
|
)}
|
|
218
236
|
|
|
@@ -239,6 +257,12 @@ const FavoriteListUI = (props: FavoriteParams) => {
|
|
|
239
257
|
<OrderSkeleton key={i} />
|
|
240
258
|
))
|
|
241
259
|
)}
|
|
260
|
+
{!favoriteList?.loading && !favoriteList?.favorites?.length && (
|
|
261
|
+
<NotFoundSource
|
|
262
|
+
content={t('NOT_FOUND_FAVORITES_LIST', 'No favorites to show at this time.')
|
|
263
|
+
}
|
|
264
|
+
/>
|
|
265
|
+
)}
|
|
242
266
|
</>
|
|
243
267
|
)}
|
|
244
268
|
|
|
@@ -248,9 +272,9 @@ const FavoriteListUI = (props: FavoriteParams) => {
|
|
|
248
272
|
favoriteList.favorites?.sort((a: any, b: any) => a?.name?.toLowerCase() > b?.name?.toLowerCase()).map((product: any, i: number) => (
|
|
249
273
|
<SingleProductCard
|
|
250
274
|
key={`${product?.id}_${i}`}
|
|
251
|
-
isSoldOut={product
|
|
275
|
+
isSoldOut={product?.inventoried && !product?.quantity}
|
|
252
276
|
product={product}
|
|
253
|
-
onProductClick={
|
|
277
|
+
onProductClick={onProductClick}
|
|
254
278
|
handleUpdateProducts={handleUpdateFavoriteList}
|
|
255
279
|
/>
|
|
256
280
|
))
|
|
@@ -260,6 +284,12 @@ const FavoriteListUI = (props: FavoriteParams) => {
|
|
|
260
284
|
<ProductSkeleton key={i} />
|
|
261
285
|
))
|
|
262
286
|
)}
|
|
287
|
+
{!favoriteList?.loading && !favoriteList?.favorites?.length && (
|
|
288
|
+
<NotFoundSource
|
|
289
|
+
content={t('NOT_FOUND_FAVORITES_LIST', 'No favorites to show at this time.')
|
|
290
|
+
}
|
|
291
|
+
/>
|
|
292
|
+
)}
|
|
263
293
|
</>
|
|
264
294
|
)}
|
|
265
295
|
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react'
|
|
2
|
-
import { getTrackingStatus, requestTrackingPermission } from 'react-native-tracking-transparency'
|
|
3
|
-
import Geolocation from '@react-native-community/geolocation'
|
|
4
2
|
import Geocoder from 'react-native-geocoding'
|
|
5
|
-
import { GpsButtonStyle } from './styles'
|
|
6
|
-
import { View } from 'react-native'
|
|
7
|
-
import { OText } from '../shared'
|
|
8
3
|
import { ActivityIndicator } from 'react-native-paper'
|
|
4
|
+
import Geolocation from '@react-native-community/geolocation'
|
|
5
|
+
import { getTrackingStatus, requestTrackingPermission } from 'react-native-tracking-transparency'
|
|
6
|
+
|
|
7
|
+
import { OText } from '../shared'
|
|
8
|
+
import { GpsButtonStyle } from './styles'
|
|
9
9
|
|
|
10
10
|
export const GPSButton = (props: any) => {
|
|
11
11
|
const {
|
|
12
12
|
handleGPS,
|
|
13
13
|
apiKey,
|
|
14
|
-
googleReady,
|
|
15
14
|
IconButton,
|
|
16
15
|
IconLoadingButton
|
|
17
16
|
} = props
|
|
@@ -56,25 +55,27 @@ export const GPSButton = (props: any) => {
|
|
|
56
55
|
})
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
|
|
58
|
+
const getCurrentPosition = async () => {
|
|
60
59
|
let trackingStatus = await getTrackingStatus()
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
setLoading(true)
|
|
60
|
+
if (trackingStatus === 'not-determined') {
|
|
61
|
+
trackingStatus = await requestTrackingPermission()
|
|
62
|
+
}
|
|
63
|
+
if (trackingStatus === 'authorized' || trackingStatus === 'unavailable') {
|
|
64
|
+
setLoading(true)
|
|
66
65
|
Geolocation.getCurrentPosition((pos) => {
|
|
67
|
-
geoCodePosition(pos.coords)
|
|
66
|
+
geoCodePosition(pos.coords)
|
|
68
67
|
}, (err) => {
|
|
69
68
|
setLoading(false);
|
|
70
|
-
console.log(err)
|
|
71
|
-
}
|
|
69
|
+
console.log(`ERROR(${err.code}): ${err.message}`)
|
|
70
|
+
}, {
|
|
71
|
+
enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
|
|
72
|
+
})
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
+
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
Geocoder.init(apiKey);
|
|
78
|
+
}, [])
|
|
78
79
|
|
|
79
80
|
return (
|
|
80
81
|
<GpsButtonStyle
|