ordering-ui-react-native 0.16.14 → 0.16.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/navigators/CheckoutNavigator.tsx +6 -0
- package/src/navigators/HomeNavigator.tsx +6 -0
- package/src/pages/MultiCheckout.tsx +31 -0
- package/src/pages/MultiOrdersDetails.tsx +27 -0
- package/themes/original/index.tsx +6 -0
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +3 -2
- package/themes/original/src/components/BusinessItemAccordion/styles.tsx +0 -2
- package/themes/original/src/components/BusinessProductsListing/index.tsx +14 -7
- package/themes/original/src/components/Cart/index.tsx +17 -8
- 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 +291 -0
- package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
- package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +370 -0
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +250 -0
- package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
- package/themes/original/src/components/MyOrders/index.tsx +120 -32
- package/themes/original/src/components/MyOrders/styles.tsx +8 -1
- package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +150 -0
- package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
- package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +51 -0
- package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
- package/themes/original/src/components/OrdersOption/index.tsx +102 -28
- package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
- package/themes/original/src/components/StripeElementsForm/index.tsx +10 -2
- package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
- package/themes/original/src/components/UserDetails/index.tsx +1 -1
- package/themes/original/src/types/index.tsx +43 -19
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import AddressForm from '../pages/AddressForm'
|
|
|
6
6
|
import CartList from '../pages/CartList'
|
|
7
7
|
import CheckoutPage from '../pages/Checkout';
|
|
8
8
|
import BusinessProductsList from '../pages/BusinessProductsList';
|
|
9
|
+
import MultiCheckout from '../pages/MultiCheckout';
|
|
9
10
|
|
|
10
11
|
const Stack = createStackNavigator();
|
|
11
12
|
|
|
@@ -53,6 +54,11 @@ const CheckoutNavigator = (props: any) => {
|
|
|
53
54
|
component={AddressForm}
|
|
54
55
|
options={{ headerShown: false }}
|
|
55
56
|
/>
|
|
57
|
+
<Stack.Screen
|
|
58
|
+
name="MultiCheckout"
|
|
59
|
+
children={() => <MultiCheckout {...checkoutProps} />}
|
|
60
|
+
options={{ headerShown: false }}
|
|
61
|
+
/>
|
|
56
62
|
</Stack.Navigator>
|
|
57
63
|
);
|
|
58
64
|
}
|
|
@@ -23,6 +23,7 @@ import HelpAccountAndPayment from '../pages/HelpAccountAndPayment'
|
|
|
23
23
|
import Sessions from '../pages/Sessions';
|
|
24
24
|
import Splash from '../pages/Splash';
|
|
25
25
|
import ProductDetails from '../pages/ProductDetails';
|
|
26
|
+
import MultiOrdersDetails from '../pages/MultiOrdersDetails';
|
|
26
27
|
const Stack = createStackNavigator();
|
|
27
28
|
|
|
28
29
|
const HomeNavigator = (e : any) => {
|
|
@@ -170,6 +171,11 @@ const HomeNavigator = (e : any) => {
|
|
|
170
171
|
component={Sessions}
|
|
171
172
|
options={{ headerShown: false }}
|
|
172
173
|
/>
|
|
174
|
+
<Stack.Screen
|
|
175
|
+
name="MultiOrdersDetails"
|
|
176
|
+
component={MultiOrdersDetails}
|
|
177
|
+
options={{ headerShown: false }}
|
|
178
|
+
/>
|
|
173
179
|
</>
|
|
174
180
|
)}
|
|
175
181
|
</>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Platform, KeyboardAvoidingView, StyleSheet } from 'react-native'
|
|
3
|
+
import { MultiCheckout as MultiCheckoutController } from '../../themes/original/src/components/MultiCheckout'
|
|
4
|
+
|
|
5
|
+
const MultiCheckout = (props: any) => {
|
|
6
|
+
const multiCheckoutProps = {
|
|
7
|
+
...props,
|
|
8
|
+
onPlaceOrderClick: (orderUuids: any) => {
|
|
9
|
+
props.navigation.navigate('MultiOrdersDetails', { orderUuids: orderUuids, isFromMultiCheckout: true })
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<KeyboardAvoidingView
|
|
15
|
+
enabled
|
|
16
|
+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
17
|
+
style={styles.container}
|
|
18
|
+
>
|
|
19
|
+
<MultiCheckoutController {...multiCheckoutProps} />
|
|
20
|
+
</KeyboardAvoidingView>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const styles = StyleSheet.create({
|
|
25
|
+
container: {
|
|
26
|
+
flexGrow: 1,
|
|
27
|
+
paddingBottom: 70,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export default MultiCheckout
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Platform } from 'react-native'
|
|
3
|
+
import { MultiOrdersDetails as MultiOrdersDetailsController } from '../../themes/original/src/components/MultiOrdersDetails'
|
|
4
|
+
import styled from 'styled-components/native';
|
|
5
|
+
|
|
6
|
+
const SafeAreaContainer = styled.SafeAreaView`
|
|
7
|
+
flex: 1;
|
|
8
|
+
background-color: ${(props: any) => props.theme.colors.backgroundPage};
|
|
9
|
+
padding-top: ${Platform.OS === 'ios' ? '0px' : '24px'};
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
const MultiOrdersDetails = ({ navigation, route }: any) => {
|
|
13
|
+
const multiOrdersDetailsProps = {
|
|
14
|
+
navigation,
|
|
15
|
+
orderUuids: route.params?.orderUuids || [],
|
|
16
|
+
isFromMultiCheckout: route.params?.isFromMultiCheckout,
|
|
17
|
+
onRedirectPage: () => navigation.navigate('BusinessList')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<SafeAreaContainer>
|
|
22
|
+
<MultiOrdersDetailsController {...multiOrdersDetailsProps} />
|
|
23
|
+
</SafeAreaContainer>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default MultiOrdersDetails
|
|
@@ -32,6 +32,7 @@ import { ReviewDriver } from './src/components/ReviewDriver';
|
|
|
32
32
|
import { UserProfile } from './src/components/UserProfile';
|
|
33
33
|
import { MessageListing } from './src/components/MessageListing';
|
|
34
34
|
import { Messages } from './src/components/Messages';
|
|
35
|
+
import { MyOrders } from './src/components/MyOrders';
|
|
35
36
|
import { Help } from './src/components/Help';
|
|
36
37
|
import { HelpAccountAndPayment } from './src/components/HelpAccountAndPayment';
|
|
37
38
|
import { HelpGuide } from './src/components/HelpGuide';
|
|
@@ -47,6 +48,8 @@ import { UpsellingProducts } from './src/components/UpsellingProducts';
|
|
|
47
48
|
import { UserVerification } from './src/components/UserVerification';
|
|
48
49
|
import { BusinessListingSearch } from './src/components/BusinessListingSearch';
|
|
49
50
|
import { LastOrders } from './src/components/LastOrders';
|
|
51
|
+
import { MultiCheckout } from './src/components/MultiCheckout'
|
|
52
|
+
import { MultiOrdersDetails } from './src/components/MultiOrdersDetails'
|
|
50
53
|
import NavBar from './src/components/NavBar';
|
|
51
54
|
import { BusinessTypeFilter } from './src/components/BusinessTypeFilter';
|
|
52
55
|
import { BusinessController } from './src/components/BusinessController';
|
|
@@ -187,6 +190,8 @@ export {
|
|
|
187
190
|
HelpAccountAndPayment,
|
|
188
191
|
HelpGuide,
|
|
189
192
|
HelpOrder,
|
|
193
|
+
MultiCheckout,
|
|
194
|
+
MultiOrdersDetails,
|
|
190
195
|
NetworkError,
|
|
191
196
|
NotFoundSource,
|
|
192
197
|
OrderTypeSelector,
|
|
@@ -240,6 +245,7 @@ export {
|
|
|
240
245
|
UserFormDetailsUI,
|
|
241
246
|
WalletTransactionItem,
|
|
242
247
|
Promotions,
|
|
248
|
+
MyOrders,
|
|
243
249
|
ORDER_TYPES,
|
|
244
250
|
USER_TYPE,
|
|
245
251
|
|
|
@@ -21,7 +21,8 @@ export const BusinessItemAccordion = (props: any) => {
|
|
|
21
21
|
singleBusiness,
|
|
22
22
|
handleClearProducts,
|
|
23
23
|
handleClickCheckout,
|
|
24
|
-
checkoutButtonDisabled
|
|
24
|
+
checkoutButtonDisabled,
|
|
25
|
+
isMultiCheckout
|
|
25
26
|
} = props
|
|
26
27
|
|
|
27
28
|
const [orderState] = useOrder();
|
|
@@ -139,7 +140,7 @@ export const BusinessItemAccordion = (props: any) => {
|
|
|
139
140
|
)}
|
|
140
141
|
</BIActions>
|
|
141
142
|
</BIHeader>
|
|
142
|
-
{!isActive && !isClosed && !!isProducts && (
|
|
143
|
+
{!isActive && !isClosed && !!isProducts && !isMultiCheckout && (
|
|
143
144
|
<PriceContainer>
|
|
144
145
|
<OText>{parsePrice(cart?.total)}</OText>
|
|
145
146
|
{cart?.valid_products && (
|
|
@@ -102,6 +102,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
102
102
|
const [isCategoryClicked, setCategoryClicked] = useState(false)
|
|
103
103
|
const [subcategoriesSelected, setSubcategoriesSelected] = useState([])
|
|
104
104
|
|
|
105
|
+
const isCheckoutMultiBusinessEnabled: Boolean = configs?.checkout_multi_business_enabled?.value === '1'
|
|
105
106
|
const currentCart: any = Object.values(orderState.carts).find((cart: any) => cart?.business?.slug === business?.slug) ?? {}
|
|
106
107
|
const isOpenFiltProducts = isOpenSearchBar && !!searchValue
|
|
107
108
|
const filtProductsHeight = Platform.OS === 'ios' ? 0 : 35
|
|
@@ -123,13 +124,19 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
const handleUpsellingPage = () => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
if (isCheckoutMultiBusinessEnabled) {
|
|
128
|
+
onRedirect('CheckoutNavigator', {
|
|
129
|
+
screen: 'MultiCheckout'
|
|
130
|
+
})
|
|
131
|
+
} else {
|
|
132
|
+
onRedirect('CheckoutNavigator', {
|
|
133
|
+
screen: 'CheckoutPage',
|
|
134
|
+
cartUuid: currentCart?.uuid,
|
|
135
|
+
businessLogo: logo,
|
|
136
|
+
businessName: business?.name,
|
|
137
|
+
cartTotal: currentCart?.total
|
|
138
|
+
})
|
|
139
|
+
}
|
|
133
140
|
setOpenUpselling(false)
|
|
134
141
|
}
|
|
135
142
|
|
|
@@ -39,7 +39,8 @@ const CartUI = (props: any) => {
|
|
|
39
39
|
handleChangeComment,
|
|
40
40
|
commentState,
|
|
41
41
|
onNavigationRedirect,
|
|
42
|
-
handleRemoveOfferClick
|
|
42
|
+
handleRemoveOfferClick,
|
|
43
|
+
isMultiCheckout
|
|
43
44
|
} = props
|
|
44
45
|
|
|
45
46
|
const theme = useTheme();
|
|
@@ -59,6 +60,7 @@ const CartUI = (props: any) => {
|
|
|
59
60
|
|
|
60
61
|
const isCartPending = cart?.status === 2
|
|
61
62
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
|
|
63
|
+
const isCheckoutMultiBusinessEnabled: Boolean = configs?.checkout_multi_business_enabled?.value === '1'
|
|
62
64
|
|
|
63
65
|
const business: any = (orderState?.carts && Object.values(orderState.carts).find((_cart: any) => _cart?.uuid === props.cartuuid)) ?? {}
|
|
64
66
|
const businessId = business?.business_id ?? null
|
|
@@ -96,13 +98,19 @@ const CartUI = (props: any) => {
|
|
|
96
98
|
const handleUpsellingPage = () => {
|
|
97
99
|
setOpenUpselling(false)
|
|
98
100
|
setCanOpenUpselling(false)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
if (isCheckoutMultiBusinessEnabled) {
|
|
102
|
+
props.onNavigationRedirect('CheckoutNavigator', {
|
|
103
|
+
screen: 'MultiCheckout'
|
|
104
|
+
})
|
|
105
|
+
} else {
|
|
106
|
+
props.onNavigationRedirect('CheckoutNavigator', {
|
|
107
|
+
screen: 'CheckoutPage',
|
|
108
|
+
cartUuid: cart?.uuid,
|
|
109
|
+
businessLogo: cart?.business?.logo,
|
|
110
|
+
businessName: cart?.business?.name,
|
|
111
|
+
cartTotal: cart?.total
|
|
112
|
+
})
|
|
113
|
+
}
|
|
106
114
|
}
|
|
107
115
|
|
|
108
116
|
const getIncludedTaxes = () => {
|
|
@@ -165,6 +173,7 @@ const CartUI = (props: any) => {
|
|
|
165
173
|
handleChangeStore={() => setOpenChangeStore(true)}
|
|
166
174
|
handleClickCheckout={() => setOpenUpselling(true)}
|
|
167
175
|
checkoutButtonDisabled={(openUpselling && !canOpenUpselling) || cart?.subtotal < cart?.minimum || !cart?.valid_address}
|
|
176
|
+
isMultiCheckout={isMultiCheckout}
|
|
168
177
|
>
|
|
169
178
|
{cart?.products?.length > 0 && cart?.products.map((product: any, i: number) => (
|
|
170
179
|
<ProductItemAccordion
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
useLanguage,
|
|
4
|
+
useConfig,
|
|
5
|
+
useUtils,
|
|
6
|
+
MultiCartsPaymethodsAndWallets as MultiCartsPaymethodsAndWalletsController
|
|
7
|
+
} from 'ordering-components/native'
|
|
8
|
+
import { useTheme } from 'styled-components/native'
|
|
9
|
+
import { View, TouchableOpacity, FlatList, StyleSheet, KeyboardAvoidingView, Platform } from 'react-native'
|
|
10
|
+
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder'
|
|
11
|
+
import { OText, OIcon, OModal, OButton } from '../shared'
|
|
12
|
+
import { getIconCard, flatArray } from '../../utils'
|
|
13
|
+
import { StripeElementsForm } from '../StripeElementsForm'
|
|
14
|
+
import { StripeCardsList } from '../StripeCardsList'
|
|
15
|
+
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
PMContainer,
|
|
19
|
+
PMItem,
|
|
20
|
+
WalletItem
|
|
21
|
+
} from './styles'
|
|
22
|
+
|
|
23
|
+
const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
|
|
24
|
+
const {
|
|
25
|
+
businessIds,
|
|
26
|
+
paymethodsAndWallets,
|
|
27
|
+
walletsState,
|
|
28
|
+
businessPaymethods,
|
|
29
|
+
paymethodSelected,
|
|
30
|
+
handleSelectPaymethod,
|
|
31
|
+
handleSelectWallet,
|
|
32
|
+
handlePaymethodDataChange
|
|
33
|
+
} = props
|
|
34
|
+
|
|
35
|
+
const theme = useTheme()
|
|
36
|
+
const [, t] = useLanguage()
|
|
37
|
+
const [{ configs }] = useConfig()
|
|
38
|
+
const [{ parsePrice }] = useUtils()
|
|
39
|
+
|
|
40
|
+
const [addCardOpen, setAddCardOpen] = useState({ stripe: false, stripeConnect: false });
|
|
41
|
+
|
|
42
|
+
const isWalletCashEnabled = configs?.wallet_cash_enabled?.value === '1'
|
|
43
|
+
const isWalletPointsEnabled = configs?.wallet_credit_point_enabled?.value === '1'
|
|
44
|
+
|
|
45
|
+
const walletName: any = {
|
|
46
|
+
cash: {
|
|
47
|
+
name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet'),
|
|
48
|
+
isActive: isWalletCashEnabled
|
|
49
|
+
},
|
|
50
|
+
credit_point: {
|
|
51
|
+
name: t('PAY_WITH_CREDITS_POINTS_WALLET', 'Pay with Credit Points Wallet'),
|
|
52
|
+
isActive: isWalletPointsEnabled
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const getPayIcon = (method: string) => {
|
|
57
|
+
switch (method) {
|
|
58
|
+
case 'cash':
|
|
59
|
+
return theme.images.general.cash
|
|
60
|
+
case 'card_delivery':
|
|
61
|
+
return theme.images.general.carddelivery
|
|
62
|
+
case 'paypal':
|
|
63
|
+
return theme.images.general.paypal
|
|
64
|
+
case 'stripe':
|
|
65
|
+
return theme.images.general.stripe
|
|
66
|
+
case 'stripe_direct':
|
|
67
|
+
return theme.images.general.stripecc
|
|
68
|
+
case 'stripe_connect':
|
|
69
|
+
return theme.images.general.stripes
|
|
70
|
+
case 'stripe_redirect':
|
|
71
|
+
return theme.images.general.stripesb
|
|
72
|
+
default:
|
|
73
|
+
return theme.images.general.creditCard
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const renderPaymethods = ({ item }: any) => {
|
|
78
|
+
return (
|
|
79
|
+
<TouchableOpacity
|
|
80
|
+
onPress={() => handleSelectPaymethod(item)}
|
|
81
|
+
>
|
|
82
|
+
<PMItem
|
|
83
|
+
key={item.id}
|
|
84
|
+
isActive={paymethodSelected?.paymethod_id === item.paymethod_id}
|
|
85
|
+
>
|
|
86
|
+
<OIcon
|
|
87
|
+
src={getPayIcon(item.paymethod?.gateway)}
|
|
88
|
+
width={20}
|
|
89
|
+
height={20}
|
|
90
|
+
color={paymethodSelected?.paymethod_id === item.paymethod_id ? theme.colors.white : theme.colors.backgroundDark}
|
|
91
|
+
/>
|
|
92
|
+
<OText
|
|
93
|
+
size={10}
|
|
94
|
+
style={{ margin: 0, marginTop: 4 }}
|
|
95
|
+
color={paymethodSelected?.paymethod_id === item.paymethod_id ? theme.colors.white : '#000'}
|
|
96
|
+
>
|
|
97
|
+
{t(item?.paymethod?.gateway.toUpperCase(), item?.paymethod?.name)}
|
|
98
|
+
</OText>
|
|
99
|
+
</PMItem>
|
|
100
|
+
</TouchableOpacity>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<PMContainer>
|
|
106
|
+
<OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>
|
|
107
|
+
{t('PAYMENT_METHODS', 'Payment Methods')}
|
|
108
|
+
</OText>
|
|
109
|
+
{paymethodsAndWallets.loading ? (
|
|
110
|
+
<Placeholder style={{ marginTop: 10 }} Animation={Fade}>
|
|
111
|
+
<View style={{ display: 'flex', flexDirection: 'row' }}>
|
|
112
|
+
{[...Array(3)].map((_, i) => (
|
|
113
|
+
<PlaceholderLine
|
|
114
|
+
key={i}
|
|
115
|
+
width={37}
|
|
116
|
+
height={80}
|
|
117
|
+
noMargin
|
|
118
|
+
style={{ borderRadius: 10, marginRight: 10 }}
|
|
119
|
+
/>
|
|
120
|
+
))}
|
|
121
|
+
</View>
|
|
122
|
+
</Placeholder>
|
|
123
|
+
) : (
|
|
124
|
+
<FlatList
|
|
125
|
+
horizontal
|
|
126
|
+
showsHorizontalScrollIndicator={false}
|
|
127
|
+
data={businessPaymethods.result.filter((paymethod: any) => paymethodsAndWallets.paymethods.find((item: any) => item.id === paymethod.paymethod_id))}
|
|
128
|
+
renderItem={renderPaymethods}
|
|
129
|
+
keyExtractor={(paymethod: any) => paymethod?.id?.toString?.()}
|
|
130
|
+
/>
|
|
131
|
+
)}
|
|
132
|
+
{!paymethodsAndWallets.loading && !paymethodsAndWallets.error && paymethodsAndWallets.paymethods.length === 0 && (
|
|
133
|
+
<OText size={12} style={{ margin: 0 }}>
|
|
134
|
+
{t('NO_PAYMENT_METHODS', 'No payment methods!')}
|
|
135
|
+
</OText>
|
|
136
|
+
)}
|
|
137
|
+
|
|
138
|
+
{paymethodSelected?.paymethod?.gateway === 'stripe' && (
|
|
139
|
+
<View>
|
|
140
|
+
<OButton
|
|
141
|
+
text={t('ADD_PAYMENT_CARD', 'Add New Payment Card')}
|
|
142
|
+
bgColor={theme.colors.white}
|
|
143
|
+
borderColor={theme.colors.primary}
|
|
144
|
+
style={styles.btnAddStyle}
|
|
145
|
+
textStyle={{ color: theme.colors.primary, fontSize: 12 }}
|
|
146
|
+
imgRightSrc={null}
|
|
147
|
+
onClick={() => setAddCardOpen({ ...addCardOpen, stripe: true })}
|
|
148
|
+
/>
|
|
149
|
+
<StripeCardsList
|
|
150
|
+
paymethod={paymethodSelected?.paymethod}
|
|
151
|
+
businessId={businessIds[0]}
|
|
152
|
+
businessIds={businessIds}
|
|
153
|
+
publicKey={paymethodSelected?.data?.publishable}
|
|
154
|
+
payType={paymethodSelected?.paymethod?.name}
|
|
155
|
+
onSelectCard={handlePaymethodDataChange}
|
|
156
|
+
/>
|
|
157
|
+
</View>
|
|
158
|
+
)}
|
|
159
|
+
|
|
160
|
+
{(paymethodsAndWallets.loading || walletsState.loading) ? (
|
|
161
|
+
<>
|
|
162
|
+
{[...Array(2).keys()].map(i => (
|
|
163
|
+
<PlaceholderLine
|
|
164
|
+
key={i}
|
|
165
|
+
height={40}
|
|
166
|
+
noMargin
|
|
167
|
+
style={{ marginBottom: 10 }}
|
|
168
|
+
/>
|
|
169
|
+
))}
|
|
170
|
+
</>
|
|
171
|
+
) : (
|
|
172
|
+
<>
|
|
173
|
+
{walletsState.result.filter((wallet: any) => paymethodsAndWallets.wallets.find((item: any) => item.type === wallet.type)).map((wallet: any, idx: any) => walletName[wallet.type]?.isActive && (
|
|
174
|
+
<WalletItem
|
|
175
|
+
key={wallet.type}
|
|
176
|
+
isBottomBorder={idx === paymethodsAndWallets.wallets?.length - 1}
|
|
177
|
+
onPress={() => handleSelectWallet(paymethodSelected.wallet_id === wallet.id ? false : true, wallet)}
|
|
178
|
+
>
|
|
179
|
+
{paymethodSelected.wallet_id === wallet.id ? (
|
|
180
|
+
<MaterialCommunityIcons
|
|
181
|
+
name="checkbox-marked"
|
|
182
|
+
size={25}
|
|
183
|
+
color={theme.colors.primary}
|
|
184
|
+
/>
|
|
185
|
+
) : (
|
|
186
|
+
<MaterialCommunityIcons
|
|
187
|
+
name="checkbox-blank-outline"
|
|
188
|
+
size={25}
|
|
189
|
+
color={theme.colors.disabled}
|
|
190
|
+
/>
|
|
191
|
+
)}
|
|
192
|
+
<OText size={12} style={{ flex: 1, marginLeft: 15 }}>{walletName[wallet.type]?.name}</OText>
|
|
193
|
+
<OText size={12}>{parsePrice(wallet.balance)}</OText>
|
|
194
|
+
</WalletItem>
|
|
195
|
+
))}
|
|
196
|
+
</>
|
|
197
|
+
)}
|
|
198
|
+
|
|
199
|
+
<OModal
|
|
200
|
+
entireModal
|
|
201
|
+
title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
|
|
202
|
+
open={addCardOpen.stripe}
|
|
203
|
+
onClose={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
|
|
204
|
+
style={{ backgroundColor: 'red' }}
|
|
205
|
+
>
|
|
206
|
+
<KeyboardAvoidingView
|
|
207
|
+
behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
|
|
208
|
+
keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
|
|
209
|
+
enabled={Platform.OS === 'ios' ? true : false}
|
|
210
|
+
>
|
|
211
|
+
<StripeElementsForm
|
|
212
|
+
toSave
|
|
213
|
+
businessId={businessIds[0]}
|
|
214
|
+
businessIds={businessIds}
|
|
215
|
+
publicKey={paymethodSelected?.data?.publishable}
|
|
216
|
+
requirements={props.clientSecret}
|
|
217
|
+
onSelectCard={handlePaymethodDataChange}
|
|
218
|
+
onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
|
|
219
|
+
/>
|
|
220
|
+
</KeyboardAvoidingView>
|
|
221
|
+
</OModal>
|
|
222
|
+
</PMContainer>
|
|
223
|
+
)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const styles = StyleSheet.create({
|
|
227
|
+
btnAddStyle: {
|
|
228
|
+
marginVertical: 20,
|
|
229
|
+
borderRadius: 7.6,
|
|
230
|
+
shadowOpacity: 0,
|
|
231
|
+
height: 44,
|
|
232
|
+
borderWidth: 1
|
|
233
|
+
},
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
export const MultiCartsPaymethodsAndWallets = (props: any) => {
|
|
238
|
+
const multiCartsPaymethodsAndWalletsProps = {
|
|
239
|
+
...props,
|
|
240
|
+
UIComponent: MultiCartsPaymethodsAndWalletsUI
|
|
241
|
+
}
|
|
242
|
+
return <MultiCartsPaymethodsAndWalletsController {...multiCartsPaymethodsAndWalletsProps} />
|
|
243
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components/native'
|
|
2
|
+
|
|
3
|
+
export const PMContainer = styled.View`
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
width: 100%;
|
|
7
|
+
`
|
|
8
|
+
export const PMItem = styled.View`
|
|
9
|
+
width: 120px;
|
|
10
|
+
height: 50px;
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
border-radius: 10px;
|
|
16
|
+
margin-right: 10px;
|
|
17
|
+
margin-top: 10px;
|
|
18
|
+
text-align: center;
|
|
19
|
+
background-color: ${(props: any) => props.theme.colors.inputDisabled};
|
|
20
|
+
|
|
21
|
+
${(props: any) => props.theme?.rtl && css`
|
|
22
|
+
margin-left: 10px;
|
|
23
|
+
margin-right: 0;
|
|
24
|
+
`}
|
|
25
|
+
|
|
26
|
+
${(props: any) => props.isActive ? css`
|
|
27
|
+
background-color: ${(props: any) => props.theme.colors.primary};
|
|
28
|
+
` : css`
|
|
29
|
+
border: 1px solid #EAEAEA;
|
|
30
|
+
`}
|
|
31
|
+
`
|
|
32
|
+
export const WalletItem = styled.TouchableOpacity`
|
|
33
|
+
width: 100%;
|
|
34
|
+
display: flex;
|
|
35
|
+
padding: 20px 0;
|
|
36
|
+
margin-top: 10px;
|
|
37
|
+
flex-direction: row;
|
|
38
|
+
justify-content: space-between;
|
|
39
|
+
align-items: center;
|
|
40
|
+
border-top-width: 1px;
|
|
41
|
+
border-top-color: ${(props: any) => props.theme.colors.backgroundGray200};
|
|
42
|
+
${(props: any) => props.isBottomBorder && css`
|
|
43
|
+
border-bottom-width: 1px;
|
|
44
|
+
border-bottom-color: ${(props: any) => props.theme.colors.backgroundGray200};
|
|
45
|
+
`}
|
|
46
|
+
`
|