ordering-ui-react-native 0.14.69 → 0.14.72
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/components/Checkout/index.tsx +1 -0
- package/src/components/PaymentOptions/index.tsx +15 -6
- package/src/components/ProductForm/index.tsx +1 -1
- package/src/components/StripeElementsForm/index.tsx +48 -27
- package/src/components/StripeMethodForm/index.tsx +163 -0
- package/src/config.json +2 -0
- package/src/types/index.tsx +9 -0
- package/themes/kiosk/src/components/BusinessController/index.tsx +67 -0
- package/themes/kiosk/src/components/BusinessController/styles.tsx +23 -0
- package/themes/kiosk/src/components/BusinessesListing/index.tsx +119 -0
- package/themes/kiosk/src/components/BusinessesListing/styles.tsx +24 -0
- package/themes/kiosk/src/components/LoginForm/index.tsx +62 -2
- package/themes/kiosk/src/components/LogoutButton/index.tsx +74 -0
- package/themes/kiosk/src/types/index.d.ts +1 -0
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +32 -1
- package/themes/original/src/components/BusinessInformation/index.tsx +7 -2
- package/themes/original/src/components/BusinessesListing/index.tsx +8 -9
- package/themes/original/src/components/Cart/index.tsx +8 -8
- package/themes/original/src/components/Checkout/index.tsx +82 -70
- package/themes/original/src/components/LoginForm/index.tsx +6 -4
- package/themes/original/src/components/OrderDetails/index.tsx +58 -6
- package/themes/original/src/components/OrderProgress/index.tsx +39 -31
- package/themes/original/src/components/OrderSummary/index.tsx +8 -8
- package/themes/original/src/components/OrdersOption/index.tsx +40 -16
- package/themes/original/src/components/OrdersOption/styles.tsx +5 -0
- package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
- package/themes/original/src/components/PhoneInputNumber/styles.tsx +1 -1
- package/themes/original/src/components/ProductForm/index.tsx +42 -11
- package/themes/original/src/components/ProductForm/styles.tsx +1 -1
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +1 -1
- package/themes/original/src/components/ProductOptionSubOption/styles.tsx +1 -1
- package/themes/original/src/components/SingleProductCard/index.tsx +15 -8
- package/themes/original/src/components/UpsellingProducts/index.tsx +1 -4
- package/themes/original/src/components/UserProfile/index.tsx +13 -11
- package/themes/original/src/components/WalletTransactionItem/index.tsx +5 -5
- package/themes/original/src/components/Wallets/styles.tsx +1 -1
- package/themes/original/src/components/shared/OInput.tsx +6 -2
- package/themes/original/src/utils/index.tsx +7 -0
package/package.json
CHANGED
|
@@ -61,11 +61,14 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
61
61
|
handlePaymethodDataChange,
|
|
62
62
|
handlePaymentMethodClickCustom,
|
|
63
63
|
isOpenMethod,
|
|
64
|
-
setCardData
|
|
64
|
+
setCardData,
|
|
65
|
+
handlePlaceOrder
|
|
65
66
|
} = props
|
|
66
67
|
|
|
67
68
|
const theme = useTheme();
|
|
68
69
|
const [, t] = useLanguage();
|
|
70
|
+
const methodsPay = ['google_pay', 'apple_pay']
|
|
71
|
+
const stripeDirectMethods = ['stripe_direct', ...methodsPay]
|
|
69
72
|
|
|
70
73
|
const [addCardOpen, setAddCardOpen] = useState({ stripe: false, stripeConnect: false });
|
|
71
74
|
let paymethodSelected = props.paySelected || props.paymethodSelected || isOpenMethod?.paymethod
|
|
@@ -119,8 +122,11 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
119
122
|
}, [props.paySelected])
|
|
120
123
|
|
|
121
124
|
useEffect(() => {
|
|
122
|
-
setCardData(paymethodData)
|
|
123
|
-
|
|
125
|
+
setCardData && setCardData(paymethodData)
|
|
126
|
+
if (methodsPay.includes(paymethodSelected?.gateway) && paymethodData?.id && paymethodSelected?.data?.card) {
|
|
127
|
+
handlePlaceOrder()
|
|
128
|
+
}
|
|
129
|
+
}, [paymethodData, paymethodSelected])
|
|
124
130
|
|
|
125
131
|
const renderPaymethods = ({ item }: any) => {
|
|
126
132
|
return (
|
|
@@ -283,7 +289,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
283
289
|
<OModal
|
|
284
290
|
entireModal
|
|
285
291
|
title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
|
|
286
|
-
open={isOpenMethod?.paymethod?.gateway
|
|
292
|
+
open={stripeDirectMethods?.includes(isOpenMethod?.paymethod?.gateway) && !paymethodData.id}
|
|
287
293
|
onClose={() => handlePaymethodClick(null)}
|
|
288
294
|
>
|
|
289
295
|
<KeyboardAvoidingView
|
|
@@ -292,10 +298,13 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
292
298
|
enabled={Platform.OS === 'ios' ? true : false}
|
|
293
299
|
>
|
|
294
300
|
<StripeElementsForm
|
|
301
|
+
cart={cart}
|
|
302
|
+
paymethod={isOpenMethod?.paymethod?.gateway}
|
|
303
|
+
methodsPay={methodsPay}
|
|
295
304
|
businessId={props.businessId}
|
|
296
|
-
publicKey={isOpenMethod?.paymethod?.credentials?.publishable}
|
|
305
|
+
publicKey={isOpenMethod?.paymethod?.credentials?.publishable || isOpenMethod?.paymethod?.credentials?.publishable_key}
|
|
297
306
|
handleSource={handlePaymethodDataChange}
|
|
298
|
-
onCancel={() => handlePaymethodClick(
|
|
307
|
+
onCancel={() => handlePaymethodClick(null)}
|
|
299
308
|
/>
|
|
300
309
|
</KeyboardAvoidingView>
|
|
301
310
|
</OModal>
|
|
@@ -7,10 +7,11 @@ import {
|
|
|
7
7
|
useConfirmSetupIntent,
|
|
8
8
|
createPaymentMethod
|
|
9
9
|
} from '@stripe/stripe-react-native';
|
|
10
|
-
|
|
10
|
+
import configs from '../../config.json'
|
|
11
11
|
import { ErrorMessage } from './styles';
|
|
12
12
|
|
|
13
13
|
import { StripeElementsForm as StripeFormController } from './naked';
|
|
14
|
+
import { StripeMethodForm } from '../StripeMethodForm';
|
|
14
15
|
import { OButton, OText } from '../shared';
|
|
15
16
|
import { useTheme } from 'styled-components/native';
|
|
16
17
|
|
|
@@ -22,6 +23,10 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
22
23
|
businessId,
|
|
23
24
|
requirements,
|
|
24
25
|
stripeTokenHandler,
|
|
26
|
+
methodsPay,
|
|
27
|
+
paymethod,
|
|
28
|
+
onCancel,
|
|
29
|
+
cart
|
|
25
30
|
} = props;
|
|
26
31
|
|
|
27
32
|
const theme = useTheme();
|
|
@@ -121,33 +126,49 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
121
126
|
<View style={styles.container}>
|
|
122
127
|
{publicKey ? (
|
|
123
128
|
<View style={{ flex: 1 }}>
|
|
124
|
-
<StripeProvider
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
129
|
+
<StripeProvider
|
|
130
|
+
publishableKey={publicKey}
|
|
131
|
+
merchantIdentifier={`merchant.${configs.apple_app_id}`}
|
|
132
|
+
>
|
|
133
|
+
{methodsPay.includes(paymethod) ? (
|
|
134
|
+
<StripeMethodForm
|
|
135
|
+
handleSource={handleSource}
|
|
136
|
+
onCancel={onCancel}
|
|
137
|
+
cart={cart}
|
|
138
|
+
setErrors={setErrors}
|
|
139
|
+
paymethod={paymethod}
|
|
140
|
+
devMode={publicKey?.includes('test')}
|
|
141
|
+
/>
|
|
142
|
+
) : (
|
|
143
|
+
<CardField
|
|
144
|
+
postalCodeEnabled={true}
|
|
145
|
+
cardStyle={{
|
|
146
|
+
backgroundColor: '#FFFFFF',
|
|
147
|
+
textColor: '#000000',
|
|
148
|
+
}}
|
|
149
|
+
style={{
|
|
150
|
+
width: '100%',
|
|
151
|
+
height: 50,
|
|
152
|
+
marginVertical: 30,
|
|
153
|
+
zIndex: 9999,
|
|
154
|
+
}}
|
|
155
|
+
onCardChange={(cardDetails: any) => setCard(cardDetails)}
|
|
156
|
+
/>
|
|
157
|
+
)}
|
|
139
158
|
</StripeProvider>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
159
|
+
{!methodsPay?.includes(paymethod) && (
|
|
160
|
+
<OButton
|
|
161
|
+
text={t('SAVE_CARD', 'Save card')}
|
|
162
|
+
bgColor={isCompleted ? theme.colors.primary : theme.colors.backgroundGray}
|
|
163
|
+
borderColor={isCompleted ? theme.colors.primary :theme.colors.backgroundGray}
|
|
164
|
+
style={styles.btnAddStyle}
|
|
165
|
+
textStyle={{color: 'white'}}
|
|
166
|
+
imgRightSrc={null}
|
|
167
|
+
onClick={() => handleSaveCard()}
|
|
168
|
+
isDisabled={!isCompleted}
|
|
169
|
+
isLoading={confirmSetupLoading || values.loadingAdd || createPmLoading}
|
|
170
|
+
/>
|
|
171
|
+
)}
|
|
151
172
|
{!!errors && (
|
|
152
173
|
<ErrorMessage>
|
|
153
174
|
<OText
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { useLanguage } from 'ordering-components/native'
|
|
3
|
+
import { GooglePayButton, useGooglePay, ApplePayButton, useApplePay } from '@stripe/stripe-react-native'
|
|
4
|
+
import { OButton } from '../shared';
|
|
5
|
+
import { Platform, View } from 'react-native';
|
|
6
|
+
import { StripeMethodFormParams } from '../../types';
|
|
7
|
+
|
|
8
|
+
export const StripeMethodForm = (props: StripeMethodFormParams) => {
|
|
9
|
+
const {
|
|
10
|
+
cart,
|
|
11
|
+
handleSource,
|
|
12
|
+
onCancel,
|
|
13
|
+
setErrors,
|
|
14
|
+
paymethod,
|
|
15
|
+
devMode
|
|
16
|
+
} = props
|
|
17
|
+
const { initGooglePay, createGooglePayPaymentMethod, loading } = useGooglePay();
|
|
18
|
+
const { presentApplePay, isApplePaySupported } = useApplePay();
|
|
19
|
+
const [initialized, setInitialized] = useState(false);
|
|
20
|
+
const [, t] = useLanguage()
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (paymethod !== 'google_pay') return
|
|
24
|
+
if (Platform.OS === 'ios') {
|
|
25
|
+
setErrors(t('GOOGLE_PAY_NOT_SUPPORTED', 'Google pay not supported'))
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
const initialize = async () => {
|
|
29
|
+
try {
|
|
30
|
+
const { error } = await initGooglePay({
|
|
31
|
+
testEnv: devMode,
|
|
32
|
+
merchantName: 'Widget Store',
|
|
33
|
+
countryCode: 'US',
|
|
34
|
+
billingAddressConfig: {
|
|
35
|
+
format: 'FULL',
|
|
36
|
+
isPhoneNumberRequired: true,
|
|
37
|
+
isRequired: false,
|
|
38
|
+
},
|
|
39
|
+
existingPaymentMethodRequired: false,
|
|
40
|
+
isEmailRequired: true,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (error) {
|
|
44
|
+
setErrors(error.code + ' - ' + error.message);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
setInitialized(true);
|
|
48
|
+
} catch (err: any) {
|
|
49
|
+
setErrors('Catch ' + err?.message)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
initialize();
|
|
53
|
+
}, [initGooglePay]);
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (paymethod !== 'apple_pay') return
|
|
57
|
+
if (Platform.OS === 'android') {
|
|
58
|
+
setErrors(t('APPLE_PAY_NOT_SUPPORTED', 'Apple pay not supported'))
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
}, [])
|
|
62
|
+
|
|
63
|
+
const createPaymentMethod = async () => {
|
|
64
|
+
|
|
65
|
+
const { error, paymentMethod } = await createGooglePayPaymentMethod({
|
|
66
|
+
amount: cart?.balance ?? cart?.total,
|
|
67
|
+
currencyCode: 'USD',
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (error) {
|
|
71
|
+
setErrors(error.code + ' - ' + error.message);
|
|
72
|
+
return;
|
|
73
|
+
} else if (paymentMethod) {
|
|
74
|
+
handleSource({
|
|
75
|
+
...paymentMethod?.Card,
|
|
76
|
+
id: paymentMethod.id,
|
|
77
|
+
type: paymentMethod.type,
|
|
78
|
+
source_id: paymentMethod?.id,
|
|
79
|
+
card: {
|
|
80
|
+
brand: paymentMethod.Card.brand,
|
|
81
|
+
last4: paymentMethod.Card.last4
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
onCancel()
|
|
85
|
+
}
|
|
86
|
+
setInitialized(false);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const pay = async () => {
|
|
90
|
+
if (!isApplePaySupported) {
|
|
91
|
+
setErrors(t('APPLE_PAY_NOT_SUPPORTED', 'Apple pay not supported'))
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const { error, paymentMethod } = await presentApplePay({
|
|
96
|
+
cartItems: cart?.products?.map((product: any) => ({ label: product?.name, amount: product?.price?.toString?.() })),
|
|
97
|
+
country: 'US',
|
|
98
|
+
currency: 'USD',
|
|
99
|
+
shippingMethods: [
|
|
100
|
+
{
|
|
101
|
+
amount: cart?.balance?.toString() ?? cart?.total?.toString?.(),
|
|
102
|
+
identifier: 'DPS',
|
|
103
|
+
label: 'Courier',
|
|
104
|
+
detail: 'Delivery',
|
|
105
|
+
type: 'final',
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
|
|
109
|
+
requiredShippingAddressFields: ['emailAddress', 'phoneNumber'],
|
|
110
|
+
requiredBillingContactFields: ['phoneNumber', 'name'],
|
|
111
|
+
});
|
|
112
|
+
if (error) {
|
|
113
|
+
setErrors(error.code + ' - ' + error.message);
|
|
114
|
+
} else if (paymentMethod) {
|
|
115
|
+
handleSource({
|
|
116
|
+
...paymentMethod?.Card,
|
|
117
|
+
id: paymentMethod.id,
|
|
118
|
+
type: paymentMethod.type,
|
|
119
|
+
source_id: paymentMethod?.id,
|
|
120
|
+
card: {
|
|
121
|
+
brand: paymentMethod.Card.brand,
|
|
122
|
+
last4: paymentMethod.Card.last4
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
onCancel()
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<>
|
|
131
|
+
{paymethod === 'google_pay' ? (
|
|
132
|
+
<View>
|
|
133
|
+
{!loading && initialized && (
|
|
134
|
+
<OButton
|
|
135
|
+
textStyle={{
|
|
136
|
+
color: '#fff'
|
|
137
|
+
}}
|
|
138
|
+
imgRightSrc={null}
|
|
139
|
+
onClick={createPaymentMethod}
|
|
140
|
+
isDisabled={!initialized}
|
|
141
|
+
text={t('PAY_WITH_GOOGLE_PAY', 'Pay with Google Pay')}
|
|
142
|
+
/>
|
|
143
|
+
)}
|
|
144
|
+
</View>
|
|
145
|
+
) : (
|
|
146
|
+
<View>
|
|
147
|
+
{isApplePaySupported && (
|
|
148
|
+
<ApplePayButton
|
|
149
|
+
onPress={pay}
|
|
150
|
+
type="plain"
|
|
151
|
+
buttonStyle="black"
|
|
152
|
+
borderRadius={4}
|
|
153
|
+
style={{
|
|
154
|
+
width: '100%',
|
|
155
|
+
height: 50,
|
|
156
|
+
}}
|
|
157
|
+
/>
|
|
158
|
+
)}
|
|
159
|
+
</View>
|
|
160
|
+
)}
|
|
161
|
+
</>
|
|
162
|
+
)
|
|
163
|
+
}
|
package/src/config.json
CHANGED
package/src/types/index.tsx
CHANGED
|
@@ -473,3 +473,12 @@ export interface HelpGuideParams {
|
|
|
473
473
|
export interface HelpAccountAndPaymentParams {
|
|
474
474
|
navigation: any;
|
|
475
475
|
}
|
|
476
|
+
|
|
477
|
+
export interface StripeMethodFormParams {
|
|
478
|
+
cart: any;
|
|
479
|
+
handleSource: ({id, card} : {id : string, card : any}) => void;
|
|
480
|
+
onCancel: () => void;
|
|
481
|
+
setErrors: (error: string) => void;
|
|
482
|
+
paymethod: string;
|
|
483
|
+
devMode?: boolean;
|
|
484
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
import { useTheme } from 'styled-components/native';
|
|
4
|
+
import { useDeviceOrientation } from '../../../../../src/hooks/DeviceOrientation';
|
|
5
|
+
import {
|
|
6
|
+
BusinessController as BusinessSingleCard,
|
|
7
|
+
useUtils,
|
|
8
|
+
} from 'ordering-components/native';
|
|
9
|
+
|
|
10
|
+
import { Card, BusinessLogo } from './styles';
|
|
11
|
+
|
|
12
|
+
import { OText } from '../shared';
|
|
13
|
+
|
|
14
|
+
export const BusinessControllerUI = (props: any) => {
|
|
15
|
+
const { business, handleClick, isLoading } = props;
|
|
16
|
+
const [{ optimizeImage }] = useUtils();
|
|
17
|
+
const theme = useTheme()
|
|
18
|
+
|
|
19
|
+
const [orientationState] = useDeviceOrientation();
|
|
20
|
+
|
|
21
|
+
const WIDTH_SCREEN = orientationState?.dimensions?.width
|
|
22
|
+
|
|
23
|
+
const styles = StyleSheet.create({
|
|
24
|
+
businessName: {
|
|
25
|
+
width: '100%',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
textAlign: 'center',
|
|
28
|
+
marginTop: 10
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const handleBusinessClick = (selectedBusiness: any) => {
|
|
33
|
+
if (isLoading) return
|
|
34
|
+
handleClick && handleClick(selectedBusiness)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Card
|
|
39
|
+
activeOpacity={1}
|
|
40
|
+
onPress={() => handleBusinessClick(business)}
|
|
41
|
+
>
|
|
42
|
+
<BusinessLogo
|
|
43
|
+
source={business?.logo ? {
|
|
44
|
+
uri: optimizeImage(business?.logo, 'h_120,c_limit'),
|
|
45
|
+
} : theme.images.dummies.businessLogo}
|
|
46
|
+
resizeMode='contain'
|
|
47
|
+
/>
|
|
48
|
+
<OText
|
|
49
|
+
size={WIDTH_SCREEN * 0.012}
|
|
50
|
+
numberOfLines={2}
|
|
51
|
+
ellipsizeMode='tail'
|
|
52
|
+
style={styles.businessName}
|
|
53
|
+
>
|
|
54
|
+
{business?.name}
|
|
55
|
+
</OText>
|
|
56
|
+
</Card>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const BusinessController = (props: any) => {
|
|
61
|
+
const BusinessControllerProps = {
|
|
62
|
+
...props,
|
|
63
|
+
UIComponent: BusinessControllerUI,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return <BusinessSingleCard {...BusinessControllerProps} />;
|
|
67
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components/native';
|
|
2
|
+
|
|
3
|
+
export const Card = styled.TouchableOpacity`
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
align-items: center;
|
|
8
|
+
margin: 0 15px 20px;
|
|
9
|
+
width: 120px;
|
|
10
|
+
`
|
|
11
|
+
|
|
12
|
+
export const BusinessLogo = styled.ImageBackground`
|
|
13
|
+
position: relative;
|
|
14
|
+
height: 120px;
|
|
15
|
+
width: 120px;
|
|
16
|
+
border-radius: 8px;
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
align-items: center;
|
|
21
|
+
border-width: 1px;
|
|
22
|
+
border-color: ${(props: any) => props.theme.colors.border};
|
|
23
|
+
`
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
|
|
3
|
+
import { View, ScrollView, Platform } from 'react-native';
|
|
4
|
+
import { useTheme } from 'styled-components/native';
|
|
5
|
+
import { useDeviceOrientation } from '../../../../../src/hooks/DeviceOrientation';
|
|
6
|
+
import {
|
|
7
|
+
BusinessList as BusinessesListingController,
|
|
8
|
+
useLanguage,
|
|
9
|
+
useOrder,
|
|
10
|
+
} from 'ordering-components/native';
|
|
11
|
+
|
|
12
|
+
import { ListWrapper, CardsContainer, WrapperList } from './styles';
|
|
13
|
+
|
|
14
|
+
import { NotFoundSource } from '../NotFoundSource';
|
|
15
|
+
import { BusinessController } from '../BusinessController';
|
|
16
|
+
import { OText } from '../shared';
|
|
17
|
+
import { LogoutButton } from '../LogoutButton';
|
|
18
|
+
|
|
19
|
+
const BusinessesListingUI = (props: any) => {
|
|
20
|
+
const {
|
|
21
|
+
navigation,
|
|
22
|
+
businessesList,
|
|
23
|
+
handleBusinessClick,
|
|
24
|
+
paginationProps,
|
|
25
|
+
} = props;
|
|
26
|
+
|
|
27
|
+
const theme = useTheme();
|
|
28
|
+
const [, t] = useLanguage();
|
|
29
|
+
const [orderState] = useOrder();
|
|
30
|
+
const [orientationState] = useDeviceOrientation();
|
|
31
|
+
|
|
32
|
+
const WIDTH_SCREEN = orientationState?.dimensions?.width
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<ScrollView showsVerticalScrollIndicator={false}>
|
|
36
|
+
<ListWrapper>
|
|
37
|
+
{!businessesList.loading ? (
|
|
38
|
+
<>
|
|
39
|
+
<OText
|
|
40
|
+
size={WIDTH_SCREEN * 0.02}
|
|
41
|
+
weight='bold'
|
|
42
|
+
style={{ paddingHorizontal: 15 }}
|
|
43
|
+
>
|
|
44
|
+
{t('STORES', 'Stores')}
|
|
45
|
+
</OText>
|
|
46
|
+
<OText
|
|
47
|
+
size={WIDTH_SCREEN * 0.014}
|
|
48
|
+
color={theme.colors.paleGray}
|
|
49
|
+
style={{
|
|
50
|
+
paddingHorizontal: 15,
|
|
51
|
+
paddingBottom: 40
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
{t('SELECT_STORE_MESSAGE', 'Please select the store that do you need')}
|
|
55
|
+
</OText>
|
|
56
|
+
<View style={{ position: 'absolute', top: 25, right: 20 }}>
|
|
57
|
+
<LogoutButton />
|
|
58
|
+
</View>
|
|
59
|
+
</>
|
|
60
|
+
) : (
|
|
61
|
+
<View style={{ paddingHorizontal: 20 }}>
|
|
62
|
+
<PlaceholderLine width={80} height={50} style={{ marginBottom: 10 }} />
|
|
63
|
+
<PlaceholderLine height={50} style={{ marginBottom: 40 }} />
|
|
64
|
+
</View>
|
|
65
|
+
)}
|
|
66
|
+
<CardsContainer>
|
|
67
|
+
{!businessesList.loading && businessesList.businesses?.map(
|
|
68
|
+
(business: any) => (
|
|
69
|
+
<BusinessController
|
|
70
|
+
key={business.id}
|
|
71
|
+
business={business}
|
|
72
|
+
isBusinessOpen={business.open}
|
|
73
|
+
handleCustomClick={handleBusinessClick}
|
|
74
|
+
orderType={orderState?.options?.type}
|
|
75
|
+
navigation={navigation}
|
|
76
|
+
/>
|
|
77
|
+
)
|
|
78
|
+
)}
|
|
79
|
+
</CardsContainer>
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
{!businessesList.loading && businessesList.businesses.length === 0 && (
|
|
83
|
+
<NotFoundSource
|
|
84
|
+
content={t(
|
|
85
|
+
'NOT_FOUND_BUSINESSES',
|
|
86
|
+
'No businesses to delivery / pick up at this address, please change filters or change address.',
|
|
87
|
+
)}
|
|
88
|
+
/>
|
|
89
|
+
)}
|
|
90
|
+
|
|
91
|
+
{businessesList.loading && (
|
|
92
|
+
<WrapperList>
|
|
93
|
+
{[...Array(24).keys()].map(i => (
|
|
94
|
+
<PlaceholderLine
|
|
95
|
+
key={i}
|
|
96
|
+
width={15}
|
|
97
|
+
height={120}
|
|
98
|
+
style={{
|
|
99
|
+
marginBottom: 20,
|
|
100
|
+
borderRadius: 8
|
|
101
|
+
}}
|
|
102
|
+
/>
|
|
103
|
+
))}
|
|
104
|
+
</WrapperList>
|
|
105
|
+
)}
|
|
106
|
+
</ListWrapper>
|
|
107
|
+
</ScrollView>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const BusinessesListing = (props: any) => {
|
|
112
|
+
const BusinessesListingProps = {
|
|
113
|
+
...props,
|
|
114
|
+
isForceSearch: Platform.OS === 'ios',
|
|
115
|
+
UIComponent: BusinessesListingUI,
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
return <BusinessesListingController {...BusinessesListingProps} />;
|
|
119
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import styled from 'styled-components/native'
|
|
2
|
+
|
|
3
|
+
export const ListWrapper = styled.View`
|
|
4
|
+
background-color: ${(props: any) => props.theme.colors.backgroundLight};
|
|
5
|
+
padding: 20px 5px 0;
|
|
6
|
+
`;
|
|
7
|
+
|
|
8
|
+
export const CardsContainer = styled.View`
|
|
9
|
+
display: flex;
|
|
10
|
+
width: 100%;
|
|
11
|
+
justify-content: flex-start;
|
|
12
|
+
text-align: center;
|
|
13
|
+
flex-direction: row;
|
|
14
|
+
flex-wrap: wrap;
|
|
15
|
+
`
|
|
16
|
+
|
|
17
|
+
export const WrapperList = styled.View`
|
|
18
|
+
width: 100%;
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: row;
|
|
21
|
+
flex-wrap: wrap;
|
|
22
|
+
justify-content: space-between;
|
|
23
|
+
padding: 0 20px;
|
|
24
|
+
`
|