ordering-ui-react-native 0.12.57 → 0.12.58
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/themes/single-business/src/components/Cart/index.tsx +91 -15
- 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/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,124 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
useLanguage,
|
|
4
|
-
useConfig,
|
|
5
|
-
useOrder,
|
|
6
|
-
useUtils,
|
|
7
|
-
} from 'ordering-components/native';
|
|
8
|
-
import { useTheme } from 'styled-components/native';
|
|
9
|
-
import { SingleProductCardParams } from '../../types';
|
|
10
|
-
import { CardContainer, CardInfo, SoldOut } from './styles';
|
|
11
|
-
import { StyleSheet } from 'react-native';
|
|
12
|
-
import { OText, OIcon } from '../shared';
|
|
13
|
-
|
|
14
|
-
export const SingleProductCard = (props: SingleProductCardParams) => {
|
|
15
|
-
const { businessId, product, isSoldOut, onProductClick } = props;
|
|
16
|
-
|
|
17
|
-
const theme = useTheme();
|
|
18
|
-
|
|
19
|
-
const styles = StyleSheet.create({
|
|
20
|
-
container: {
|
|
21
|
-
borderWidth: 1,
|
|
22
|
-
borderRadius: 7.6,
|
|
23
|
-
borderColor: theme.colors.border,
|
|
24
|
-
marginBottom: 28,
|
|
25
|
-
},
|
|
26
|
-
line18: {
|
|
27
|
-
lineHeight: 18,
|
|
28
|
-
},
|
|
29
|
-
line15: {
|
|
30
|
-
lineHeight: 15,
|
|
31
|
-
},
|
|
32
|
-
soldOutBackgroundStyle: {
|
|
33
|
-
backgroundColor: '#B8B8B8',
|
|
34
|
-
},
|
|
35
|
-
soldOutTextStyle: {
|
|
36
|
-
textTransform: 'uppercase',
|
|
37
|
-
},
|
|
38
|
-
productStyle: {
|
|
39
|
-
width: 75,
|
|
40
|
-
height: 75,
|
|
41
|
-
borderRadius: 7.6,
|
|
42
|
-
marginStart: 12
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const [, t] = useLanguage();
|
|
48
|
-
const [stateConfig] = useConfig();
|
|
49
|
-
const [{ parsePrice, optimizeImage }] = useUtils();
|
|
50
|
-
const [orderState] = useOrder();
|
|
51
|
-
|
|
52
|
-
const editMode = typeof product?.code !== 'undefined';
|
|
53
|
-
|
|
54
|
-
const removeToBalance = editMode ? product?.quantity : 0;
|
|
55
|
-
const cart = orderState.carts[`businessId:${businessId}`];
|
|
56
|
-
const productCart = cart?.products?.find(
|
|
57
|
-
(prod: any) => prod.id === product?.id,
|
|
58
|
-
);
|
|
59
|
-
const totalBalance = (productCart?.quantity || 0) - removeToBalance;
|
|
60
|
-
|
|
61
|
-
const maxCartProductConfig =
|
|
62
|
-
(stateConfig.configs.max_product_amount
|
|
63
|
-
? parseInt(stateConfig.configs.max_product_amount)
|
|
64
|
-
: 100) - totalBalance;
|
|
65
|
-
|
|
66
|
-
const productBalance =
|
|
67
|
-
(cart?.products?.reduce(
|
|
68
|
-
(sum: any, _product: any) =>
|
|
69
|
-
sum + (product && _product.id === product?.id ? _product.quantity : 0),
|
|
70
|
-
0,
|
|
71
|
-
) || 0) - removeToBalance;
|
|
72
|
-
let maxCartProductInventory =
|
|
73
|
-
(product?.inventoried ? product?.quantity : undefined) - productBalance;
|
|
74
|
-
maxCartProductInventory = !isNaN(maxCartProductInventory)
|
|
75
|
-
? maxCartProductInventory
|
|
76
|
-
: maxCartProductConfig;
|
|
77
|
-
|
|
78
|
-
const maxProductQuantity = Math.min(
|
|
79
|
-
maxCartProductConfig,
|
|
80
|
-
maxCartProductInventory,
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<CardContainer
|
|
85
|
-
style={[
|
|
86
|
-
styles.container,
|
|
87
|
-
(isSoldOut || maxProductQuantity <= 0) && styles.soldOutBackgroundStyle,
|
|
88
|
-
]}
|
|
89
|
-
onPress={() => onProductClick?.(product)}>
|
|
90
|
-
<CardInfo>
|
|
91
|
-
<OText
|
|
92
|
-
size={12}
|
|
93
|
-
weight={'500'}
|
|
94
|
-
numberOfLines={1}
|
|
95
|
-
ellipsizeMode="tail"
|
|
96
|
-
style={styles.line18}>
|
|
97
|
-
{product?.name}
|
|
98
|
-
</OText>
|
|
99
|
-
<OText size={12} weight={'400'} style={styles.line18} color={theme.colors.textNormal}>
|
|
100
|
-
{parsePrice(product?.price)}
|
|
101
|
-
</OText>
|
|
102
|
-
<OText
|
|
103
|
-
size={10}
|
|
104
|
-
numberOfLines={2}
|
|
105
|
-
ellipsizeMode="tail"
|
|
106
|
-
color={theme.colors.textSecondary}
|
|
107
|
-
style={styles.line15}>
|
|
108
|
-
{product?.description}
|
|
109
|
-
</OText>
|
|
110
|
-
</CardInfo>
|
|
111
|
-
<OIcon
|
|
112
|
-
url={optimizeImage(product?.images, 'h_200,c_limit')}
|
|
113
|
-
style={styles.productStyle}
|
|
114
|
-
/>
|
|
115
|
-
{(isSoldOut || maxProductQuantity <= 0) && (
|
|
116
|
-
<SoldOut>
|
|
117
|
-
<OText size={12} weight="bold" color={theme.colors.textSecondary} style={styles.soldOutTextStyle}>
|
|
118
|
-
{t('SOLD_OUT', 'SOLD OUT')}
|
|
119
|
-
</OText>
|
|
120
|
-
</SoldOut>
|
|
121
|
-
)}
|
|
122
|
-
</CardContainer>
|
|
123
|
-
);
|
|
124
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components/native'
|
|
2
|
-
|
|
3
|
-
export const CardContainer = styled.TouchableOpacity`
|
|
4
|
-
flex: 1;
|
|
5
|
-
flex-direction: row;
|
|
6
|
-
justify-content: space-between;
|
|
7
|
-
align-items: center;
|
|
8
|
-
padding: 12px;
|
|
9
|
-
border-radius: 10px;
|
|
10
|
-
position: relative;
|
|
11
|
-
`
|
|
12
|
-
export const CardInfo = styled.View`
|
|
13
|
-
padding-start: 3px;
|
|
14
|
-
flex: 1;
|
|
15
|
-
`
|
|
16
|
-
export const SoldOut = styled.View`
|
|
17
|
-
position: absolute;
|
|
18
|
-
background: ${(props: any) => props.theme.colors.backgroundGray100} 0% 0% no-repeat padding-box;
|
|
19
|
-
border-radius: 23px;
|
|
20
|
-
padding: 5px 10px;
|
|
21
|
-
top: 37px;
|
|
22
|
-
end: 10px;
|
|
23
|
-
`
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { View, StyleSheet } from 'react-native';
|
|
3
|
-
import { useLanguage } from 'ordering-components/native';
|
|
4
|
-
import { CreditCardInput } from 'react-native-credit-card-input';
|
|
5
|
-
import { StripeCardForm as CardForm } from './naked';
|
|
6
|
-
import { useTheme } from 'styled-components/native';
|
|
7
|
-
import {
|
|
8
|
-
FormStripe,
|
|
9
|
-
FormRow,
|
|
10
|
-
ErrorMessage,
|
|
11
|
-
FormActions
|
|
12
|
-
} from './styles';
|
|
13
|
-
|
|
14
|
-
import { OButton, OText } from '../shared';
|
|
15
|
-
|
|
16
|
-
const StripeCardFormUI = (props: any) => {
|
|
17
|
-
const {
|
|
18
|
-
stateCardForm,
|
|
19
|
-
handleCancel,
|
|
20
|
-
publicKey
|
|
21
|
-
} = props;
|
|
22
|
-
|
|
23
|
-
const theme = useTheme();
|
|
24
|
-
|
|
25
|
-
const { error, loading } = stateCardForm;
|
|
26
|
-
|
|
27
|
-
const [, t] = useLanguage();
|
|
28
|
-
const [cardState, setCardState] = useState<any>(null)
|
|
29
|
-
|
|
30
|
-
const handleChange = (values: any) => setCardState(values);
|
|
31
|
-
|
|
32
|
-
const handleSubmit = () => props.handleSubmit && props.handleSubmit(cardState)
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<FormStripe>
|
|
36
|
-
<FormRow style={{ marginTop: 30 }}>
|
|
37
|
-
<CreditCardInput
|
|
38
|
-
autoFocus
|
|
39
|
-
requiresCVC
|
|
40
|
-
labelStyle={styles.label}
|
|
41
|
-
inputStyle={styles.input}
|
|
42
|
-
validColor={'#000000'}
|
|
43
|
-
invalidColor={theme.colors.cancelColor}
|
|
44
|
-
placeholderColor={theme.colors.backgroundGray}
|
|
45
|
-
onChange={handleChange}
|
|
46
|
-
/>
|
|
47
|
-
<ErrorMessage>
|
|
48
|
-
<OText color={theme.colors.error} style={{ textAlign: 'center' }}>
|
|
49
|
-
{error}
|
|
50
|
-
</OText>
|
|
51
|
-
</ErrorMessage>
|
|
52
|
-
</FormRow>
|
|
53
|
-
<FormActions>
|
|
54
|
-
<View style={{ width: '49%' }}>
|
|
55
|
-
<OButton
|
|
56
|
-
text={t('CANCEL', 'Cancel')}
|
|
57
|
-
bgColor={theme.colors.backgroundGray}
|
|
58
|
-
borderColor={theme.colors.backgroundGray}
|
|
59
|
-
textStyle={{ color: 'white' }}
|
|
60
|
-
imgRightSrc={null}
|
|
61
|
-
onClick={() => handleCancel()}
|
|
62
|
-
/>
|
|
63
|
-
</View>
|
|
64
|
-
<View style={{ width: '49%' }}>
|
|
65
|
-
<OButton
|
|
66
|
-
text={loading ? t('LOADING', 'Loading...') : t('ADD', 'Add')}
|
|
67
|
-
isDisabled={!cardState?.valid || loading}
|
|
68
|
-
bgColor={theme.colors.primary}
|
|
69
|
-
borderColor={theme.colors.primary}
|
|
70
|
-
textStyle={{ color: 'white' }}
|
|
71
|
-
imgRightSrc={null}
|
|
72
|
-
onClick={handleSubmit}
|
|
73
|
-
/>
|
|
74
|
-
</View>
|
|
75
|
-
</FormActions>
|
|
76
|
-
</FormStripe>
|
|
77
|
-
)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const styles = StyleSheet.create({
|
|
81
|
-
label: {
|
|
82
|
-
color: '#000',
|
|
83
|
-
fontSize: 14,
|
|
84
|
-
},
|
|
85
|
-
input: {
|
|
86
|
-
fontSize: 18,
|
|
87
|
-
color: '#000'
|
|
88
|
-
},
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
export const StripeCardForm = (props: any) => {
|
|
92
|
-
const cardFormProps = {
|
|
93
|
-
...props,
|
|
94
|
-
UIComponent: StripeCardFormUI
|
|
95
|
-
}
|
|
96
|
-
return <CardForm {...cardFormProps} />
|
|
97
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { useSession, useApi, useLanguage, useOrder } from 'ordering-components/native';
|
|
3
|
-
// import stripe from 'tipsi-stripe';
|
|
4
|
-
|
|
5
|
-
export const StripeCardForm = (props: any) => {
|
|
6
|
-
const {
|
|
7
|
-
UIComponent,
|
|
8
|
-
toSave,
|
|
9
|
-
onNewCard,
|
|
10
|
-
publicKey,
|
|
11
|
-
requirements,
|
|
12
|
-
handleSource,
|
|
13
|
-
handleCustomSubmit
|
|
14
|
-
} = props;
|
|
15
|
-
|
|
16
|
-
const [{ user }] = useSession();
|
|
17
|
-
const [orderState] = useOrder();
|
|
18
|
-
const [ordering] = useApi();
|
|
19
|
-
const [, t] = useLanguage();
|
|
20
|
-
|
|
21
|
-
// stripe.setOptions({
|
|
22
|
-
// publishableKey: publicKey,
|
|
23
|
-
// // androidPayMode: 'test', // Android only
|
|
24
|
-
// })
|
|
25
|
-
|
|
26
|
-
const [state, setState] = useState<any>({ error: null, loading: false })
|
|
27
|
-
|
|
28
|
-
const stripeTokenHandler = async (tokenId: string, user: any, businessId: string) => {
|
|
29
|
-
try {
|
|
30
|
-
const result = await fetch(`${ordering.root}/payments/stripe/cards`, {
|
|
31
|
-
method: 'POST',
|
|
32
|
-
headers: {
|
|
33
|
-
Authorization: `Bearer ${user?.session?.access_token}`,
|
|
34
|
-
'Content-Type': 'application/json'
|
|
35
|
-
},
|
|
36
|
-
body: JSON.stringify({
|
|
37
|
-
business_id: businessId,
|
|
38
|
-
gateway: 'stripe',
|
|
39
|
-
token_id: tokenId,
|
|
40
|
-
user_id: user?.id
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
const response = await result.json();
|
|
44
|
-
onNewCard && onNewCard(response.result);
|
|
45
|
-
} catch (error) {
|
|
46
|
-
setState({
|
|
47
|
-
...state,
|
|
48
|
-
loading: false,
|
|
49
|
-
error
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const handleSubmit = async (creditCardData: any) => {
|
|
55
|
-
if (handleCustomSubmit) {
|
|
56
|
-
return handleCustomSubmit(creditCardData);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// if (!stripe) {
|
|
60
|
-
// setState({
|
|
61
|
-
// ...state,
|
|
62
|
-
// error: t('STRIPE_LOAD_ERROR', 'Faile to load Stripe properly')
|
|
63
|
-
// })
|
|
64
|
-
// return
|
|
65
|
-
// }
|
|
66
|
-
|
|
67
|
-
setState({ ...state, loading: true });
|
|
68
|
-
|
|
69
|
-
// try {
|
|
70
|
-
// const paymentMethod = await stripe.createPaymentMethod({
|
|
71
|
-
// card: {
|
|
72
|
-
// number : creditCardData.values.number.replace(/ /g, ''),
|
|
73
|
-
// cvc : creditCardData.values.cvc,
|
|
74
|
-
// expMonth : parseInt(creditCardData.values.expiry.split('/')[0], 10),
|
|
75
|
-
// expYear : parseInt(creditCardData.values.expiry.split('/')[1], 10)
|
|
76
|
-
// },
|
|
77
|
-
// billingDetails: {
|
|
78
|
-
// name: `${user.name} ${user.lastname}`,
|
|
79
|
-
// email: user.email,
|
|
80
|
-
// address: {
|
|
81
|
-
// line1: orderState.options.address.address,
|
|
82
|
-
// postalCode: orderState.options.address.zipcode
|
|
83
|
-
// }
|
|
84
|
-
// }
|
|
85
|
-
// });
|
|
86
|
-
// if (paymentMethod?.error) {
|
|
87
|
-
// setState({
|
|
88
|
-
// ...state,
|
|
89
|
-
// loading: false,
|
|
90
|
-
// error: paymentMethod?.error
|
|
91
|
-
// })
|
|
92
|
-
// return
|
|
93
|
-
// }
|
|
94
|
-
// setState({ ...state, loading: false })
|
|
95
|
-
// if (handleSource) {
|
|
96
|
-
// handleSource && handleSource({
|
|
97
|
-
// id: paymentMethod?.id,
|
|
98
|
-
// type: 'card',
|
|
99
|
-
// card: {
|
|
100
|
-
// brand: paymentMethod?.card?.brand,
|
|
101
|
-
// last4: paymentMethod?.card?.last4
|
|
102
|
-
// }
|
|
103
|
-
// })
|
|
104
|
-
// return
|
|
105
|
-
// }
|
|
106
|
-
// toSave && stripeTokenHandler(paymentMethod?.id, user, props.businessId);
|
|
107
|
-
// } catch (e) {
|
|
108
|
-
// setState({
|
|
109
|
-
// ...state,
|
|
110
|
-
// loading: false,
|
|
111
|
-
// error: e?.toString() || e?.message.toString()
|
|
112
|
-
// })
|
|
113
|
-
// }
|
|
114
|
-
setState({ ...state, loading: false });
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
return (
|
|
118
|
-
<UIComponent
|
|
119
|
-
{...props}
|
|
120
|
-
stateCardForm={state}
|
|
121
|
-
handleSubmit={handleSubmit}
|
|
122
|
-
/>
|
|
123
|
-
)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
StripeCardForm.defaultProps = {
|
|
127
|
-
autosave: true
|
|
128
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import styled, { css } from 'styled-components/native';
|
|
2
|
-
|
|
3
|
-
export const FormStripe = styled.ScrollView`
|
|
4
|
-
display: flex;
|
|
5
|
-
flex-direction: column;
|
|
6
|
-
width: 100%;
|
|
7
|
-
flex-grow: 0;
|
|
8
|
-
`
|
|
9
|
-
|
|
10
|
-
export const FormRow = styled.View``
|
|
11
|
-
|
|
12
|
-
export const ErrorMessage = styled.View`
|
|
13
|
-
font-size: 16px;
|
|
14
|
-
font-weight: bold;
|
|
15
|
-
margin-top: 10px;
|
|
16
|
-
/* margin-bottom: 20px; */
|
|
17
|
-
color: #D81212;
|
|
18
|
-
margin: 10px 0px 0px 10px;
|
|
19
|
-
|
|
20
|
-
/* ${(props: any) => props.theme?.rtl && css`
|
|
21
|
-
margin: 10px 10px 0px 0px;
|
|
22
|
-
`} */
|
|
23
|
-
`
|
|
24
|
-
|
|
25
|
-
export const FormActions = styled.View`
|
|
26
|
-
width: 100%;
|
|
27
|
-
display: flex;
|
|
28
|
-
padding: 30px 20px 0px;
|
|
29
|
-
flex-direction: row;
|
|
30
|
-
justify-content: space-between;
|
|
31
|
-
margin-top: 20px;
|
|
32
|
-
`
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { View, StyleSheet, ScrollView } from 'react-native';
|
|
3
|
-
import {
|
|
4
|
-
PaymentOptionStripe,
|
|
5
|
-
useSession,
|
|
6
|
-
useLanguage,
|
|
7
|
-
} from 'ordering-components/native';
|
|
8
|
-
import { PlaceholderLine } from 'rn-placeholder';
|
|
9
|
-
import { useTheme } from 'styled-components/native';
|
|
10
|
-
import { getIconCard } from '../../utils';
|
|
11
|
-
import { OAlert, OIcon, OText } from '../shared';
|
|
12
|
-
|
|
13
|
-
import { NotFoundSource } from '../NotFoundSource';
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
OSItem,
|
|
17
|
-
OSItemContent,
|
|
18
|
-
OSItemActions,
|
|
19
|
-
} from '../PaymentOptionStripe/styles';
|
|
20
|
-
import { TouchableOpacity } from 'react-native-gesture-handler';
|
|
21
|
-
import Icon from 'react-native-vector-icons/Feather';
|
|
22
|
-
|
|
23
|
-
const StripeCardsListUI = (props: any) => {
|
|
24
|
-
const {
|
|
25
|
-
onSelectCard,
|
|
26
|
-
deleteCard,
|
|
27
|
-
cardSelected,
|
|
28
|
-
cardsList,
|
|
29
|
-
handleCardClick,
|
|
30
|
-
} = props;
|
|
31
|
-
|
|
32
|
-
const theme = useTheme();
|
|
33
|
-
|
|
34
|
-
const [{ token }] = useSession();
|
|
35
|
-
const [, t] = useLanguage();
|
|
36
|
-
const [showOption, setShowOption] = useState({id: 0, status: false});
|
|
37
|
-
|
|
38
|
-
const handleCardSelected = (card: any) => {
|
|
39
|
-
handleCardClick(card);
|
|
40
|
-
onSelectCard(card);
|
|
41
|
-
setShowOption({id: showOption.id, status: false});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const handleShowOption = (idx: number) => {
|
|
45
|
-
if (idx == showOption.id) {
|
|
46
|
-
setShowOption({id: idx, status: !showOption.status});
|
|
47
|
-
} else {
|
|
48
|
-
setShowOption({id: idx, status: true});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<>
|
|
54
|
-
{token && !cardsList.loading && cardsList.cards && cardsList.cards.length === 0 && (
|
|
55
|
-
<OSItem style={{ justifyContent: 'center', paddingTop: 0 }}>
|
|
56
|
-
<OText size={22}>
|
|
57
|
-
{t('YOU_DONT_HAVE_CARDS', 'You don\'t have cards')}
|
|
58
|
-
</OText>
|
|
59
|
-
</OSItem>
|
|
60
|
-
)}
|
|
61
|
-
|
|
62
|
-
{token && cardsList.error && cardsList.error.length > 0 && (
|
|
63
|
-
<NotFoundSource
|
|
64
|
-
content={cardsList?.error[0]?.message || cardsList?.error[0]}
|
|
65
|
-
/>
|
|
66
|
-
)}
|
|
67
|
-
|
|
68
|
-
{token && cardsList.loading && (
|
|
69
|
-
<View style={{ width: '100%' }}>
|
|
70
|
-
{[...Array(2)].map((_, i) => (
|
|
71
|
-
<PlaceholderLine
|
|
72
|
-
key={i}
|
|
73
|
-
height={50}
|
|
74
|
-
noMargin
|
|
75
|
-
style={{ marginBottom: 20 }}
|
|
76
|
-
/>
|
|
77
|
-
))}
|
|
78
|
-
</View>
|
|
79
|
-
)}
|
|
80
|
-
|
|
81
|
-
{token && cardsList.cards && cardsList.cards.length > 0 && (
|
|
82
|
-
<ScrollView
|
|
83
|
-
horizontal={false}
|
|
84
|
-
showsVerticalScrollIndicator={false}
|
|
85
|
-
showsHorizontalScrollIndicator={false}
|
|
86
|
-
nestedScrollEnabled={true}
|
|
87
|
-
style={styles.cardsList}
|
|
88
|
-
>
|
|
89
|
-
{cardsList.cards.map((card: any, idx: number) => (
|
|
90
|
-
<OSItem key={card.id} style={{zIndex: 99 - idx}}>
|
|
91
|
-
<OSItemContent onPress={() => {}} style={{justifyContent: 'space-between'}} activeOpacity={0.8}>
|
|
92
|
-
{/* <View style={styles.viewStyle}>
|
|
93
|
-
{card.id === cardSelected?.id ? (
|
|
94
|
-
<OIcon
|
|
95
|
-
src={theme.images.general.radio_act}
|
|
96
|
-
width={16}
|
|
97
|
-
color={theme.colors.primary}
|
|
98
|
-
/>
|
|
99
|
-
) : (
|
|
100
|
-
<OIcon
|
|
101
|
-
src={theme.images.general.radio_nor}
|
|
102
|
-
width={16}
|
|
103
|
-
color={theme.colors.disabled}
|
|
104
|
-
/>
|
|
105
|
-
)}
|
|
106
|
-
</View> */}
|
|
107
|
-
<View style={styles.viewStyle}>
|
|
108
|
-
{getIconCard(card.brand, 20)}
|
|
109
|
-
<OText size={12} style={{textTransform: 'capitalize'}} color={theme.colors.textNormal} mLeft={10} mRight={10}>
|
|
110
|
-
{`${card.brand} ${card.last4}`}
|
|
111
|
-
</OText>
|
|
112
|
-
</View>
|
|
113
|
-
{card.id === cardSelected?.id &&
|
|
114
|
-
<OText size={10} weight={'bold'}>{t('DEFAULT', 'Default')}</OText>
|
|
115
|
-
}
|
|
116
|
-
</OSItemContent>
|
|
117
|
-
<OSItemActions>
|
|
118
|
-
<TouchableOpacity onPress={() => handleShowOption(idx)}>
|
|
119
|
-
<Icon
|
|
120
|
-
name='more-vertical'
|
|
121
|
-
color={theme.colors.textPrimary}
|
|
122
|
-
size={16}
|
|
123
|
-
/>
|
|
124
|
-
</TouchableOpacity>
|
|
125
|
-
{showOption.status && showOption.id === idx &&
|
|
126
|
-
<View style={styles.optWrap}>
|
|
127
|
-
<TouchableOpacity onPress={() => handleCardSelected(card)} style={{paddingBottom: 4}}>
|
|
128
|
-
<OText size={10} lineHeight={15}>{t('USE_AS_DEFAULT', 'Use as default')}</OText>
|
|
129
|
-
</TouchableOpacity>
|
|
130
|
-
<OAlert
|
|
131
|
-
title={t('CARD', 'Card')}
|
|
132
|
-
message={t('QUESTION_DELETE_CARD', 'Are you sure that you want to delete the card?')}
|
|
133
|
-
onAccept={() =>{ deleteCard(card); setShowOption({id: idx, status: false}) }}
|
|
134
|
-
>
|
|
135
|
-
<OText size={10} lineHeight={15} color={theme.colors.red}>{t('DELETE', 'Delete')}</OText>
|
|
136
|
-
</OAlert>
|
|
137
|
-
</View>
|
|
138
|
-
}
|
|
139
|
-
</OSItemActions>
|
|
140
|
-
</OSItem>
|
|
141
|
-
))}
|
|
142
|
-
</ScrollView>
|
|
143
|
-
)}
|
|
144
|
-
</>
|
|
145
|
-
)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const styles = StyleSheet.create({
|
|
149
|
-
viewStyle: {
|
|
150
|
-
marginRight: 7,
|
|
151
|
-
flexDirection: 'row',
|
|
152
|
-
alignItems: 'center'
|
|
153
|
-
},
|
|
154
|
-
cardsList: {
|
|
155
|
-
width: '100%',
|
|
156
|
-
maxHeight: 130
|
|
157
|
-
},
|
|
158
|
-
optWrap: {
|
|
159
|
-
position: 'absolute',
|
|
160
|
-
end: 4,
|
|
161
|
-
top: 20,
|
|
162
|
-
minWidth: 100,
|
|
163
|
-
backgroundColor: 'white',
|
|
164
|
-
paddingHorizontal: 12,
|
|
165
|
-
paddingVertical: 7,
|
|
166
|
-
borderRadius: 7.6,
|
|
167
|
-
shadowColor: '#000000',
|
|
168
|
-
shadowOffset: {width: 0, height: 1},
|
|
169
|
-
shadowRadius: 2,
|
|
170
|
-
shadowOpacity: 0.2,
|
|
171
|
-
}
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
export const StripeCardsList = (props: any) => {
|
|
175
|
-
const stripeCardsListProps = {
|
|
176
|
-
...props,
|
|
177
|
-
UIComponent: StripeCardsListUI
|
|
178
|
-
}
|
|
179
|
-
return (
|
|
180
|
-
<PaymentOptionStripe {...stripeCardsListProps} />
|
|
181
|
-
)
|
|
182
|
-
}
|