ordering-ui-react-native 0.17.90 → 0.17.91-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 +8 -7
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/BusinessInformation/index.tsx +10 -9
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/OrderCreating/index.tsx +1 -21
- package/src/components/PaymentOptionsWebView/index.tsx +29 -8
- package/src/components/PhoneInputNumber/index.tsx +6 -2
- package/src/components/StripeMethodForm/index.tsx +136 -102
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/components/shared/OToast.tsx +3 -2
- package/src/types/index.tsx +5 -0
- package/src/utils/index.tsx +5 -0
- package/themes/business/index.tsx +2 -0
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +37 -27
- package/themes/business/src/components/BusinessController/index.tsx +0 -1
- package/themes/business/src/components/Chat/index.tsx +163 -123
- package/themes/business/src/components/DriverMap/index.tsx +17 -6
- package/themes/business/src/components/DriverSchedule/index.tsx +45 -8
- package/themes/business/src/components/FloatingButton/index.tsx +34 -31
- package/themes/business/src/components/GoogleMap/index.tsx +58 -57
- package/themes/business/src/components/LoginForm/Otp/index.tsx +31 -3
- package/themes/business/src/components/LoginForm/index.tsx +15 -22
- package/themes/business/src/components/MapView/index.tsx +14 -10
- package/themes/business/src/components/MessagesOption/index.tsx +20 -93
- package/themes/business/src/components/NewOrderNotification/index.tsx +123 -96
- package/themes/business/src/components/NotFoundSource/index.tsx +2 -2
- package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +202 -12
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +84 -37
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +81 -66
- package/themes/business/src/components/OrderDetailsLogistic/index.tsx +200 -0
- package/themes/business/src/components/OrderDetailsLogistic/styles.tsx +5 -0
- package/themes/business/src/components/OrderMessage/index.tsx +19 -18
- package/themes/business/src/components/OrderSummary/index.tsx +114 -123
- package/themes/business/src/components/OrdersOption/index.tsx +22 -22
- package/themes/business/src/components/PreviousMessages/FooterMessageComponent.tsx +103 -0
- package/themes/business/src/components/PreviousMessages/index.tsx +97 -55
- package/themes/business/src/components/PreviousOrders/OrderItem.tsx +17 -12
- package/themes/business/src/components/PreviousOrders/OrderList.tsx +93 -0
- package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +1 -1
- package/themes/business/src/components/PreviousOrders/index.tsx +198 -221
- package/themes/business/src/components/ProductItemAccordion/index.tsx +7 -1
- package/themes/business/src/components/ReviewCustomer/index.tsx +18 -13
- package/themes/business/src/components/StoresList/index.tsx +3 -4
- package/themes/business/src/components/UserProfileForm/index.tsx +14 -15
- package/themes/business/src/components/shared/OModal.tsx +16 -9
- package/themes/business/src/types/index.tsx +25 -10
- package/themes/business/src/utils/index.tsx +29 -2
- 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/Intro/index.tsx +16 -1
- package/themes/kiosk/src/components/LoginForm/index.tsx +7 -9
- 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/PhoneInputNumber/index.tsx +2 -2
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/original/index.tsx +1 -1
- package/themes/original/src/components/AddressDetails/index.tsx +19 -3
- package/themes/original/src/components/AddressForm/index.tsx +35 -17
- package/themes/original/src/components/AddressList/index.tsx +5 -8
- package/themes/original/src/components/AnalyticsSegment/index.tsx +193 -10
- package/themes/original/src/components/AppleLogin/index.tsx +4 -4
- package/themes/original/src/components/AppleLogin/styles.tsx +3 -1
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +73 -37
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +10 -12
- package/themes/original/src/components/BusinessController/index.tsx +35 -44
- package/themes/original/src/components/BusinessController/styles.tsx +12 -5
- package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
- package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
- package/themes/original/src/components/BusinessInformation/index.tsx +140 -85
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +15 -20
- package/themes/original/src/components/BusinessListingSearch/index.tsx +347 -341
- package/themes/original/src/components/BusinessListingSearch/styles.tsx +0 -18
- package/themes/original/src/components/BusinessPreorder/index.tsx +103 -19
- package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -2
- package/themes/original/src/components/BusinessProductsList/index.tsx +15 -7
- package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
- package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +1 -1
- package/themes/original/src/components/BusinessProductsListing/index.tsx +664 -556
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -3
- package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
- package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +69 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +406 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListing.tsx +76 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +38 -405
- package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
- package/themes/original/src/components/Cart/index.tsx +57 -49
- package/themes/original/src/components/CartContent/index.tsx +102 -58
- package/themes/original/src/components/CartContent/styles.tsx +6 -6
- package/themes/original/src/components/Checkout/index.tsx +277 -33
- package/themes/original/src/components/CitiesControl/index.tsx +1 -1
- package/themes/original/src/components/CouponControl/index.tsx +10 -3
- package/themes/original/src/components/DriverTips/index.tsx +14 -6
- package/themes/original/src/components/FacebookLogin/styles.tsx +3 -1
- package/themes/original/src/components/Favorite/index.tsx +1 -5
- package/themes/original/src/components/GPSButton/index.tsx +6 -4
- package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +8 -3
- package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +42 -5
- package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +2 -0
- package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +86 -10
- package/themes/original/src/components/GoogleLogin/styles.tsx +1 -1
- package/themes/original/src/components/GoogleMap/index.tsx +63 -7
- package/themes/original/src/components/Home/index.tsx +13 -4
- package/themes/original/src/components/LastOrder/index.tsx +2 -1
- package/themes/original/src/components/LastOrders/index.tsx +2 -1
- package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -25
- package/themes/original/src/components/LoginForm/index.tsx +64 -34
- package/themes/original/src/components/LottieAnimation/index.tsx +88 -63
- package/themes/original/src/components/MessageListing/index.tsx +9 -2
- package/themes/original/src/components/Messages/index.tsx +15 -4
- package/themes/original/src/components/MomentOption/index.tsx +193 -92
- package/themes/original/src/components/MomentSelector/index.tsx +1 -1
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +162 -50
- package/themes/original/src/components/MultiCheckout/index.tsx +385 -46
- package/themes/original/src/components/MultiCheckout/styles.tsx +3 -1
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +23 -19
- package/themes/original/src/components/MyOrders/index.tsx +15 -4
- package/themes/original/src/components/NavBar/index.tsx +20 -13
- package/themes/original/src/components/NotFoundSource/index.tsx +14 -10
- package/themes/original/src/components/OrderDetails/OrderEta.tsx +76 -0
- package/themes/original/src/components/OrderDetails/OrderHistory.tsx +21 -5
- package/themes/original/src/components/OrderDetails/index.tsx +50 -38
- package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
- package/themes/original/src/components/OrderItAgain/index.tsx +3 -1
- package/themes/original/src/components/OrderProgress/index.tsx +34 -25
- package/themes/original/src/components/OrderSummary/index.tsx +83 -57
- package/themes/original/src/components/OrderTypeSelector/index.tsx +5 -6
- package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +13 -13
- package/themes/original/src/components/OrdersOption/index.tsx +43 -20
- package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
- package/themes/original/src/components/PageBanner/index.tsx +65 -29
- package/themes/original/src/components/PageBanner/styles.tsx +0 -3
- package/themes/original/src/components/PaymentOptionCard/index.tsx +180 -0
- package/themes/original/src/components/PaymentOptionStripe/styles.tsx +3 -0
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
- package/themes/original/src/components/PaymentOptions/index.tsx +100 -34
- package/themes/original/src/components/PhoneInputNumber/index.tsx +18 -4
- package/themes/original/src/components/ProductForm/index.tsx +87 -31
- package/themes/original/src/components/ProductForm/styles.tsx +3 -3
- package/themes/original/src/components/ProductItemAccordion/index.tsx +8 -6
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +49 -20
- package/themes/original/src/components/ProductOptionSubOption/styles.tsx +10 -9
- package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
- package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -50
- package/themes/original/src/components/ProfessionalProfile/index.tsx +36 -7
- package/themes/original/src/components/Promotions/index.tsx +2 -2
- package/themes/original/src/components/Promotions/styles.tsx +3 -1
- package/themes/original/src/components/ReviewProducts/index.tsx +16 -7
- package/themes/original/src/components/ScheduleAccordion/index.tsx +3 -3
- package/themes/original/src/components/ServiceForm/index.tsx +63 -20
- package/themes/original/src/components/SignupForm/index.tsx +43 -27
- package/themes/original/src/components/SingleOrderCard/index.tsx +42 -19
- package/themes/original/src/components/SingleOrderCard/styles.tsx +1 -1
- package/themes/original/src/components/SingleProductCard/index.tsx +14 -11
- package/themes/original/src/components/SingleProductCard/styles.tsx +8 -3
- package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
- package/themes/original/src/components/StripeCardsList/index.tsx +61 -5
- package/themes/original/src/components/StripeElementsForm/index.tsx +48 -34
- package/themes/original/src/components/StripeElementsForm/naked.tsx +12 -1
- package/themes/original/src/components/UpsellingProducts/index.tsx +5 -10
- package/themes/original/src/components/UserDetails/index.tsx +3 -1
- package/themes/original/src/components/UserFormDetails/index.tsx +78 -9
- package/themes/original/src/components/UserFormDetails/styles.tsx +1 -1
- package/themes/original/src/components/UserProfile/index.tsx +8 -26
- package/themes/original/src/components/UserProfileForm/index.tsx +30 -31
- package/themes/original/src/components/UserVerification/index.tsx +55 -50
- package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
- package/themes/original/src/components/WalletTransactions/index.tsx +3 -3
- package/themes/original/src/components/Wallets/index.tsx +52 -62
- package/themes/original/src/components/Wallets/styles.tsx +2 -4
- package/themes/original/src/components/shared/OButton.tsx +3 -3
- package/themes/original/src/components/shared/OInput.tsx +4 -5
- package/themes/original/src/components/shared/OModal.tsx +3 -3
- package/themes/original/src/types/index.tsx +37 -10
- package/themes/original/src/utils/index.tsx +185 -13
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
- package/src/navigators/BottomNavigator.tsx +0 -117
- package/src/navigators/CheckoutNavigator.tsx +0 -66
- package/src/navigators/HomeNavigator.tsx +0 -202
- package/src/navigators/NavigationRef.tsx +0 -7
- package/src/navigators/RootNavigator.tsx +0 -269
- package/src/pages/Account.tsx +0 -34
- package/src/pages/AddressForm.tsx +0 -62
- package/src/pages/AddressList.tsx +0 -24
- package/src/pages/BusinessProductsList.tsx +0 -81
- package/src/pages/BusinessesListing.tsx +0 -43
- package/src/pages/CartList.tsx +0 -49
- package/src/pages/Checkout.tsx +0 -101
- package/src/pages/ForgotPassword.tsx +0 -24
- package/src/pages/Help.tsx +0 -23
- package/src/pages/HelpAccountAndPayment.tsx +0 -23
- package/src/pages/HelpGuide.tsx +0 -23
- package/src/pages/HelpOrder.tsx +0 -23
- package/src/pages/Home.tsx +0 -36
- package/src/pages/IntroductoryTutorial.tsx +0 -170
- package/src/pages/Login.tsx +0 -47
- package/src/pages/MomentOption.tsx +0 -30
- package/src/pages/MultiCheckout.tsx +0 -31
- package/src/pages/MultiOrdersDetails.tsx +0 -27
- package/src/pages/MyOrders.tsx +0 -40
- package/src/pages/NetworkError.tsx +0 -24
- package/src/pages/NotFound.tsx +0 -22
- package/src/pages/OrderDetails.tsx +0 -25
- package/src/pages/ProductDetails.tsx +0 -55
- package/src/pages/Profile.tsx +0 -36
- package/src/pages/ReviewDriver.tsx +0 -30
- package/src/pages/ReviewOrder.tsx +0 -32
- package/src/pages/ReviewProducts.tsx +0 -30
- package/src/pages/Sessions.tsx +0 -22
- package/src/pages/Signup.tsx +0 -53
- package/src/pages/SpinnerLoader.tsx +0 -10
- package/src/pages/Splash.tsx +0 -21
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { useRef } from 'react'
|
|
2
|
-
import { useUtils, PageBanner as PageBannerController } from 'ordering-components/native'
|
|
1
|
+
import React, { useEffect, useState, useRef } from 'react'
|
|
2
|
+
import { useUtils, useEvent, PageBanner as PageBannerController } from 'ordering-components/native'
|
|
3
3
|
import { View, StyleSheet, Dimensions, TouchableOpacity } from 'react-native'
|
|
4
4
|
import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
|
|
5
5
|
import Carousel from 'react-native-snap-carousel'
|
|
@@ -16,7 +16,10 @@ const PageBannerUI = (props: any) => {
|
|
|
16
16
|
|
|
17
17
|
const theme = useTheme();
|
|
18
18
|
const [{ optimizeImage }] = useUtils();
|
|
19
|
-
const
|
|
19
|
+
const [events] = useEvent()
|
|
20
|
+
const carouselRef = useRef<any>(null)
|
|
21
|
+
const [currentIndex, setCurrentIndex] = useState(0)
|
|
22
|
+
const [viewedBanner, setViewedBanner] = useState<any>(null)
|
|
20
23
|
|
|
21
24
|
const windowWidth = Dimensions.get('window').width;
|
|
22
25
|
|
|
@@ -41,10 +44,11 @@ const PageBannerUI = (props: any) => {
|
|
|
41
44
|
})
|
|
42
45
|
|
|
43
46
|
const onRedirect = (route: string, params?: any) => {
|
|
44
|
-
navigation.
|
|
47
|
+
navigation.push(route, params)
|
|
45
48
|
}
|
|
46
49
|
|
|
47
|
-
const handleGoToPage = (
|
|
50
|
+
const handleGoToPage = (item: any) => {
|
|
51
|
+
const action = item.action
|
|
48
52
|
if (!action?.url) return
|
|
49
53
|
let slug
|
|
50
54
|
if (action.type === 'business') {
|
|
@@ -59,15 +63,22 @@ const PageBannerUI = (props: any) => {
|
|
|
59
63
|
businessSlug: slug,
|
|
60
64
|
businessId: action.business_id,
|
|
61
65
|
categoryId: action.category_id,
|
|
62
|
-
productId: action.product_id
|
|
66
|
+
productId: action.product_id,
|
|
67
|
+
isRedirect: 'business',
|
|
68
|
+
business: {
|
|
69
|
+
store: slug
|
|
70
|
+
}
|
|
63
71
|
})
|
|
64
72
|
}
|
|
73
|
+
const clickedBanner = pageBannerState.result.find(banner => banner.id === item?.banner_id)
|
|
74
|
+
events.emit('promotion_clicked', clickedBanner)
|
|
65
75
|
}
|
|
66
76
|
|
|
67
77
|
const renderItem = ({ item, index }) => {
|
|
68
78
|
return (
|
|
69
79
|
<TouchableOpacity
|
|
70
|
-
|
|
80
|
+
activeOpacity={1}
|
|
81
|
+
onPress={() => handleGoToPage(item)}
|
|
71
82
|
>
|
|
72
83
|
<View style={styles.sliderWrapper}>
|
|
73
84
|
<FastImage
|
|
@@ -80,6 +91,24 @@ const PageBannerUI = (props: any) => {
|
|
|
80
91
|
)
|
|
81
92
|
}
|
|
82
93
|
|
|
94
|
+
const updateIndex = () => {
|
|
95
|
+
setCurrentIndex(carouselRef?.current?.currentIndex)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (pageBannerState.loading) return
|
|
100
|
+
if (pageBannerState.banner?.items && pageBannerState.banner?.items.length > 0) {
|
|
101
|
+
const bannerId = pageBannerState.banner.items[currentIndex]?.banner_id
|
|
102
|
+
if (pageBannerState.result && bannerId) {
|
|
103
|
+
const _viewedBanner = pageBannerState.result.find(banner => banner.id === bannerId)
|
|
104
|
+
if (_viewedBanner?.id !== viewedBanner?.id) {
|
|
105
|
+
setViewedBanner(_viewedBanner)
|
|
106
|
+
events.emit('promotion_viewed', _viewedBanner)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, [pageBannerState.loading, currentIndex, viewedBanner])
|
|
111
|
+
|
|
83
112
|
return (
|
|
84
113
|
<>
|
|
85
114
|
{pageBannerState.loading ? (
|
|
@@ -97,37 +126,44 @@ const PageBannerUI = (props: any) => {
|
|
|
97
126
|
<>
|
|
98
127
|
{pageBannerState.banner?.items && pageBannerState.banner?.items.length > 0 && (
|
|
99
128
|
<PageBannerWrapper>
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
129
|
+
{pageBannerState.banner?.items.length > 1 && (
|
|
130
|
+
<>
|
|
131
|
+
<TouchableOpacity
|
|
132
|
+
activeOpacity={1}
|
|
133
|
+
style={[styles.swiperButton, { left: 25 }]}
|
|
134
|
+
onPress={() => carouselRef.current.snapToPrev()}
|
|
135
|
+
>
|
|
136
|
+
<IconAntDesign
|
|
137
|
+
name="caretleft"
|
|
138
|
+
color={theme.colors.white}
|
|
139
|
+
size={13}
|
|
140
|
+
/>
|
|
141
|
+
</TouchableOpacity>
|
|
142
|
+
<TouchableOpacity
|
|
143
|
+
activeOpacity={1}
|
|
144
|
+
style={[styles.swiperButton, { right: 25 }]}
|
|
145
|
+
onPress={() => carouselRef.current.snapToNext()}
|
|
146
|
+
>
|
|
147
|
+
<IconAntDesign
|
|
148
|
+
name="caretright"
|
|
149
|
+
color={theme.colors.white}
|
|
150
|
+
size={13}
|
|
151
|
+
/>
|
|
152
|
+
</TouchableOpacity>
|
|
153
|
+
</>
|
|
154
|
+
)}
|
|
120
155
|
<Carousel
|
|
121
156
|
ref={carouselRef}
|
|
122
157
|
loop={pageBannerState.banner?.items.length > 1}
|
|
123
158
|
data={pageBannerState.banner?.items}
|
|
124
159
|
renderItem={renderItem}
|
|
125
|
-
sliderWidth={windowWidth
|
|
126
|
-
itemWidth={windowWidth
|
|
160
|
+
sliderWidth={windowWidth}
|
|
161
|
+
itemWidth={windowWidth}
|
|
127
162
|
inactiveSlideScale={1}
|
|
128
163
|
pagingEnabled
|
|
129
164
|
removeClippedSubviews={false}
|
|
130
165
|
inactiveSlideOpacity={1}
|
|
166
|
+
onSnapToItem={updateIndex}
|
|
131
167
|
/>
|
|
132
168
|
</PageBannerWrapper>
|
|
133
169
|
)}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react'
|
|
2
|
+
import { View, Modal, TouchableOpacity, StyleSheet, SafeAreaView, KeyboardAvoidingView, Platform, ScrollView } from 'react-native'
|
|
3
|
+
import { OButton, OIcon, OInput, OModal, OText } from '../shared'
|
|
4
|
+
import { PaymentOptionStripe, useLanguage, useSession } from 'ordering-components/native'
|
|
5
|
+
import { StripeCardsListUI } from '../StripeCardsList'
|
|
6
|
+
import { useTheme } from 'styled-components/native';
|
|
7
|
+
import { CreditCardInput } from "react-native-credit-card-input-plus";
|
|
8
|
+
import Alert from '../../providers/AlertProvider'
|
|
9
|
+
|
|
10
|
+
const PaymentOptionCardUI = (props: any) => {
|
|
11
|
+
const {
|
|
12
|
+
cardSelected,
|
|
13
|
+
deleteCard,
|
|
14
|
+
onSelectCard,
|
|
15
|
+
handleCardClick,
|
|
16
|
+
cardsList,
|
|
17
|
+
addCardOpen,
|
|
18
|
+
setAddCardOpen,
|
|
19
|
+
gateway,
|
|
20
|
+
handleNewCard,
|
|
21
|
+
paymethodsWithoutSaveCards
|
|
22
|
+
} = props
|
|
23
|
+
const [, t] = useLanguage()
|
|
24
|
+
const theme = useTheme()
|
|
25
|
+
const [{ token }] = useSession()
|
|
26
|
+
const [alertState, setAlertState] = useState<{ open: boolean, content: Array<string> }>({ open: false, content: [] })
|
|
27
|
+
const [newCard, setNewCard] = useState<any>(null)
|
|
28
|
+
|
|
29
|
+
const onChangeCardForm = (values : any) => {
|
|
30
|
+
if (values?.valid) {
|
|
31
|
+
const expiry = values?.values?.expiry?.split('/')
|
|
32
|
+
const expiryMonth = expiry[0]
|
|
33
|
+
const expiryYear = expiry[1]
|
|
34
|
+
const expiryString = expiryMonth + expiryYear
|
|
35
|
+
let lastFourDigits = values?.values?.number?.substr(-4);
|
|
36
|
+
setNewCard({
|
|
37
|
+
name: values?.values.name,
|
|
38
|
+
number: values?.values.number.replace(/\s/g, ''),
|
|
39
|
+
cvc: values?.values.cvc,
|
|
40
|
+
expiryMonth: expiryMonth,
|
|
41
|
+
expiryYear: expiryYear,
|
|
42
|
+
expiry: expiry,
|
|
43
|
+
brand: values?.values?.type,
|
|
44
|
+
last4: lastFourDigits,
|
|
45
|
+
expiryString: expiryString
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const handleAddNewCard = () => {
|
|
51
|
+
handleNewCard(newCard)
|
|
52
|
+
setAddCardOpen({ ...addCardOpen, card: false })
|
|
53
|
+
setNewCard(null)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (cardsList.error && !cardsList.loading) {
|
|
58
|
+
setAlertState({
|
|
59
|
+
open: true,
|
|
60
|
+
content: cardsList.error
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
}, [JSON.stringify(cardsList)])
|
|
64
|
+
|
|
65
|
+
const style = StyleSheet.create({
|
|
66
|
+
wrapperIcon: {
|
|
67
|
+
marginLeft: 25,
|
|
68
|
+
marginTop: Platform.OS === 'ios' ? 40 : 12,
|
|
69
|
+
marginBottom: 20,
|
|
70
|
+
alignItems: 'center',
|
|
71
|
+
justifyContent: 'center',
|
|
72
|
+
},
|
|
73
|
+
buttonStyle: {
|
|
74
|
+
marginVertical: 20,
|
|
75
|
+
borderRadius: 7.6,
|
|
76
|
+
shadowOpacity: 0,
|
|
77
|
+
height: 44,
|
|
78
|
+
borderWidth: 1
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<View>
|
|
84
|
+
<>
|
|
85
|
+
{token && (!cardSelected || !paymethodsWithoutSaveCards.includes(gateway)) && (
|
|
86
|
+
<OButton
|
|
87
|
+
text={t('ADD_PAYMENT_CARD', 'Add New Payment Card')}
|
|
88
|
+
bgColor={theme.colors.white}
|
|
89
|
+
borderColor={theme.colors.primary}
|
|
90
|
+
style={{
|
|
91
|
+
marginVertical: 20,
|
|
92
|
+
borderRadius: 7.6,
|
|
93
|
+
shadowOpacity: 0,
|
|
94
|
+
height: 44,
|
|
95
|
+
borderWidth: 1
|
|
96
|
+
}}
|
|
97
|
+
textStyle={{ color: theme.colors.primary, fontSize: 12 }}
|
|
98
|
+
imgRightSrc={null}
|
|
99
|
+
onClick={() => setAddCardOpen({ ...addCardOpen, card: true })}
|
|
100
|
+
/>
|
|
101
|
+
)}
|
|
102
|
+
<StripeCardsListUI
|
|
103
|
+
cardSelected={cardSelected}
|
|
104
|
+
deleteCard={deleteCard}
|
|
105
|
+
onSelectCard={onSelectCard}
|
|
106
|
+
handleCardClick={handleCardClick}
|
|
107
|
+
cardsList={cardsList}
|
|
108
|
+
noShowErrors
|
|
109
|
+
gateway={gateway}
|
|
110
|
+
/>
|
|
111
|
+
</>
|
|
112
|
+
<Modal
|
|
113
|
+
animationType="slide"
|
|
114
|
+
visible={addCardOpen?.card}
|
|
115
|
+
onDismiss={() => setAddCardOpen({ ...addCardOpen, card: false })}
|
|
116
|
+
>
|
|
117
|
+
<KeyboardAvoidingView
|
|
118
|
+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
119
|
+
style={{
|
|
120
|
+
flex: 1,
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
<ScrollView>
|
|
124
|
+
<TouchableOpacity onPress={() => setAddCardOpen({ ...addCardOpen, card: false })}>
|
|
125
|
+
<OIcon
|
|
126
|
+
src={theme.images.general.close}
|
|
127
|
+
width={16}
|
|
128
|
+
style={style.wrapperIcon}
|
|
129
|
+
/>
|
|
130
|
+
</TouchableOpacity>
|
|
131
|
+
<>
|
|
132
|
+
<CreditCardInput
|
|
133
|
+
onChange={onChangeCardForm}
|
|
134
|
+
requiresName
|
|
135
|
+
/>
|
|
136
|
+
{alertState?.content?.[0] && !cardsList?.loading && (
|
|
137
|
+
<OText
|
|
138
|
+
color={theme?.colors?.error}
|
|
139
|
+
style={{
|
|
140
|
+
alignSelf: 'center'
|
|
141
|
+
}}
|
|
142
|
+
size={20}
|
|
143
|
+
>
|
|
144
|
+
{alertState.content[0]}
|
|
145
|
+
</OText>
|
|
146
|
+
)}
|
|
147
|
+
<OButton
|
|
148
|
+
text={t('ADD_CARD', 'Add card')}
|
|
149
|
+
isDisabled={!newCard || cardsList?.loading}
|
|
150
|
+
isLoading={cardsList?.loading}
|
|
151
|
+
onClick={() => handleAddNewCard()}
|
|
152
|
+
style={{
|
|
153
|
+
margin: 20,
|
|
154
|
+
...style.buttonStyle
|
|
155
|
+
}}
|
|
156
|
+
/>
|
|
157
|
+
</>
|
|
158
|
+
</ScrollView>
|
|
159
|
+
</KeyboardAvoidingView>
|
|
160
|
+
</Modal>
|
|
161
|
+
<Alert
|
|
162
|
+
open={alertState?.open || false}
|
|
163
|
+
title=''
|
|
164
|
+
content={alertState.content}
|
|
165
|
+
onClose={() => setAlertState({ open: false, content: [] })}
|
|
166
|
+
onAccept={() => setAlertState({ open: false, content: [] })}
|
|
167
|
+
/>
|
|
168
|
+
</View>
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export const PaymentOptionCard = (props : any) => {
|
|
173
|
+
const paymentOptions = {
|
|
174
|
+
...props,
|
|
175
|
+
UIComponent: PaymentOptionCardUI
|
|
176
|
+
}
|
|
177
|
+
return (
|
|
178
|
+
<PaymentOptionStripe {...paymentOptions} />
|
|
179
|
+
)
|
|
180
|
+
}
|
|
@@ -45,7 +45,7 @@ const PaymentOptionWalletUI = (props: any) => {
|
|
|
45
45
|
new Array(walletsState.result?.length).fill(false)
|
|
46
46
|
);
|
|
47
47
|
|
|
48
|
-
const creditBalance: any = (wallet: any) => ` = ${parsePrice(wallet.balance / wallet.redemption_rate
|
|
48
|
+
const creditBalance: any = (wallet: any) => ` = ${parsePrice(wallet.balance / wallet.redemption_rate)}`
|
|
49
49
|
|
|
50
50
|
const walletName: any = {
|
|
51
51
|
cash: {
|
|
@@ -87,65 +87,65 @@ const PaymentOptionWalletUI = (props: any) => {
|
|
|
87
87
|
{!walletsState.loading &&
|
|
88
88
|
!walletsState.error &&
|
|
89
89
|
walletsState.result?.length > 0 &&
|
|
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
|
-
</View>
|
|
90
|
+
(
|
|
91
|
+
<>
|
|
92
|
+
{walletsState.result?.map((wallet: any, idx: any) => wallet.valid && wallet.balance >= 0 && walletName[wallet.type]?.isActive && (
|
|
93
|
+
<Container
|
|
94
|
+
key={wallet.id}
|
|
95
|
+
isBottomBorder={idx === walletsState.result?.filter((wallet: any) => wallet.valid)?.length - 1}
|
|
96
|
+
onPress={() => handleOnChange(idx, wallet)}
|
|
97
|
+
disabled={(cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0}
|
|
98
|
+
>
|
|
99
|
+
<SectionLeft>
|
|
100
|
+
{checkedState[idx] ? (
|
|
101
|
+
<MaterialCommunityIcons
|
|
102
|
+
name="checkbox-marked"
|
|
103
|
+
size={25}
|
|
104
|
+
color={theme.colors.primary}
|
|
105
|
+
/>
|
|
106
|
+
) : (
|
|
107
|
+
<MaterialCommunityIcons
|
|
108
|
+
name="checkbox-blank-outline"
|
|
109
|
+
size={25}
|
|
110
|
+
color={theme.colors.disabled}
|
|
111
|
+
/>
|
|
112
|
+
)}
|
|
113
|
+
<View style={{ alignItems: 'baseline', marginLeft: 5 }}>
|
|
114
|
+
<View>
|
|
115
|
+
<OText
|
|
116
|
+
style={((cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0) ?{
|
|
117
|
+
color: theme.colors.disabled
|
|
118
|
+
} : {}}
|
|
119
|
+
>
|
|
120
|
+
{walletName[wallet.type]?.name}
|
|
121
|
+
</OText>
|
|
123
122
|
</View>
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
123
|
+
</View>
|
|
124
|
+
</SectionLeft>
|
|
125
|
+
|
|
126
|
+
<View style={{maxWidth: '35%', alignItems: 'flex-end' }}>
|
|
127
|
+
{wallet.type === 'cash' && (
|
|
128
|
+
<OText>
|
|
129
|
+
{parsePrice(wallet?.balance)}
|
|
130
|
+
</OText>
|
|
131
|
+
)}
|
|
132
|
+
{wallet.type === 'credit_point' && (
|
|
133
|
+
<OText>
|
|
134
|
+
<OText color={theme.colors.primary} weight='bold'>
|
|
135
|
+
{`${wallet?.balance} ${t('POINTS', 'Points')}`}
|
|
130
136
|
</OText>
|
|
131
|
-
)}
|
|
132
|
-
{wallet.type === 'credit_point' && (
|
|
133
137
|
<OText>
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
<OText>
|
|
138
|
-
{wallet?.balance > 0
|
|
139
|
-
? creditBalance(wallet)
|
|
140
|
-
: null}
|
|
141
|
-
</OText>
|
|
138
|
+
{wallet?.balance > 0
|
|
139
|
+
? creditBalance(wallet)
|
|
140
|
+
: null}
|
|
142
141
|
</OText>
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
</
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
142
|
+
</OText>
|
|
143
|
+
)}
|
|
144
|
+
</View>
|
|
145
|
+
</Container>
|
|
146
|
+
))}
|
|
147
|
+
</>
|
|
148
|
+
)}
|
|
149
149
|
|
|
150
150
|
{walletsState?.loading && (
|
|
151
151
|
<View>
|