ordering-ui-react-native 0.15.78 → 0.15.79-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 -3
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/ActiveOrders/index.tsx +61 -63
- package/src/components/ActiveOrders/styles.tsx +1 -1
- package/src/components/AddressForm/index.tsx +18 -2
- package/src/components/BusinessBasicInformation/index.tsx +11 -19
- package/src/components/BusinessController/index.tsx +16 -8
- package/src/components/BusinessInformation/index.tsx +14 -0
- package/src/components/BusinessTypeFilter/index.tsx +1 -2
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Checkout/index.tsx +25 -3
- package/src/components/DriverTips/index.tsx +11 -6
- package/src/components/LanguageSelector/index.tsx +6 -2
- package/src/components/LoginForm/index.tsx +120 -30
- package/src/components/LoginForm/styles.tsx +6 -0
- package/src/components/NotificationSetting/index.tsx +85 -0
- package/src/components/OrderDetails/index.tsx +7 -21
- 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 +145 -61
- package/src/components/SingleProductCard/index.tsx +16 -4
- package/src/components/SingleProductReview/index.tsx +1 -1
- package/src/components/StripeElementsForm/index.tsx +25 -16
- package/src/components/StripeMethodForm/index.tsx +22 -24
- package/src/components/UpsellingProducts/index.tsx +1 -1
- package/src/components/UserProfileForm/index.tsx +63 -6
- package/src/components/UserProfileForm/styles.tsx +8 -0
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/components/shared/OBottomPopup.tsx +6 -2
- package/src/components/shared/OModal.tsx +1 -1
- package/src/hooks/useCountdownTimer.tsx +26 -0
- package/src/index.tsx +2 -0
- package/src/navigators/CheckoutNavigator.tsx +6 -0
- package/src/navigators/HomeNavigator.tsx +12 -0
- package/src/pages/BusinessesListing.tsx +7 -6
- package/src/pages/MultiCheckout.tsx +31 -0
- package/src/pages/MultiOrdersDetails.tsx +27 -0
- package/src/pages/OrderDetails.tsx +1 -1
- package/src/pages/ReviewDriver.tsx +2 -2
- package/src/pages/ReviewOrder.tsx +2 -2
- package/src/pages/Sessions.tsx +22 -0
- package/src/theme.json +0 -1
- package/src/types/index.tsx +18 -11
- package/src/utils/index.tsx +28 -29
- package/themes/business/index.tsx +4 -0
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +100 -60
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
- package/themes/business/src/components/Chat/index.tsx +51 -91
- package/themes/business/src/components/DriverMap/index.tsx +6 -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 +89 -2
- package/themes/business/src/components/LoginForm/styles.tsx +6 -0
- package/themes/business/src/components/LogoutButton/index.tsx +1 -1
- package/themes/business/src/components/NewOrderNotification/index.tsx +26 -13
- package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +28 -11
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +26 -18
- package/themes/business/src/components/OrdersListManager/index.tsx +11 -4
- package/themes/business/src/components/OrdersOption/index.tsx +16 -4
- package/themes/business/src/components/PreviousOrders/index.tsx +7 -7
- package/themes/business/src/components/ProductItemAccordion/index.tsx +5 -4
- 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/OModal.tsx +41 -38
- package/themes/business/src/types/index.tsx +15 -7
- 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/BusinessMenu/index.tsx +39 -28
- package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
- package/themes/kiosk/src/components/Cart/index.tsx +11 -12
- package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
- package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
- package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
- package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
- package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
- package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
- package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
- package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
- package/themes/kiosk/src/components/NavBar/index.tsx +29 -20
- package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderDetails/index.tsx +32 -27
- package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
- package/themes/kiosk/src/components/PaymentOptions/index.tsx +56 -54
- package/themes/kiosk/src/components/ProductForm/index.tsx +6 -7
- package/themes/kiosk/src/components/ProductItemAccordion/index.tsx +2 -2
- package/themes/kiosk/src/components/ProductOption/index.tsx +1 -1
- package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
- package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/kiosk/src/types/index.d.ts +1 -0
- package/themes/original/index.tsx +24 -0
- package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
- package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
- package/themes/original/src/components/AddressForm/index.tsx +7 -6
- package/themes/original/src/components/AddressList/index.tsx +2 -2
- package/themes/original/src/components/AppleLogin/index.tsx +6 -8
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +291 -150
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
- package/themes/original/src/components/BusinessController/index.tsx +201 -96
- package/themes/original/src/components/BusinessController/styles.tsx +5 -0
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
- package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
- package/themes/original/src/components/BusinessListingSearch/index.tsx +234 -64
- package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
- package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
- package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
- package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
- 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 +65 -73
- package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
- package/themes/original/src/components/BusinessProductsListing/index.tsx +315 -176
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +11 -0
- package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +106 -38
- package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +560 -0
- package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Appointment/styles.tsx} +24 -2
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +661 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +137 -0
- package/themes/original/src/components/BusinessesListing/index.tsx +104 -462
- package/themes/original/src/components/Cart/index.tsx +84 -39
- package/themes/original/src/components/Cart/styles.tsx +4 -0
- package/themes/original/src/components/Checkout/index.tsx +100 -50
- package/themes/original/src/components/Checkout/styles.tsx +0 -1
- package/themes/original/src/components/DriverTips/index.tsx +17 -12
- package/themes/original/src/components/Favorite/index.tsx +92 -0
- package/themes/original/src/components/Favorite/styles.tsx +22 -0
- package/themes/original/src/components/FavoriteList/index.tsx +298 -0
- package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
- package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
- package/themes/original/src/components/GPSButton/index.tsx +15 -8
- package/themes/original/src/components/GoogleMap/index.tsx +11 -11
- package/themes/original/src/components/Help/index.tsx +21 -4
- package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
- package/themes/original/src/components/LastOrders/index.tsx +12 -1
- package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -0
- package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
- package/themes/original/src/components/LoginForm/index.tsx +332 -164
- package/themes/original/src/components/LoginForm/styles.tsx +1 -3
- package/themes/original/src/components/Messages/index.tsx +1 -1
- 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 +243 -0
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
- package/themes/original/src/components/MultiCheckout/index.tsx +304 -0
- package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
- package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
- package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
- package/themes/original/src/components/MyOrders/index.tsx +132 -27
- package/themes/original/src/components/MyOrders/styles.tsx +8 -1
- package/themes/original/src/components/NavBar/index.tsx +4 -4
- package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
- package/themes/original/src/components/OrderDetails/index.tsx +148 -63
- package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
- package/themes/original/src/components/OrderItAgain/index.tsx +72 -0
- package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
- package/themes/original/src/components/OrderSummary/index.tsx +5 -5
- package/themes/original/src/components/OrderTypeSelector/index.tsx +77 -35
- package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
- package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
- package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
- package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
- package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
- package/themes/original/src/components/OrdersOption/index.tsx +139 -46
- package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
- package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +15 -22
- package/themes/original/src/components/PaymentOptions/index.tsx +57 -37
- package/themes/original/src/components/PhoneInputNumber/index.tsx +5 -11
- package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
- package/themes/original/src/components/ProductForm/index.tsx +712 -673
- package/themes/original/src/components/ProductForm/styles.tsx +9 -7
- package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
- package/themes/original/src/components/ProductOption/index.tsx +1 -1
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +13 -9
- package/themes/original/src/components/ProfessionalFilter/index.tsx +128 -0
- package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
- package/themes/original/src/components/ProfessionalProfile/index.tsx +298 -0
- package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
- package/themes/original/src/components/Promotions/index.tsx +145 -128
- package/themes/original/src/components/Promotions/styles.tsx +2 -0
- package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
- package/themes/original/src/components/ReviewOrder/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 +13 -5
- package/themes/original/src/components/ServiceForm/index.tsx +579 -0
- package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
- package/themes/original/src/components/Sessions/index.tsx +160 -0
- package/themes/original/src/components/Sessions/styles.tsx +15 -0
- package/themes/original/src/components/SignupForm/index.tsx +237 -126
- package/themes/original/src/components/SingleOrderCard/index.tsx +316 -0
- package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
- package/themes/original/src/components/SingleProductCard/index.tsx +220 -94
- package/themes/original/src/components/SingleProductCard/styles.tsx +2 -2
- package/themes/original/src/components/StripeElementsForm/index.tsx +25 -9
- package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
- package/themes/original/src/components/UpsellingProducts/index.tsx +2 -6
- package/themes/original/src/components/UserDetails/index.tsx +32 -18
- package/themes/original/src/components/UserFormDetails/index.tsx +108 -74
- package/themes/original/src/components/UserProfile/index.tsx +10 -1
- package/themes/original/src/components/UserProfileForm/index.tsx +14 -9
- package/themes/original/src/components/UserVerification/index.tsx +178 -192
- package/themes/original/src/components/Wallets/index.tsx +2 -2
- package/themes/original/src/components/shared/OBottomPopup.tsx +47 -14
- package/themes/original/src/components/shared/OButton.tsx +2 -0
- package/themes/original/src/components/shared/OInput.tsx +3 -2
- package/themes/original/src/components/shared/OModal.tsx +4 -2
- package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
- package/themes/original/src/types/index.tsx +199 -36
- package/themes/original/src/utils/index.tsx +94 -1
- 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 {
|
|
@@ -39,7 +40,8 @@ const CartUI = (props: any) => {
|
|
|
39
40
|
handleChangeComment,
|
|
40
41
|
commentState,
|
|
41
42
|
onNavigationRedirect,
|
|
42
|
-
handleRemoveOfferClick
|
|
43
|
+
handleRemoveOfferClick,
|
|
44
|
+
isMultiCheckout
|
|
43
45
|
} = props
|
|
44
46
|
|
|
45
47
|
const theme = useTheme();
|
|
@@ -59,10 +61,16 @@ const CartUI = (props: any) => {
|
|
|
59
61
|
|
|
60
62
|
const isCartPending = cart?.status === 2
|
|
61
63
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
|
|
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) || []
|
|
62
66
|
|
|
63
67
|
const business: any = (orderState?.carts && Object.values(orderState.carts).find((_cart: any) => _cart?.uuid === props.cartuuid)) ?? {}
|
|
64
68
|
const businessId = business?.business_id ?? null
|
|
65
|
-
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 || []
|
|
66
74
|
|
|
67
75
|
const momentFormatted = !orderState?.option?.moment
|
|
68
76
|
? t('RIGHT_NOW', 'Right Now')
|
|
@@ -96,17 +104,23 @@ const CartUI = (props: any) => {
|
|
|
96
104
|
const handleUpsellingPage = () => {
|
|
97
105
|
setOpenUpselling(false)
|
|
98
106
|
setCanOpenUpselling(false)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
if (isCheckoutMultiBusinessEnabled && openCarts.length > 1) {
|
|
108
|
+
props.onNavigationRedirect('CheckoutNavigator', {
|
|
109
|
+
screen: 'MultiCheckout'
|
|
110
|
+
})
|
|
111
|
+
} else {
|
|
112
|
+
props.onNavigationRedirect('CheckoutNavigator', {
|
|
113
|
+
screen: 'CheckoutPage',
|
|
114
|
+
cartUuid: cart?.uuid,
|
|
115
|
+
businessLogo: cart?.business?.logo,
|
|
116
|
+
businessName: cart?.business?.name,
|
|
117
|
+
cartTotal: cart?.total
|
|
118
|
+
})
|
|
119
|
+
}
|
|
106
120
|
}
|
|
107
121
|
|
|
108
122
|
const getIncludedTaxes = () => {
|
|
109
|
-
if (cart?.taxes === null) {
|
|
123
|
+
if (cart?.taxes === null || !cart?.taxes) {
|
|
110
124
|
return cart.business.tax_type === 1 ? cart?.tax : 0
|
|
111
125
|
} else {
|
|
112
126
|
return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
|
|
@@ -162,9 +176,10 @@ const CartUI = (props: any) => {
|
|
|
162
176
|
handleClearProducts={handleClearProducts}
|
|
163
177
|
handleCartOpen={handleCartOpen}
|
|
164
178
|
onNavigationRedirect={props.onNavigationRedirect}
|
|
165
|
-
handleChangeStore={
|
|
179
|
+
handleChangeStore={() => setOpenChangeStore(true)}
|
|
166
180
|
handleClickCheckout={() => setOpenUpselling(true)}
|
|
167
181
|
checkoutButtonDisabled={(openUpselling && !canOpenUpselling) || cart?.subtotal < cart?.minimum || !cart?.valid_address}
|
|
182
|
+
isMultiCheckout={isMultiCheckout}
|
|
168
183
|
>
|
|
169
184
|
{cart?.products?.length > 0 && cart?.products.map((product: any, i: number) => (
|
|
170
185
|
<ProductItemAccordion
|
|
@@ -346,13 +361,39 @@ const CartUI = (props: any) => {
|
|
|
346
361
|
</OSTable>
|
|
347
362
|
)}
|
|
348
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
|
+
|
|
349
390
|
<OSTotal>
|
|
350
391
|
<OSTable style={{ marginTop: 15 }}>
|
|
351
392
|
<OText size={14} lineHeight={21} weight={'600'}>
|
|
352
393
|
{t('TOTAL', 'Total')}
|
|
353
394
|
</OText>
|
|
354
395
|
<OText size={14} lineHeight={21} weight={'600'}>
|
|
355
|
-
{parsePrice(cart?.
|
|
396
|
+
{parsePrice(cart?.balance >= 0 ? cart?.balance : 0)}
|
|
356
397
|
</OText>
|
|
357
398
|
</OSTable>
|
|
358
399
|
</OSTotal>
|
|
@@ -409,36 +450,40 @@ const CartUI = (props: any) => {
|
|
|
409
450
|
)}
|
|
410
451
|
</OSBill>
|
|
411
452
|
)}
|
|
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
|
-
|
|
453
|
+
{!isMultiCheckout && (
|
|
454
|
+
<>
|
|
455
|
+
{cart?.valid_products ? (
|
|
456
|
+
<CheckoutAction>
|
|
457
|
+
<OButton
|
|
458
|
+
text={(cart?.subtotal >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
|
|
459
|
+
!openUpselling !== canOpenUpselling ? t('CHECKOUT', 'Checkout') : t('LOADING', 'Loading')
|
|
460
|
+
) : !cart?.valid_address ? (
|
|
461
|
+
`${t('OUT_OF_COVERAGE', 'Out of Coverage')}`
|
|
462
|
+
) : (
|
|
463
|
+
`${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`
|
|
464
|
+
)}
|
|
465
|
+
bgColor={(cart?.subtotal < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
|
|
466
|
+
isDisabled={(openUpselling && !canOpenUpselling) || cart?.subtotal < cart?.minimum || !cart?.valid_address}
|
|
467
|
+
borderColor={theme.colors.primary}
|
|
468
|
+
imgRightSrc={null}
|
|
469
|
+
textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
|
|
470
|
+
onClick={() => setOpenUpselling(true)}
|
|
471
|
+
style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
|
|
472
|
+
/>
|
|
473
|
+
</CheckoutAction>
|
|
474
|
+
) : (
|
|
475
|
+
<View style={{ alignItems: 'center', width: '100%' }}>
|
|
476
|
+
<OText size={12} color={theme.colors.red} style={{ textAlign: 'center', marginTop: 5 }}>
|
|
477
|
+
{t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
|
|
478
|
+
</OText>
|
|
479
|
+
</View>
|
|
480
|
+
)}
|
|
481
|
+
</>
|
|
437
482
|
)}
|
|
438
483
|
</BusinessItemAccordion>
|
|
439
484
|
|
|
440
485
|
<OModal
|
|
441
|
-
open={openChangeStore
|
|
486
|
+
open={openChangeStore}
|
|
442
487
|
entireModal
|
|
443
488
|
customClose
|
|
444
489
|
onClose={() => setOpenChangeStore(false)}
|
|
@@ -105,15 +105,21 @@ const CheckoutUI = (props: any) => {
|
|
|
105
105
|
padding: 20
|
|
106
106
|
},
|
|
107
107
|
pagePadding: {
|
|
108
|
-
|
|
109
|
-
paddingRight: 40
|
|
108
|
+
paddingHorizontal: 40
|
|
110
109
|
},
|
|
111
110
|
icon: {
|
|
112
111
|
top: 15,
|
|
113
112
|
right: Platform.OS === 'ios' ? 5 : (I18nManager.isRTL ? 30 : 0),
|
|
114
113
|
position: 'absolute',
|
|
115
114
|
fontSize: 20
|
|
116
|
-
}
|
|
115
|
+
},
|
|
116
|
+
detailWrapper: {
|
|
117
|
+
paddingHorizontal: 40,
|
|
118
|
+
width: '100%'
|
|
119
|
+
},
|
|
120
|
+
wrapperNavbar: Platform.OS === 'ios'
|
|
121
|
+
? { paddingVertical: 0, paddingHorizontal: 40 }
|
|
122
|
+
: { paddingVertical: 20, paddingHorizontal: 40 }
|
|
117
123
|
})
|
|
118
124
|
|
|
119
125
|
const [, { showToast }] = useToast();
|
|
@@ -133,11 +139,23 @@ const CheckoutUI = (props: any) => {
|
|
|
133
139
|
const [isDeliveryOptionModalVisible, setIsDeliveryOptionModalVisible] = useState(false)
|
|
134
140
|
const [showGateway, setShowGateway] = useState<any>({ closedByUsed: false, open: false });
|
|
135
141
|
const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
142
|
+
const [isOpen, setIsOpen] = useState(false)
|
|
143
|
+
const [requiredFields, setRequiredFields] = useState<any>([])
|
|
144
|
+
|
|
145
|
+
const placeSpotTypes = [4]
|
|
146
|
+
const businessConfigs = businessDetails?.business?.configs ?? []
|
|
147
|
+
const isWalletCashEnabled = businessConfigs.find((config: any) => config.key === 'wallet_cash_enabled')?.value === '1'
|
|
148
|
+
const isWalletCreditPointsEnabled = businessConfigs.find((config: any) => config.key === 'wallet_credit_point_enabled')?.value === '1'
|
|
149
|
+
const isWalletEnabled = configs?.cash_wallet?.value && configs?.wallet_enabled?.value === '1' && (isWalletCashEnabled || isWalletCreditPointsEnabled)
|
|
150
|
+
const isBusinessChangeEnabled = configs?.cart_change_business_validation?.value === '1'
|
|
151
|
+
|
|
139
152
|
const isPreOrder = configs?.preorder_status_enabled?.value === '1'
|
|
140
|
-
const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) || placing || errorCash ||
|
|
153
|
+
const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) || placing || errorCash ||
|
|
154
|
+
cart?.subtotal < cart?.minimum || (placeSpotTypes.includes(options?.type) && !cart?.place) ||
|
|
155
|
+
(options.type === 1 &&
|
|
156
|
+
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
157
|
+
validationFields?.fields?.checkout?.driver_tip?.required &&
|
|
158
|
+
(Number(cart?.driver_tip) <= 0))
|
|
141
159
|
|
|
142
160
|
const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
|
|
143
161
|
? JSON.parse(configs?.driver_tip_options?.value) || []
|
|
@@ -159,9 +177,13 @@ const CheckoutUI = (props: any) => {
|
|
|
159
177
|
}
|
|
160
178
|
}
|
|
161
179
|
|
|
162
|
-
const handlePlaceOrder = () => {
|
|
163
|
-
if (!userErrors.length) {
|
|
164
|
-
handlerClickPlaceOrder && handlerClickPlaceOrder()
|
|
180
|
+
const handlePlaceOrder = (confirmPayment: any) => {
|
|
181
|
+
if (!userErrors.length && !requiredFields?.length) {
|
|
182
|
+
handlerClickPlaceOrder && handlerClickPlaceOrder(null, null, confirmPayment)
|
|
183
|
+
return
|
|
184
|
+
}
|
|
185
|
+
if (requiredFields?.length) {
|
|
186
|
+
setIsOpen(true)
|
|
165
187
|
return
|
|
166
188
|
}
|
|
167
189
|
let stringError = ''
|
|
@@ -191,11 +213,12 @@ const CheckoutUI = (props: any) => {
|
|
|
191
213
|
setUserErrors([])
|
|
192
214
|
const errors = []
|
|
193
215
|
const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes']
|
|
216
|
+
const _requiredFields: any = []
|
|
194
217
|
|
|
195
218
|
Object.values(validationFields?.fields?.checkout).map((field: any) => {
|
|
196
|
-
if (field?.required && !notFields.includes(field.code)) {
|
|
219
|
+
if (field?.required && !notFields.includes(field.code) && field?.enabled) {
|
|
197
220
|
if (!user[field?.code]) {
|
|
198
|
-
|
|
221
|
+
_requiredFields.push(field?.code)
|
|
199
222
|
}
|
|
200
223
|
}
|
|
201
224
|
})
|
|
@@ -206,8 +229,9 @@ const CheckoutUI = (props: any) => {
|
|
|
206
229
|
validationFields?.fields?.checkout?.cellphone?.required) ||
|
|
207
230
|
configs?.verification_phone_required?.value === '1')
|
|
208
231
|
) {
|
|
209
|
-
|
|
232
|
+
_requiredFields.push('cellphone')
|
|
210
233
|
}
|
|
234
|
+
setRequiredFields(_requiredFields)
|
|
211
235
|
|
|
212
236
|
if (phoneUpdate) {
|
|
213
237
|
errors.push(t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number'))
|
|
@@ -239,7 +263,7 @@ const CheckoutUI = (props: any) => {
|
|
|
239
263
|
|
|
240
264
|
useEffect(() => {
|
|
241
265
|
if (cart?.products?.length === 0) {
|
|
242
|
-
|
|
266
|
+
onNavigationRedirect('Business', { store: cart?.business?.slug, header: null, logo: null })
|
|
243
267
|
}
|
|
244
268
|
}, [cart?.products])
|
|
245
269
|
|
|
@@ -250,13 +274,18 @@ const CheckoutUI = (props: any) => {
|
|
|
250
274
|
return (
|
|
251
275
|
<>
|
|
252
276
|
<Container noPadding>
|
|
253
|
-
<
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
277
|
+
<View style={styles.wrapperNavbar}>
|
|
278
|
+
<NavBar
|
|
279
|
+
title={t('CHECKOUT', 'Checkout')}
|
|
280
|
+
titleAlign={'center'}
|
|
281
|
+
onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
|
|
282
|
+
showCall={false}
|
|
283
|
+
btnStyle={{ paddingLeft: 0 }}
|
|
284
|
+
style={{ marginTop: Platform.OS === 'ios' ? 0 : 30 }}
|
|
285
|
+
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
286
|
+
titleStyle={{ marginRight: 0, marginLeft: 0 }}
|
|
287
|
+
/>
|
|
288
|
+
</View>
|
|
260
289
|
<ChContainer style={styles.pagePadding}>
|
|
261
290
|
<ChSection style={{ paddingTop: 0 }}>
|
|
262
291
|
<ChHeader>
|
|
@@ -297,10 +326,10 @@ const CheckoutUI = (props: any) => {
|
|
|
297
326
|
!businessDetails?.error &&
|
|
298
327
|
(
|
|
299
328
|
<Placeholder Animation={Fade}>
|
|
300
|
-
<PlaceholderLine height={20}
|
|
301
|
-
<PlaceholderLine height={
|
|
302
|
-
<PlaceholderLine height={
|
|
303
|
-
<PlaceholderLine height={
|
|
329
|
+
<PlaceholderLine height={20} />
|
|
330
|
+
<PlaceholderLine height={12} />
|
|
331
|
+
<PlaceholderLine height={12} />
|
|
332
|
+
<PlaceholderLine height={12} style={{ marginBottom: 20 }} />
|
|
304
333
|
</Placeholder>
|
|
305
334
|
)}
|
|
306
335
|
{
|
|
@@ -346,10 +375,10 @@ const CheckoutUI = (props: any) => {
|
|
|
346
375
|
<ChUserDetails>
|
|
347
376
|
{cartState.loading ? (
|
|
348
377
|
<Placeholder Animation={Fade}>
|
|
349
|
-
<PlaceholderLine height={20}
|
|
350
|
-
<PlaceholderLine height={
|
|
351
|
-
<PlaceholderLine height={
|
|
352
|
-
<PlaceholderLine height={
|
|
378
|
+
<PlaceholderLine height={20} />
|
|
379
|
+
<PlaceholderLine height={12} />
|
|
380
|
+
<PlaceholderLine height={12} />
|
|
381
|
+
<PlaceholderLine height={12} style={{ marginBottom: 20 }} />
|
|
353
382
|
</Placeholder>
|
|
354
383
|
) : (
|
|
355
384
|
<UserDetails
|
|
@@ -373,8 +402,8 @@ const CheckoutUI = (props: any) => {
|
|
|
373
402
|
{cartState.loading || deliveryOptionSelected === undefined ? (
|
|
374
403
|
<View style={{ height: 110 }}>
|
|
375
404
|
<Placeholder Animation={Fade}>
|
|
376
|
-
<PlaceholderLine height={20}
|
|
377
|
-
<PlaceholderLine height={40}
|
|
405
|
+
<PlaceholderLine height={20} />
|
|
406
|
+
<PlaceholderLine height={40} />
|
|
378
407
|
</Placeholder>
|
|
379
408
|
</View>
|
|
380
409
|
) : (
|
|
@@ -597,7 +626,7 @@ const CheckoutUI = (props: any) => {
|
|
|
597
626
|
</OText>
|
|
598
627
|
</TouchableOpacity>
|
|
599
628
|
</CartHeader>
|
|
600
|
-
{
|
|
629
|
+
{isBusinessChangeEnabled && (
|
|
601
630
|
<TouchableOpacity
|
|
602
631
|
onPress={() => setOpenChangeStore(true)}
|
|
603
632
|
style={{ alignSelf: 'flex-start' }}
|
|
@@ -616,6 +645,7 @@ const CheckoutUI = (props: any) => {
|
|
|
616
645
|
cart={cart}
|
|
617
646
|
isCartPending={cart?.status === 2}
|
|
618
647
|
onNavigationRedirect={onNavigationRedirect}
|
|
648
|
+
placeSpotTypes={placeSpotTypes}
|
|
619
649
|
/>
|
|
620
650
|
</>
|
|
621
651
|
)}
|
|
@@ -625,7 +655,7 @@ const CheckoutUI = (props: any) => {
|
|
|
625
655
|
|
|
626
656
|
{!cartState.loading && cart && (
|
|
627
657
|
<View>
|
|
628
|
-
<ChErrors style={{ marginBottom:
|
|
658
|
+
<ChErrors style={{ marginBottom: 10 }}>
|
|
629
659
|
{!cart?.valid_address && cart?.status !== 2 && (
|
|
630
660
|
<OText
|
|
631
661
|
color={theme.colors.error}
|
|
@@ -660,11 +690,22 @@ const CheckoutUI = (props: any) => {
|
|
|
660
690
|
{t('WARNING_PLACE_SPOT', 'Please, select your spot to place order.')}
|
|
661
691
|
</OText>
|
|
662
692
|
)}
|
|
693
|
+
{options.type === 1 &&
|
|
694
|
+
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
695
|
+
validationFields?.fields?.checkout?.driver_tip?.required &&
|
|
696
|
+
(Number(cart?.driver_tip) <= 0) && (
|
|
697
|
+
<OText
|
|
698
|
+
color={theme.colors.error}
|
|
699
|
+
size={12}
|
|
700
|
+
>
|
|
701
|
+
{t('WARNING_INVALID_DRIVER_TIP', 'Driver Tip is required.')}
|
|
702
|
+
</OText>
|
|
703
|
+
)}
|
|
663
704
|
</ChErrors>
|
|
664
705
|
</View>
|
|
665
706
|
)}
|
|
666
707
|
<OModal
|
|
667
|
-
open={openChangeStore
|
|
708
|
+
open={openChangeStore}
|
|
668
709
|
entireModal
|
|
669
710
|
customClose
|
|
670
711
|
onClose={() => setOpenChangeStore(false)}
|
|
@@ -674,11 +715,33 @@ const CheckoutUI = (props: any) => {
|
|
|
674
715
|
onClose={() => setOpenChangeStore(false)}
|
|
675
716
|
/>
|
|
676
717
|
</OModal>
|
|
718
|
+
<OModal
|
|
719
|
+
open={isOpen}
|
|
720
|
+
onClose={() => setIsOpen(false)}
|
|
721
|
+
>
|
|
722
|
+
<View style={styles.detailWrapper}>
|
|
723
|
+
<UserDetails
|
|
724
|
+
isUserDetailsEdit
|
|
725
|
+
cartStatus={cart?.status}
|
|
726
|
+
businessId={cart?.business_id}
|
|
727
|
+
useValidationFields
|
|
728
|
+
useDefualtSessionManager
|
|
729
|
+
useSessionUser
|
|
730
|
+
isCheckout
|
|
731
|
+
isEdit
|
|
732
|
+
phoneUpdate={phoneUpdate}
|
|
733
|
+
togglePhoneUpdate={togglePhoneUpdate}
|
|
734
|
+
requiredFields={requiredFields}
|
|
735
|
+
hideUpdateButton
|
|
736
|
+
onClose={() => setIsOpen(false)}
|
|
737
|
+
/>
|
|
738
|
+
</View>
|
|
739
|
+
</OModal>
|
|
677
740
|
</ChContainer>
|
|
678
741
|
</Container>
|
|
679
742
|
{!cartState.loading && cart && cart?.status !== 2 && (
|
|
680
743
|
<FloatingButton
|
|
681
|
-
handleClick={() => handlePlaceOrder()}
|
|
744
|
+
handleClick={() => handlePlaceOrder(null)}
|
|
682
745
|
isSecondaryBtn={isDisabledButtonPlace}
|
|
683
746
|
disabled={isDisabledButtonPlace}
|
|
684
747
|
btnText={cart?.subtotal >= cart?.minimum
|
|
@@ -692,7 +755,7 @@ const CheckoutUI = (props: any) => {
|
|
|
692
755
|
: (`${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`)
|
|
693
756
|
}
|
|
694
757
|
btnRightValueShow
|
|
695
|
-
btnRightValue={parsePrice(cart?.
|
|
758
|
+
btnRightValue={parsePrice(cart?.balance)}
|
|
696
759
|
iosBottom={30}
|
|
697
760
|
/>
|
|
698
761
|
)}
|
|
@@ -708,19 +771,6 @@ const CheckoutUI = (props: any) => {
|
|
|
708
771
|
setShowGateway={setShowGateway}
|
|
709
772
|
/>
|
|
710
773
|
)}
|
|
711
|
-
{webviewPaymethod?.gateway === 'square' && showGateway.open && (
|
|
712
|
-
<PaymentOptionsWebView
|
|
713
|
-
onNavigationRedirect={onNavigationRedirect}
|
|
714
|
-
uri={`https://test-square-f50f7.web.app`}
|
|
715
|
-
user={user}
|
|
716
|
-
token={token}
|
|
717
|
-
cart={cart}
|
|
718
|
-
currency={currency}
|
|
719
|
-
webviewPaymethod={webviewPaymethod}
|
|
720
|
-
setShowGateway={setShowGateway}
|
|
721
|
-
locationId={'L1NGAY5M6KJRX'}
|
|
722
|
-
/>
|
|
723
|
-
)}
|
|
724
774
|
</>
|
|
725
775
|
)
|
|
726
776
|
}
|
|
@@ -873,7 +923,7 @@ export const Checkout = (props: any) => {
|
|
|
873
923
|
...props,
|
|
874
924
|
UIComponent: CheckoutUI,
|
|
875
925
|
cartState,
|
|
876
|
-
|
|
926
|
+
uuid: cartUuid
|
|
877
927
|
}
|
|
878
928
|
|
|
879
929
|
return (
|
|
@@ -48,22 +48,28 @@ const DriverTipsUI = (props: any) => {
|
|
|
48
48
|
}
|
|
49
49
|
})
|
|
50
50
|
|
|
51
|
-
const [value, setvalue] = useState(
|
|
51
|
+
const [value, setvalue] = useState('');
|
|
52
52
|
|
|
53
53
|
const placeholderCurrency = (configs?.currency_position?.value || 'left') === 'left'
|
|
54
54
|
? `${configs?.format_number_currency?.value}0`
|
|
55
55
|
: `0${configs?.format_number_currency?.value}`
|
|
56
56
|
|
|
57
57
|
const handleChangeDriverTip = (val: any) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
const tip = Number(val)
|
|
59
|
+
if ((isNaN(tip) || tip < 0)) {
|
|
60
|
+
setvalue(value)
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
setvalue(val)
|
|
61
64
|
}
|
|
62
|
-
|
|
65
|
+
|
|
63
66
|
return (
|
|
64
67
|
<DTContainer>
|
|
68
|
+
<DTLabel>
|
|
69
|
+
{t('CUSTOM_DRIVER_TIP_MESSAGE', '100% of these tips go directly to your driver')}
|
|
70
|
+
</DTLabel>
|
|
65
71
|
<DTWrapperTips>
|
|
66
|
-
{driverTipsOptions.map((option: any, i: number) => (
|
|
72
|
+
{!isDriverTipUseCustom && driverTipsOptions.map((option: any, i: number) => (
|
|
67
73
|
<TouchableOpacity
|
|
68
74
|
key={i}
|
|
69
75
|
onPress={() => handlerChangeOption(option)}
|
|
@@ -79,7 +85,7 @@ const DriverTipsUI = (props: any) => {
|
|
|
79
85
|
</TouchableOpacity>
|
|
80
86
|
))}
|
|
81
87
|
</DTWrapperTips>
|
|
82
|
-
{!driverTipsOptions.includes(driverTip) && driverTip > 0 && (
|
|
88
|
+
{(!isDriverTipUseCustom && !driverTipsOptions.includes(driverTip) && driverTip > 0) && (
|
|
83
89
|
<OText
|
|
84
90
|
color={theme.colors.error}
|
|
85
91
|
size={16}
|
|
@@ -90,13 +96,12 @@ const DriverTipsUI = (props: any) => {
|
|
|
90
96
|
)}
|
|
91
97
|
{isDriverTipUseCustom && (
|
|
92
98
|
<DTForm>
|
|
93
|
-
<DTLabel>
|
|
94
|
-
{t('CUSTOM_DRIVER_TIP_MESSAGE', '100% of these tips go directly to your driver')}
|
|
95
|
-
</DTLabel>
|
|
96
99
|
<DTWrapperInput>
|
|
97
100
|
<OInput
|
|
98
101
|
placeholder={placeholderCurrency}
|
|
99
102
|
style={style.inputStyle}
|
|
103
|
+
value={value}
|
|
104
|
+
type={'numeric'}
|
|
100
105
|
onChange={handleChangeDriverTip}
|
|
101
106
|
autoCapitalize='none'
|
|
102
107
|
autoCorrect={false}
|
|
@@ -108,10 +113,10 @@ const DriverTipsUI = (props: any) => {
|
|
|
108
113
|
textStyle={{ color: 'white', fontSize: 14 }}
|
|
109
114
|
imgRightSrc={null}
|
|
110
115
|
style={{ borderRadius: 5, height: 44 }}
|
|
111
|
-
isDisabled={
|
|
116
|
+
isDisabled={parseFloat(value || '0') < 0 || parseFloat(value || '0') === driverTip || value === ''}
|
|
112
117
|
onClick={() => {
|
|
113
118
|
handlerChangeOption(value)
|
|
114
|
-
setvalue(
|
|
119
|
+
setvalue('')
|
|
115
120
|
}}
|
|
116
121
|
/>
|
|
117
122
|
</DTWrapperInput>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { useLanguage, useOrder } from 'ordering-components/native'
|
|
3
|
+
import { useTheme } from 'styled-components/native'
|
|
4
|
+
import { FavoriteList } from '../FavoriteList'
|
|
5
|
+
import NavBar from '../NavBar'
|
|
6
|
+
import { OText } from '../shared'
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
TabContainer,
|
|
10
|
+
Tab,
|
|
11
|
+
Container
|
|
12
|
+
} from './styles'
|
|
13
|
+
|
|
14
|
+
export const Favorite = (props: any) => {
|
|
15
|
+
const {
|
|
16
|
+
navigation
|
|
17
|
+
} = props
|
|
18
|
+
const [, t] = useLanguage()
|
|
19
|
+
const theme = useTheme()
|
|
20
|
+
const [orderState] = useOrder()
|
|
21
|
+
const [tabSelected, setTabSelected] = useState('businesses')
|
|
22
|
+
|
|
23
|
+
const tabList = [
|
|
24
|
+
{ key: 'businesses', name: t('BUSINESSES', 'Businesses') },
|
|
25
|
+
{ key: 'products', name: t('PRODUCTS', 'Products') },
|
|
26
|
+
{ key: 'orders', name: t('ORDERS', 'Orders') }
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
const goToBack = () => navigation?.canGoBack() && navigation.goBack()
|
|
30
|
+
|
|
31
|
+
const onRedirect = (route: string, params?: any) => {
|
|
32
|
+
navigation.navigate(route, params)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Container>
|
|
37
|
+
<NavBar
|
|
38
|
+
title={t('FAVORITE', 'Favorite')}
|
|
39
|
+
titleAlign={'center'}
|
|
40
|
+
onActionLeft={goToBack}
|
|
41
|
+
showCall={false}
|
|
42
|
+
paddingTop={10}
|
|
43
|
+
btnStyle={{ paddingLeft: 0 }}
|
|
44
|
+
/>
|
|
45
|
+
<TabContainer>
|
|
46
|
+
{tabList.map((menu, i) => (
|
|
47
|
+
<Tab
|
|
48
|
+
key={i}
|
|
49
|
+
active={menu.key === tabSelected}
|
|
50
|
+
onPress={() => setTabSelected(menu.key)}
|
|
51
|
+
>
|
|
52
|
+
<OText
|
|
53
|
+
color={menu.key === tabSelected ? theme.colors.textNormal : theme.colors.disabled}
|
|
54
|
+
size={14}
|
|
55
|
+
weight={menu.key === tabSelected ? '500' : '400'}
|
|
56
|
+
style={{ marginBottom: 12 }}
|
|
57
|
+
>
|
|
58
|
+
{menu.name}
|
|
59
|
+
</OText>
|
|
60
|
+
</Tab>
|
|
61
|
+
))}
|
|
62
|
+
</TabContainer>
|
|
63
|
+
{tabSelected === 'businesses' && (
|
|
64
|
+
<FavoriteList
|
|
65
|
+
navigation={navigation}
|
|
66
|
+
onNavigationRedirect={onRedirect}
|
|
67
|
+
isBusiness
|
|
68
|
+
favoriteURL='favorite_businesses'
|
|
69
|
+
originalURL='business'
|
|
70
|
+
location={`${orderState.options?.address?.location?.lat},${orderState.options?.address?.location?.lng}`}
|
|
71
|
+
propsToFetch={['id', 'name', 'header', 'logo', 'location', 'address', 'ribbon', 'timezone', 'schedule', 'open', 'delivery_price', 'distance', 'delivery_time', 'pickup_time', 'reviews', 'featured', 'offers', 'food', 'laundry', 'alcohol', 'groceries', 'slug']}
|
|
72
|
+
/>
|
|
73
|
+
)}
|
|
74
|
+
{tabSelected === 'products' && (
|
|
75
|
+
<FavoriteList
|
|
76
|
+
favoriteURL='favorite_products'
|
|
77
|
+
originalURL='products'
|
|
78
|
+
onNavigationRedirect={onRedirect}
|
|
79
|
+
isProduct
|
|
80
|
+
/>
|
|
81
|
+
)}
|
|
82
|
+
{tabSelected === 'orders' && (
|
|
83
|
+
<FavoriteList
|
|
84
|
+
onNavigationRedirect={onRedirect}
|
|
85
|
+
favoriteURL='favorite_orders'
|
|
86
|
+
originalURL='orders'
|
|
87
|
+
isOrder
|
|
88
|
+
/>
|
|
89
|
+
)}
|
|
90
|
+
</Container>
|
|
91
|
+
)
|
|
92
|
+
}
|