ordering-ui-react-native 0.12.56 → 0.12.60
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/AppleLogin/index.tsx +14 -8
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +8 -8
- package/themes/business/src/components/OrderDetails/styles.tsx +1 -0
- package/themes/doordash/src/components/Cart/index.tsx +1 -0
- package/themes/doordash/src/components/OrderSummary/index.tsx +1 -0
- package/themes/instacart/src/components/OrderDetails/index.tsx +2 -2
- package/themes/single-business/src/components/Cart/index.tsx +127 -16
- package/themes/single-business/src/components/Cart/styles.tsx +39 -0
- package/themes/single-business/src/components/CartContent/index.tsx +56 -52
- package/themes/single-business/src/components/CartContent/styles.tsx +2 -16
- package/themes/single-business/src/components/OrderDetails/index.tsx +724 -708
- package/themes/single-business/src/components/OrderSummary/index.tsx +189 -154
- package/themes/franchises/index.tsx +0 -111
- package/themes/franchises/src/components/ActiveOrders/index.tsx +0 -134
- package/themes/franchises/src/components/ActiveOrders/styles.tsx +0 -44
- package/themes/franchises/src/components/AddressDetails/index.tsx +0 -77
- package/themes/franchises/src/components/AddressDetails/styles.tsx +0 -21
- package/themes/franchises/src/components/AddressForm/index.tsx +0 -837
- package/themes/franchises/src/components/AddressForm/styles.tsx +0 -27
- package/themes/franchises/src/components/AddressList/index.tsx +0 -338
- package/themes/franchises/src/components/AddressList/styles.tsx +0 -20
- package/themes/franchises/src/components/AppleLogin/index.tsx +0 -149
- package/themes/franchises/src/components/AppleLogin/styles.tsx +0 -21
- package/themes/franchises/src/components/BottomWrapper/index.tsx +0 -29
- package/themes/franchises/src/components/BusinessBasicInformation/index.tsx +0 -310
- package/themes/franchises/src/components/BusinessBasicInformation/styles.tsx +0 -66
- package/themes/franchises/src/components/BusinessController/index.tsx +0 -184
- package/themes/franchises/src/components/BusinessController/styles.tsx +0 -64
- package/themes/franchises/src/components/BusinessFeaturedController/index.tsx +0 -189
- package/themes/franchises/src/components/BusinessFeaturedController/styles.tsx +0 -50
- package/themes/franchises/src/components/BusinessInformation/index.tsx +0 -202
- package/themes/franchises/src/components/BusinessInformation/styles.tsx +0 -39
- package/themes/franchises/src/components/BusinessItemAccordion/index.tsx +0 -125
- package/themes/franchises/src/components/BusinessItemAccordion/styles.tsx +0 -54
- package/themes/franchises/src/components/BusinessProductsCategories/index.tsx +0 -87
- package/themes/franchises/src/components/BusinessProductsCategories/styles.tsx +0 -8
- package/themes/franchises/src/components/BusinessProductsList/index.tsx +0 -199
- package/themes/franchises/src/components/BusinessProductsList/styles.tsx +0 -14
- package/themes/franchises/src/components/BusinessProductsListing/index.tsx +0 -292
- package/themes/franchises/src/components/BusinessProductsListing/styles.tsx +0 -30
- package/themes/franchises/src/components/BusinessReviews/index.tsx +0 -249
- package/themes/franchises/src/components/BusinessReviews/styles.tsx +0 -59
- package/themes/franchises/src/components/BusinessTypeFilter/index.tsx +0 -127
- package/themes/franchises/src/components/BusinessTypeFilter/styles.tsx +0 -40
- package/themes/franchises/src/components/BusinessesListing/index.tsx +0 -339
- package/themes/franchises/src/components/BusinessesListing/styles.tsx +0 -92
- package/themes/franchises/src/components/Cart/index.tsx +0 -332
- package/themes/franchises/src/components/Cart/styles.tsx +0 -28
- package/themes/franchises/src/components/CartContent/index.tsx +0 -60
- package/themes/franchises/src/components/CartContent/styles.tsx +0 -19
- package/themes/franchises/src/components/Checkout/index.tsx +0 -664
- package/themes/franchises/src/components/Checkout/styles.tsx +0 -89
- package/themes/franchises/src/components/CouponControl/index.tsx +0 -119
- package/themes/franchises/src/components/CouponControl/styles.tsx +0 -22
- package/themes/franchises/src/components/DriverTips/index.tsx +0 -167
- package/themes/franchises/src/components/DriverTips/styles.tsx +0 -63
- package/themes/franchises/src/components/FacebookLogin/index.tsx +0 -107
- package/themes/franchises/src/components/FacebookLogin/styles.tsx +0 -21
- package/themes/franchises/src/components/FloatingButton/index.tsx +0 -100
- package/themes/franchises/src/components/FloatingButton/styles.tsx +0 -26
- package/themes/franchises/src/components/ForgotPasswordForm/index.tsx +0 -156
- package/themes/franchises/src/components/ForgotPasswordForm/styles.tsx +0 -11
- package/themes/franchises/src/components/GPSButton/index.tsx +0 -84
- package/themes/franchises/src/components/GPSButton/styles.ts +0 -6
- package/themes/franchises/src/components/GoogleLogin/index.tsx +0 -122
- package/themes/franchises/src/components/GoogleLogin/styles.tsx +0 -23
- package/themes/franchises/src/components/GoogleMap/index.tsx +0 -229
- package/themes/franchises/src/components/Help/index.tsx +0 -56
- package/themes/franchises/src/components/Help/styles.tsx +0 -11
- package/themes/franchises/src/components/HelpAccountAndPayment/index.tsx +0 -68
- package/themes/franchises/src/components/HelpAccountAndPayment/styles.tsx +0 -6
- package/themes/franchises/src/components/HelpGuide/index.tsx +0 -67
- package/themes/franchises/src/components/HelpGuide/styles.tsx +0 -6
- package/themes/franchises/src/components/HelpOrder/index.tsx +0 -79
- package/themes/franchises/src/components/HelpOrder/styles.tsx +0 -6
- package/themes/franchises/src/components/Home/index.tsx +0 -102
- package/themes/franchises/src/components/Home/styles.tsx +0 -18
- package/themes/franchises/src/components/LanguageSelector/index.tsx +0 -98
- package/themes/franchises/src/components/LanguageSelector/styles.tsx +0 -7
- package/themes/franchises/src/components/LastOrder/index.tsx +0 -168
- package/themes/franchises/src/components/LastOrder/styles.tsx +0 -16
- package/themes/franchises/src/components/LastOrders/index.tsx +0 -104
- package/themes/franchises/src/components/LastOrders/styles.tsx +0 -17
- package/themes/franchises/src/components/LoginForm/index.tsx +0 -512
- package/themes/franchises/src/components/LoginForm/styles.tsx +0 -77
- package/themes/franchises/src/components/LogoutButton/index.tsx +0 -36
- package/themes/franchises/src/components/Messages/index.tsx +0 -359
- package/themes/franchises/src/components/Messages/styles.tsx +0 -20
- package/themes/franchises/src/components/MomentOption/index.tsx +0 -321
- package/themes/franchises/src/components/MomentOption/styles.tsx +0 -66
- package/themes/franchises/src/components/NavBar/index.tsx +0 -129
- package/themes/franchises/src/components/NotFoundSource/index.tsx +0 -50
- package/themes/franchises/src/components/NotFoundSource/styles.tsx +0 -16
- package/themes/franchises/src/components/Notifications/index.tsx +0 -120
- package/themes/franchises/src/components/Notifications/styles.ts +0 -21
- package/themes/franchises/src/components/OrderDetails/index.tsx +0 -828
- package/themes/franchises/src/components/OrderDetails/styles.tsx +0 -120
- package/themes/franchises/src/components/OrderSummary/index.tsx +0 -266
- package/themes/franchises/src/components/OrderSummary/styles.tsx +0 -41
- package/themes/franchises/src/components/OrderTypeSelector/index.tsx +0 -92
- package/themes/franchises/src/components/OrderTypeSelector/styles.tsx +0 -27
- package/themes/franchises/src/components/OrdersOption/index.tsx +0 -243
- package/themes/franchises/src/components/OrdersOption/styles.tsx +0 -5
- package/themes/franchises/src/components/PaymentOptionCash/index.tsx +0 -102
- package/themes/franchises/src/components/PaymentOptionCash/styles.tsx +0 -18
- package/themes/franchises/src/components/PaymentOptionStripe/index.tsx +0 -234
- package/themes/franchises/src/components/PaymentOptionStripe/styles.tsx +0 -71
- package/themes/franchises/src/components/PaymentOptions/index.tsx +0 -430
- package/themes/franchises/src/components/PaymentOptions/styles.tsx +0 -77
- package/themes/franchises/src/components/PhoneInputNumber/index.tsx +0 -127
- package/themes/franchises/src/components/PhoneInputNumber/styles.tsx +0 -3
- package/themes/franchises/src/components/PreviousOrders/index.tsx +0 -188
- package/themes/franchises/src/components/PreviousOrders/styles.tsx +0 -33
- package/themes/franchises/src/components/ProductForm/index.tsx +0 -695
- package/themes/franchises/src/components/ProductForm/styles.tsx +0 -78
- package/themes/franchises/src/components/ProductIngredient/index.tsx +0 -43
- package/themes/franchises/src/components/ProductIngredient/styles.tsx +0 -7
- package/themes/franchises/src/components/ProductItemAccordion/index.tsx +0 -276
- package/themes/franchises/src/components/ProductItemAccordion/styles.tsx +0 -57
- package/themes/franchises/src/components/ProductOption/index.tsx +0 -50
- package/themes/franchises/src/components/ProductOption/styles.tsx +0 -11
- package/themes/franchises/src/components/ProductOptionSubOption/index.tsx +0 -146
- package/themes/franchises/src/components/ProductOptionSubOption/styles.tsx +0 -32
- package/themes/franchises/src/components/ReviewDriver/index.tsx +0 -221
- package/themes/franchises/src/components/ReviewDriver/styles.tsx +0 -46
- package/themes/franchises/src/components/ReviewOrder/index.tsx +0 -325
- package/themes/franchises/src/components/ReviewOrder/styles.tsx +0 -46
- package/themes/franchises/src/components/ReviewProduct/index.tsx +0 -275
- package/themes/franchises/src/components/ReviewProduct/styles.tsx +0 -53
- package/themes/franchises/src/components/SearchBar/index.tsx +0 -139
- package/themes/franchises/src/components/SignupForm/index.tsx +0 -643
- package/themes/franchises/src/components/SignupForm/styles.tsx +0 -27
- package/themes/franchises/src/components/SingleProductCard/index.tsx +0 -124
- package/themes/franchises/src/components/SingleProductCard/styles.tsx +0 -23
- package/themes/franchises/src/components/StripeCardForm/index.tsx +0 -97
- package/themes/franchises/src/components/StripeCardForm/naked.tsx +0 -128
- package/themes/franchises/src/components/StripeCardForm/styles.tsx +0 -32
- package/themes/franchises/src/components/StripeCardsList/index.tsx +0 -182
- package/themes/franchises/src/components/StripeElementsForm/index.tsx +0 -204
- package/themes/franchises/src/components/StripeElementsForm/naked.tsx +0 -90
- package/themes/franchises/src/components/StripeElementsForm/styles.tsx +0 -13
- package/themes/franchises/src/components/StripeRedirectForm/index.tsx +0 -159
- package/themes/franchises/src/components/StripeRedirectForm/styles.tsx +0 -23
- package/themes/franchises/src/components/TagSelector/index.tsx +0 -94
- package/themes/franchises/src/components/TagSelector/styles.ts +0 -0
- package/themes/franchises/src/components/TaxInformation/index.tsx +0 -51
- package/themes/franchises/src/components/TaxInformation/styles.tsx +0 -9
- package/themes/franchises/src/components/UpsellingProducts/index.tsx +0 -222
- package/themes/franchises/src/components/UpsellingProducts/styles.tsx +0 -50
- package/themes/franchises/src/components/UserDetails/index.tsx +0 -134
- package/themes/franchises/src/components/UserDetails/styles.tsx +0 -26
- package/themes/franchises/src/components/UserFormDetails/index.tsx +0 -351
- package/themes/franchises/src/components/UserFormDetails/styles.tsx +0 -35
- package/themes/franchises/src/components/UserProfile/index.tsx +0 -179
- package/themes/franchises/src/components/UserProfile/styles.ts +0 -42
- package/themes/franchises/src/components/UserProfileForm/index.tsx +0 -253
- package/themes/franchises/src/components/UserProfileForm/styles.tsx +0 -29
- package/themes/franchises/src/components/VerifyPhone/index.tsx +0 -188
- package/themes/franchises/src/components/VerifyPhone/styles.tsx +0 -43
- package/themes/franchises/src/components/shared/OAlert.tsx +0 -55
- package/themes/franchises/src/components/shared/OBottomPopup.tsx +0 -73
- package/themes/franchises/src/components/shared/OBottomStickBar.tsx +0 -62
- package/themes/franchises/src/components/shared/OButton.tsx +0 -132
- package/themes/franchises/src/components/shared/ODropDown.tsx +0 -169
- package/themes/franchises/src/components/shared/OIcon.tsx +0 -53
- package/themes/franchises/src/components/shared/OIconButton.tsx +0 -127
- package/themes/franchises/src/components/shared/OIconText.tsx +0 -54
- package/themes/franchises/src/components/shared/OInput.tsx +0 -113
- package/themes/franchises/src/components/shared/OKeyButton.tsx +0 -35
- package/themes/franchises/src/components/shared/OModal.tsx +0 -172
- package/themes/franchises/src/components/shared/OText.tsx +0 -52
- package/themes/franchises/src/components/shared/OTextarea.tsx +0 -36
- package/themes/franchises/src/components/shared/OToast.tsx +0 -93
- package/themes/franchises/src/components/shared/OToggle.tsx +0 -158
- package/themes/franchises/src/components/shared/index.tsx +0 -29
- package/themes/franchises/src/config/constants.tsx +0 -57
- package/themes/franchises/src/layouts/Container.tsx +0 -23
- package/themes/franchises/src/layouts/SafeAreaContainer.tsx +0 -6
- package/themes/franchises/src/providers/AlertProvider.tsx +0 -43
- package/themes/franchises/src/providers/StoreUtil.tsx +0 -50
- package/themes/franchises/src/types/index.tsx +0 -445
- package/themes/franchises/src/utils/index.tsx +0 -222
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { View, StyleSheet, useWindowDimensions } from 'react-native';
|
|
3
|
-
import { useLanguage, useSession } from 'ordering-components/native';
|
|
4
|
-
import {
|
|
5
|
-
StripeProvider,
|
|
6
|
-
CardField,
|
|
7
|
-
useConfirmSetupIntent,
|
|
8
|
-
createPaymentMethod
|
|
9
|
-
} from '@stripe/stripe-react-native';
|
|
10
|
-
import { useTheme } from 'styled-components/native';
|
|
11
|
-
import { ErrorMessage } from './styles';
|
|
12
|
-
|
|
13
|
-
import { StripeElementsForm as StripeFormController } from './naked';
|
|
14
|
-
import { OButton, OText } from '../shared';
|
|
15
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
16
|
-
|
|
17
|
-
const StripeElementsFormUI = (props: any) => {
|
|
18
|
-
const {
|
|
19
|
-
publicKey,
|
|
20
|
-
handleSource,
|
|
21
|
-
values,
|
|
22
|
-
businessId,
|
|
23
|
-
requirements,
|
|
24
|
-
stripeTokenHandler,
|
|
25
|
-
} = props;
|
|
26
|
-
|
|
27
|
-
const theme = useTheme();
|
|
28
|
-
|
|
29
|
-
const [, t] = useLanguage();
|
|
30
|
-
const [{ user }] = useSession();
|
|
31
|
-
const [card, setCard] = useState<any>(null);
|
|
32
|
-
const [isCompleted, setIsCompleted] = useState(false);
|
|
33
|
-
const [errors, setErrors] = useState('')
|
|
34
|
-
const { confirmSetupIntent, loading: confirmSetupLoading } = useConfirmSetupIntent();
|
|
35
|
-
const [createPmLoading, setCreatePmLoading] = useState(false);
|
|
36
|
-
const { height } = useWindowDimensions();
|
|
37
|
-
const { top, bottom } = useSafeAreaInsets();
|
|
38
|
-
|
|
39
|
-
const billingDetails = {
|
|
40
|
-
name: `${user.name} ${user.lastname}`,
|
|
41
|
-
email: user.email,
|
|
42
|
-
addressLine1: user.address
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const createPayMethod = async () => {
|
|
46
|
-
try {
|
|
47
|
-
setCreatePmLoading(true)
|
|
48
|
-
const { paymentMethod } = await createPaymentMethod({
|
|
49
|
-
type: 'Card',
|
|
50
|
-
billingDetails,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
setCreatePmLoading(false)
|
|
54
|
-
handleSource && handleSource({
|
|
55
|
-
id: paymentMethod.id,
|
|
56
|
-
type: 'card',
|
|
57
|
-
card: {
|
|
58
|
-
brand: paymentMethod.Card.brand,
|
|
59
|
-
last4: paymentMethod.Card.last4
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
// if (error) {
|
|
64
|
-
// setErrors(
|
|
65
|
-
// error?.code === 'Unknown'
|
|
66
|
-
// ? t('ERROR_ADD_CARD', 'An error occurred while trying to add a card')
|
|
67
|
-
// : error.message
|
|
68
|
-
// );
|
|
69
|
-
// }
|
|
70
|
-
} catch (error: any) {
|
|
71
|
-
setErrors(error?.message || error?.toString());
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const handleSaveCard = async () => {
|
|
76
|
-
setErrors('');
|
|
77
|
-
if (!requirements) {
|
|
78
|
-
createPayMethod();
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
try {
|
|
82
|
-
const { setupIntent, error } = await confirmSetupIntent(requirements, {
|
|
83
|
-
type: 'Card',
|
|
84
|
-
billingDetails,
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
if (setupIntent?.status === 'Succeeded') {
|
|
88
|
-
stripeTokenHandler(setupIntent?.paymentMethodId, user, businessId);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (error) {
|
|
92
|
-
setErrors(
|
|
93
|
-
error?.code === 'Unknown'
|
|
94
|
-
? t('ERROR_ADD_CARD', 'An error occurred while trying to add a card')
|
|
95
|
-
: error.message
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
} catch (error: any) {
|
|
99
|
-
setErrors(error?.message || error?.toString());
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
useEffect(() => {
|
|
104
|
-
if (card) {
|
|
105
|
-
setIsCompleted(
|
|
106
|
-
!!card?.last4 &&
|
|
107
|
-
!!card?.expiryMonth &&
|
|
108
|
-
!!card?.expiryYear &&
|
|
109
|
-
!!card?.brand &&
|
|
110
|
-
!!card?.postalCode
|
|
111
|
-
)
|
|
112
|
-
}
|
|
113
|
-
}, [card])
|
|
114
|
-
|
|
115
|
-
return (
|
|
116
|
-
<View style={{ ...styles.container, ...{ height: height - top - bottom - 60 } }}>
|
|
117
|
-
{publicKey ? (
|
|
118
|
-
<View style={{ flex: 1 }}>
|
|
119
|
-
<StripeProvider publishableKey={publicKey}>
|
|
120
|
-
<CardField
|
|
121
|
-
postalCodeEnabled={true}
|
|
122
|
-
cardStyle={{
|
|
123
|
-
backgroundColor: '#FFFFFF',
|
|
124
|
-
textColor: '#000000',
|
|
125
|
-
styles: {
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
}}
|
|
129
|
-
style={{
|
|
130
|
-
width: '100%',
|
|
131
|
-
height: 50,
|
|
132
|
-
marginVertical: 50,
|
|
133
|
-
borderWidth: 1,
|
|
134
|
-
borderColor: theme.colors.border,
|
|
135
|
-
borderRadius: 7.6
|
|
136
|
-
}}
|
|
137
|
-
onCardChange={(cardDetails: any) => setCard(cardDetails)}
|
|
138
|
-
/>
|
|
139
|
-
</StripeProvider>
|
|
140
|
-
{!!errors && (
|
|
141
|
-
<ErrorMessage>
|
|
142
|
-
<OText
|
|
143
|
-
size={20}
|
|
144
|
-
color={theme.colors.error}
|
|
145
|
-
style={{ marginTop: 20, textAlign: 'center' }}
|
|
146
|
-
>
|
|
147
|
-
{errors}
|
|
148
|
-
</OText>
|
|
149
|
-
</ErrorMessage>
|
|
150
|
-
)}
|
|
151
|
-
</View>
|
|
152
|
-
) : (
|
|
153
|
-
<ErrorMessage>
|
|
154
|
-
<OText
|
|
155
|
-
size={20}
|
|
156
|
-
color={theme.colors.error}
|
|
157
|
-
style={{ marginTop: 20 }}
|
|
158
|
-
>
|
|
159
|
-
{t('SOMETHING_WRONG', 'Something is wrong!')}
|
|
160
|
-
</OText>
|
|
161
|
-
</ErrorMessage>
|
|
162
|
-
)}
|
|
163
|
-
<OButton
|
|
164
|
-
text={t('SAVE_CARD', 'Save card')}
|
|
165
|
-
bgColor={isCompleted ? theme.colors.primary : theme.colors.backgroundGray}
|
|
166
|
-
borderColor={isCompleted ? theme.colors.primary : theme.colors.backgroundGray}
|
|
167
|
-
style={styles.btnAddStyle}
|
|
168
|
-
textStyle={{ color: 'white', fontSize: 14 }}
|
|
169
|
-
imgRightSrc={null}
|
|
170
|
-
onClick={isCompleted ? () => handleSaveCard() : () => { }}
|
|
171
|
-
isLoading={confirmSetupLoading || values.loadingAdd || createPmLoading}
|
|
172
|
-
/>
|
|
173
|
-
</View>
|
|
174
|
-
)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const styles = StyleSheet.create({
|
|
178
|
-
container: {
|
|
179
|
-
width: '100%',
|
|
180
|
-
paddingHorizontal: 40,
|
|
181
|
-
justifyContent: 'space-between',
|
|
182
|
-
paddingBottom: 12
|
|
183
|
-
},
|
|
184
|
-
btnAddStyle: {
|
|
185
|
-
marginTop: 20,
|
|
186
|
-
borderRadius: 7.6,
|
|
187
|
-
shadowOpacity: 0,
|
|
188
|
-
height: 44
|
|
189
|
-
},
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
export const StripeElementsForm = (props: any) => {
|
|
193
|
-
const stripeProps = {
|
|
194
|
-
...props,
|
|
195
|
-
UIComponent: StripeElementsFormUI,
|
|
196
|
-
onSelectCard: (card: any) => {
|
|
197
|
-
props.onSelectCard(card);
|
|
198
|
-
if (card) {
|
|
199
|
-
props.onCancel && props.onCancel();
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
return <StripeFormController {...stripeProps} />
|
|
204
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { useApi, useSession } from 'ordering-components/native';
|
|
3
|
-
|
|
4
|
-
export const StripeElementsForm = (props: any) => {
|
|
5
|
-
const {
|
|
6
|
-
UIComponent,
|
|
7
|
-
toSave
|
|
8
|
-
} = props;
|
|
9
|
-
|
|
10
|
-
const [ordering] = useApi();
|
|
11
|
-
const [{ token }] = useSession();
|
|
12
|
-
const [state, setState] = useState({ loading: false, loadingAdd: false, error: null, requirements: null });
|
|
13
|
-
|
|
14
|
-
const getRequirements = async () => {
|
|
15
|
-
try {
|
|
16
|
-
setState({
|
|
17
|
-
...state,
|
|
18
|
-
loading: true
|
|
19
|
-
})
|
|
20
|
-
const response = await fetch(
|
|
21
|
-
`${ordering.root}/payments/stripe/requirements?type=add_card`,
|
|
22
|
-
{
|
|
23
|
-
headers: {
|
|
24
|
-
Authorization: `Bearer ${token}`
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
)
|
|
28
|
-
const { result } = await response.json();
|
|
29
|
-
setState({
|
|
30
|
-
...state,
|
|
31
|
-
loading: false,
|
|
32
|
-
requirements: result
|
|
33
|
-
})
|
|
34
|
-
} catch (error) {
|
|
35
|
-
setState({
|
|
36
|
-
...state,
|
|
37
|
-
loading: false,
|
|
38
|
-
error
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const stripeTokenHandler = async (tokenId: string, user: any, businessId: string) => {
|
|
44
|
-
try {
|
|
45
|
-
setState({
|
|
46
|
-
...state,
|
|
47
|
-
loadingAdd: true
|
|
48
|
-
})
|
|
49
|
-
const result = await fetch(`${ordering.root}/payments/stripe/cards`, {
|
|
50
|
-
method: 'POST',
|
|
51
|
-
headers: {
|
|
52
|
-
Authorization: `Bearer ${user?.session?.access_token}`,
|
|
53
|
-
'Content-Type': 'application/json'
|
|
54
|
-
},
|
|
55
|
-
body: JSON.stringify({
|
|
56
|
-
business_id: businessId,
|
|
57
|
-
gateway: 'stripe',
|
|
58
|
-
token_id: tokenId,
|
|
59
|
-
user_id: user?.id
|
|
60
|
-
})
|
|
61
|
-
})
|
|
62
|
-
const response = await result.json();
|
|
63
|
-
props.onSelectCard && props.onSelectCard(response.result);
|
|
64
|
-
setState({
|
|
65
|
-
...state,
|
|
66
|
-
loadingAdd: false
|
|
67
|
-
})
|
|
68
|
-
} catch (error) {
|
|
69
|
-
setState({
|
|
70
|
-
...state,
|
|
71
|
-
loadingAdd: false,
|
|
72
|
-
error
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
if (!token || state.requirements) return
|
|
79
|
-
toSave && getRequirements()
|
|
80
|
-
}, [token])
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<UIComponent
|
|
84
|
-
{...props}
|
|
85
|
-
values={state}
|
|
86
|
-
requirements={state.requirements}
|
|
87
|
-
stripeTokenHandler={stripeTokenHandler}
|
|
88
|
-
/>
|
|
89
|
-
)
|
|
90
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import styled, { css } from 'styled-components/native';
|
|
2
|
-
|
|
3
|
-
export const ErrorMessage = styled.View`
|
|
4
|
-
color: ${(props: any) => props.theme.colors.cancelColor};
|
|
5
|
-
font-size: 24px;
|
|
6
|
-
padding-left: 10px;
|
|
7
|
-
font-weight: bold;
|
|
8
|
-
opacity: 0.8;
|
|
9
|
-
/* ${(props: any) => props.theme?.rtl && css`
|
|
10
|
-
padding-right: 10px;
|
|
11
|
-
padding-left: 0px;
|
|
12
|
-
`} */
|
|
13
|
-
`;
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { useForm, Controller } from 'react-hook-form';
|
|
3
|
-
import { StripeRedirectForm as StripeRedirectFormController, useSession, useLanguage, ToastType, useToast } from 'ordering-components/native';
|
|
4
|
-
import { useTheme } from 'styled-components/native';
|
|
5
|
-
// import stripe from 'tipsi-stripe';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
FormRedirect,
|
|
9
|
-
FormGroup,
|
|
10
|
-
ErrorMessage
|
|
11
|
-
} from './styles';
|
|
12
|
-
|
|
13
|
-
import { OButton, ODropDown, OInput, OText } from '../shared';
|
|
14
|
-
|
|
15
|
-
const StripeRedirectFormUI = (props: any) => {
|
|
16
|
-
const {
|
|
17
|
-
paymethods,
|
|
18
|
-
publicKey,
|
|
19
|
-
handleSubmitPaymentMethod
|
|
20
|
-
} = props;
|
|
21
|
-
|
|
22
|
-
const theme = useTheme();
|
|
23
|
-
|
|
24
|
-
// stripe.setOptions({
|
|
25
|
-
// publishableKey: publicKey,
|
|
26
|
-
// // androidPayMode: 'test', // Android only
|
|
27
|
-
// })
|
|
28
|
-
|
|
29
|
-
const [, { showToast }] = useToast();
|
|
30
|
-
const { control, handleSubmit, errors } = useForm();
|
|
31
|
-
|
|
32
|
-
const [{ user }] = useSession();
|
|
33
|
-
const [, t] = useLanguage();
|
|
34
|
-
|
|
35
|
-
const [paymentValue, setPaymentValue] = useState('-1');
|
|
36
|
-
|
|
37
|
-
const onSubmit = (values: any) => {
|
|
38
|
-
console.log('onSubmit', values);
|
|
39
|
-
// handleSubmitPaymentMethod && handleSubmitPaymentMethod();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const handleChangeBankOption = (option: any) => {
|
|
43
|
-
console.log('option', option);
|
|
44
|
-
// setPaymentValue(option.value)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
if (Object.keys(errors).length > 0) {
|
|
49
|
-
const list = Object.values(errors)
|
|
50
|
-
let stringError = ''
|
|
51
|
-
list.map((item: any, i: number) => {
|
|
52
|
-
stringError += (i + 1) === list.length ? `- ${item.message}` : `- ${item.message}\n`
|
|
53
|
-
})
|
|
54
|
-
showToast(ToastType.Error, stringError)
|
|
55
|
-
}
|
|
56
|
-
}, [errors])
|
|
57
|
-
|
|
58
|
-
const handleCreateSource = async () => {
|
|
59
|
-
// try {
|
|
60
|
-
// // this.setState({ loading: true, source: null })
|
|
61
|
-
// const source = await stripe.createSourceWithParams({
|
|
62
|
-
// type: 'alipay',
|
|
63
|
-
// amount: 50,
|
|
64
|
-
// currency: 'USD',
|
|
65
|
-
// returnURL: 'https://www.google.com/',
|
|
66
|
-
// })
|
|
67
|
-
// // this.setState({ loading: false, source })
|
|
68
|
-
// console.log('source', source);
|
|
69
|
-
// } catch (error) {
|
|
70
|
-
// // this.setState({ loading: false })
|
|
71
|
-
// console.log(error);
|
|
72
|
-
// }
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<FormRedirect>
|
|
77
|
-
<FormGroup>
|
|
78
|
-
<OText size={24}>{t('SELECT_A_PAYMENT_METHOD', 'Select a payment method')}</OText>
|
|
79
|
-
<ODropDown
|
|
80
|
-
options={paymethods}
|
|
81
|
-
defaultValue={paymentValue}
|
|
82
|
-
onSelect={(option: any) => handleChangeBankOption(option)}
|
|
83
|
-
/>
|
|
84
|
-
{/* {errors.type && errors.type.type === 'required' && (
|
|
85
|
-
<ErrorMessage>{t('FIELD_REQUIRED', 'This field is required')}</ErrorMessage>
|
|
86
|
-
)} */}
|
|
87
|
-
{/* {errors && (
|
|
88
|
-
<OText>
|
|
89
|
-
{JSON.stringify(errors)}
|
|
90
|
-
</OText>
|
|
91
|
-
)} */}
|
|
92
|
-
</FormGroup>
|
|
93
|
-
|
|
94
|
-
{/* <FormGroup>
|
|
95
|
-
<Controller
|
|
96
|
-
control={control}
|
|
97
|
-
render={({ onChange, value }) => (
|
|
98
|
-
<OInput
|
|
99
|
-
placeholder={t('TYPE_ACCOUNT_HOLDER', 'Type an Account holder')}
|
|
100
|
-
// style={styles.inputStyle}
|
|
101
|
-
icon={IMAGES.user}
|
|
102
|
-
value={value}
|
|
103
|
-
onChange={(val: any) => onChange(val)}
|
|
104
|
-
/>
|
|
105
|
-
)}
|
|
106
|
-
name="name"
|
|
107
|
-
rules={{
|
|
108
|
-
required: t(`VALIDATION_ERROR_NAME_REQUIRED`, 'Name is required'),
|
|
109
|
-
}}
|
|
110
|
-
defaultValue={user?.name}
|
|
111
|
-
/>
|
|
112
|
-
</FormGroup>
|
|
113
|
-
|
|
114
|
-
<FormGroup>
|
|
115
|
-
<Controller
|
|
116
|
-
control={control}
|
|
117
|
-
render={({ onChange, value }) => (
|
|
118
|
-
<OInput
|
|
119
|
-
placeholder={t('TYPE_AN_EMAIL', 'Type an email')}
|
|
120
|
-
icon={IMAGES.email}
|
|
121
|
-
value={value}
|
|
122
|
-
onChange={(val: any) => onChange(val)}
|
|
123
|
-
autoCapitalize='none'
|
|
124
|
-
/>
|
|
125
|
-
)}
|
|
126
|
-
name="email"
|
|
127
|
-
rules={{
|
|
128
|
-
required: t('VALIDATION_ERROR_EMAIL_REQUIRED', 'The field Email is required').replace('_attribute_', t('EMAIL', 'Email')),
|
|
129
|
-
pattern: {
|
|
130
|
-
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
|
|
131
|
-
message: t('INVALID_ERROR_EMAIL', 'Invalid email address').replace('_attribute_', t('EMAIL', 'Email'))
|
|
132
|
-
}
|
|
133
|
-
}}
|
|
134
|
-
defaultValue={user?.email}
|
|
135
|
-
/>
|
|
136
|
-
</FormGroup> */}
|
|
137
|
-
|
|
138
|
-
<OButton
|
|
139
|
-
// text={formState.isSubmitting ? t('LOADING', 'Loading...') : t('OK', 'OK')}
|
|
140
|
-
text={t('OK', 'OK')}
|
|
141
|
-
bgColor={theme.colors.primary}
|
|
142
|
-
borderColor={theme.colors.primary}
|
|
143
|
-
textStyle={{ color: 'white' }}
|
|
144
|
-
imgRightSrc={null}
|
|
145
|
-
// isDisabled={formState.isSubmitting}
|
|
146
|
-
// onClick={() => handleSubmit(onSubmit)}
|
|
147
|
-
onClick={() => handleCreateSource()}
|
|
148
|
-
/>
|
|
149
|
-
</FormRedirect>
|
|
150
|
-
)
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export const StripeRedirectForm = (props: any) => {
|
|
154
|
-
const stripeRedirectFormProps = {
|
|
155
|
-
...props,
|
|
156
|
-
UIComponent: StripeRedirectFormUI
|
|
157
|
-
}
|
|
158
|
-
return <StripeRedirectFormController {...stripeRedirectFormProps} />
|
|
159
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import styled, { css } from 'styled-components/native';
|
|
2
|
-
|
|
3
|
-
export const FormRedirect = styled.View`
|
|
4
|
-
display: flex;
|
|
5
|
-
flex-direction: column;
|
|
6
|
-
padding-left: 10px;
|
|
7
|
-
/* ${(props: any) => props.theme?.rtl && css`
|
|
8
|
-
padding-right: 10px;
|
|
9
|
-
padding-left: 0px;
|
|
10
|
-
`} */
|
|
11
|
-
`
|
|
12
|
-
|
|
13
|
-
export const FormGroup = styled.View`
|
|
14
|
-
display: flex;
|
|
15
|
-
flex-direction: column;
|
|
16
|
-
margin-bottom: 10px;
|
|
17
|
-
`
|
|
18
|
-
|
|
19
|
-
export const ErrorMessage = styled.View`
|
|
20
|
-
color: #D81212;
|
|
21
|
-
margin: 10px 0 0 0;
|
|
22
|
-
font-weight: bold;
|
|
23
|
-
`
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react'
|
|
2
|
-
import { StyleSheet, Text, View, TouchableOpacity, Image } from 'react-native';
|
|
3
|
-
import { useTheme } from 'styled-components/native';
|
|
4
|
-
// import { TouchableOpacity } from 'react-native-gesture-handler';
|
|
5
|
-
|
|
6
|
-
interface TProps {
|
|
7
|
-
items: Array<string>;
|
|
8
|
-
onUpdated?: (items: Array<TItem>) => void;
|
|
9
|
-
activeColor?: string;
|
|
10
|
-
normalColor?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface TItem {
|
|
14
|
-
id: number;
|
|
15
|
-
label: string;
|
|
16
|
-
checked: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const TagSelector = (props: TProps) => {
|
|
20
|
-
const { items, onUpdated, activeColor, normalColor } = props;
|
|
21
|
-
const theme = useTheme();
|
|
22
|
-
const [tags, setTags] = useState<TItem[]>([]);
|
|
23
|
-
|
|
24
|
-
const onCheck = (tag: TItem, remove?: boolean) => {
|
|
25
|
-
let temp = [...tags];
|
|
26
|
-
temp[tag.id].checked = remove ? !temp[tag.id].checked : true;
|
|
27
|
-
setTags(temp);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
const tagItems = items.map((str, idx) =>
|
|
32
|
-
{
|
|
33
|
-
return {
|
|
34
|
-
id: idx,
|
|
35
|
-
label: str,
|
|
36
|
-
checked: false,
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
)
|
|
40
|
-
setTags(tagItems);
|
|
41
|
-
}, [items]);
|
|
42
|
-
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (onUpdated) onUpdated(tags);
|
|
45
|
-
}, [tags]);
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<View style={tcStyles.wrapper}>
|
|
49
|
-
{tags.map((t, idx) =>
|
|
50
|
-
<TouchableOpacity key={idx} activeOpacity={0.8} onPress={() => onCheck(t)}
|
|
51
|
-
style={{...tcStyles.item, backgroundColor: t.checked === true ? activeColor || 'blue' : normalColor || '#eee'}}>
|
|
52
|
-
<Text style={{fontSize: 10, color: t.checked ? 'white' : 'black'}}>{t.label}</Text>
|
|
53
|
-
{t.checked &&
|
|
54
|
-
<TouchableOpacity onPress={() => onCheck(t, true)} style={tcStyles.remove}>
|
|
55
|
-
<Image source={theme.images.general.close} style={tcStyles.removeIcon} />
|
|
56
|
-
</TouchableOpacity>
|
|
57
|
-
}
|
|
58
|
-
</TouchableOpacity>
|
|
59
|
-
)}
|
|
60
|
-
</View>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const tcStyles = StyleSheet.create({
|
|
65
|
-
wrapper: {
|
|
66
|
-
flexDirection: 'row',
|
|
67
|
-
flexShrink: 1,
|
|
68
|
-
flexWrap: 'wrap'
|
|
69
|
-
},
|
|
70
|
-
item: {
|
|
71
|
-
borderRadius: 20,
|
|
72
|
-
paddingHorizontal: 12,
|
|
73
|
-
paddingVertical: 5,
|
|
74
|
-
marginEnd: 10,
|
|
75
|
-
backgroundColor: '#EEE',
|
|
76
|
-
flexDirection: 'row',
|
|
77
|
-
alignItems: 'center',
|
|
78
|
-
justifyContent: 'space-between',
|
|
79
|
-
marginBottom: 14,
|
|
80
|
-
minHeight: 24
|
|
81
|
-
},
|
|
82
|
-
remove: {
|
|
83
|
-
padding: 2,
|
|
84
|
-
marginStart: 12,
|
|
85
|
-
},
|
|
86
|
-
removeIcon: {
|
|
87
|
-
width: 7,
|
|
88
|
-
height: 7,
|
|
89
|
-
resizeMode: 'contain',
|
|
90
|
-
tintColor: 'white'
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
export default TagSelector;
|
|
File without changes
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { useLanguage, useUtils } from 'ordering-components/native'
|
|
3
|
-
import { SingleProductCard } from '../SingleProductCard'
|
|
4
|
-
import { TaxInformationContainer, ProductContainer } from './styles'
|
|
5
|
-
import { OText } from '../shared'
|
|
6
|
-
|
|
7
|
-
interface taxInformationParams {
|
|
8
|
-
data: { name: string, description?: string, rate: string | number, type: number, fixed?: number, percentage?: number, id: number },
|
|
9
|
-
products: Array<any>
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const TaxInformation = (props: taxInformationParams) => {
|
|
13
|
-
const {
|
|
14
|
-
data,
|
|
15
|
-
products
|
|
16
|
-
} = props
|
|
17
|
-
|
|
18
|
-
const [, t] = useLanguage()
|
|
19
|
-
const [{ parsePrice }] = useUtils()
|
|
20
|
-
|
|
21
|
-
const isTax = typeof data?.rate === 'number'
|
|
22
|
-
const TaxFeeString = isTax ? 'tax' : 'fee'
|
|
23
|
-
const includedOnPriceString = data?.type === 1 ? `(${t('INCLUDED_ON_PRICE', 'Included on price')})` : `(${t('NOT_INCLUDED_ON_PRICE', 'Not included on price')})`
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<TaxInformationContainer>
|
|
27
|
-
<OText size={24} style={{ alignSelf: 'center', textAlign: 'center' }} mBottom={10}>
|
|
28
|
-
{`${data?.name ||
|
|
29
|
-
t('INHERIT_FROM_BUSINESS', 'Inherit from business')} (${typeof data?.rate === 'number' ? `${data?.rate}%` : `${parsePrice(data?.fixed ?? 0)} + ${data?.percentage}%`})`}
|
|
30
|
-
</OText>
|
|
31
|
-
{data?.description && (
|
|
32
|
-
<OText mBottom={10} size={18} style={{ alignSelf: 'center', textAlign: 'center' }}>
|
|
33
|
-
{t('DESCRIPTION', 'Description')}: {data?.description} {data?.type && includedOnPriceString}
|
|
34
|
-
</OText>
|
|
35
|
-
)}
|
|
36
|
-
<OText>{t(`OTHER_PRODUCTS_WITH_THIS_${TaxFeeString.toUpperCase()}`, `Other products with this ${TaxFeeString}`)}:</OText>
|
|
37
|
-
<ProductContainer>
|
|
38
|
-
{
|
|
39
|
-
products.filter((product: any) => isTax ? (product.tax?.id ? product.tax?.id === data?.id : product.tax?.id === null && data?.id === null) : (product.fee?.id ? product.fee?.id === data?.id : (product.fee?.id === null && data?.id === null))).map(product => (
|
|
40
|
-
<SingleProductCard
|
|
41
|
-
key={product.id}
|
|
42
|
-
product={product}
|
|
43
|
-
isSoldOut={false}
|
|
44
|
-
businessId={product?.business_id}
|
|
45
|
-
/>
|
|
46
|
-
))
|
|
47
|
-
}
|
|
48
|
-
</ProductContainer>
|
|
49
|
-
</TaxInformationContainer>
|
|
50
|
-
)
|
|
51
|
-
}
|