ordering-ui-react-native 0.12.54 → 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/src/components/Cart/index.tsx +50 -16
- package/src/components/OrderDetails/index.tsx +8 -0
- package/src/components/OrderSummary/index.tsx +38 -3
- package/src/layouts/Container.tsx +1 -1
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +8 -0
- package/themes/business/src/components/OrderDetails/styles.tsx +1 -0
- package/themes/business/src/layouts/Container.tsx +3 -1
- package/themes/doordash/src/components/Cart/index.tsx +36 -2
- package/themes/doordash/src/components/OrderDetails/index.tsx +8 -0
- package/themes/doordash/src/components/OrderSummary/index.tsx +36 -3
- package/themes/doordash/src/layouts/Container.tsx +1 -1
- package/themes/instacart/src/components/Cart/index.tsx +37 -3
- package/themes/instacart/src/components/OrderDetails/index.tsx +8 -0
- package/themes/instacart/src/components/OrderSummary/index.tsx +37 -4
- package/themes/instacart/src/layouts/Container.tsx +1 -1
- package/themes/kiosk/src/layouts/Container.tsx +2 -1
- package/themes/original/src/components/Cart/index.tsx +268 -234
- package/themes/original/src/components/OrderDetails/index.tsx +723 -715
- package/themes/original/src/components/OrderSummary/index.tsx +37 -3
- package/themes/original/src/layouts/Container.tsx +1 -1
- package/themes/single-business/src/components/Cart/index.tsx +92 -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/PhoneInputNumber/index.tsx +103 -112
- package/themes/single-business/src/components/UserDetails/index.tsx +107 -111
- package/themes/single-business/src/components/UserDetails/styles.tsx +3 -8
- package/themes/single-business/src/components/UserFormDetails/index.tsx +279 -326
- package/themes/single-business/src/components/UserFormDetails/styles.tsx +7 -5
- package/themes/single-business/src/layouts/Container.tsx +1 -1
- package/themes/uber-eats/src/components/Cart/index.tsx +37 -3
- package/themes/uber-eats/src/components/OrderDetails/index.tsx +8 -0
- package/themes/uber-eats/src/components/OrderSummary/index.tsx +40 -6
- package/themes/uber-eats/src/layouts/Container.tsx +1 -1
- 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 -298
- 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 -820
- package/themes/franchises/src/components/OrderDetails/styles.tsx +0 -120
- package/themes/franchises/src/components/OrderSummary/index.tsx +0 -232
- 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,351 +1,304 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { StyleSheet, View } from 'react-native';
|
|
3
3
|
import { useSession, useLanguage, ToastType, useToast } from 'ordering-components/native';
|
|
4
|
-
import { useTheme } from 'styled-components/native';
|
|
5
4
|
import { useForm, Controller } from 'react-hook-form';
|
|
6
5
|
|
|
7
|
-
import { UDForm, UDLoader, UDWrapper, WrapperPhone } from './styles';
|
|
6
|
+
import { UDForm, UDLoader, UDWrapper, WrapperPhone, EditButton } from './styles';
|
|
8
7
|
|
|
9
8
|
import { OText, OButton, OInput } from '../shared';
|
|
10
9
|
|
|
11
|
-
import { PhoneInputNumber } from '../PhoneInputNumber'
|
|
10
|
+
import { PhoneInputNumber } from '../PhoneInputNumber'
|
|
12
11
|
import { sortInputFields } from '../../utils';
|
|
12
|
+
import { useTheme } from 'styled-components/native';
|
|
13
13
|
|
|
14
14
|
export const UserFormDetailsUI = (props: any) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const theme = useTheme();
|
|
15
|
+
const {
|
|
16
|
+
isEdit,
|
|
17
|
+
formState,
|
|
18
|
+
showField,
|
|
19
|
+
cleanFormState,
|
|
20
|
+
onCloseProfile,
|
|
21
|
+
isRequiredField,
|
|
22
|
+
validationFields,
|
|
23
|
+
handleChangeInput,
|
|
24
|
+
handleButtonUpdateClick,
|
|
25
|
+
phoneUpdate,
|
|
26
|
+
handleCancelEdit,
|
|
27
|
+
isCheckout
|
|
28
|
+
} = props
|
|
30
29
|
|
|
30
|
+
const theme = useTheme()
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
borderWidth: 0,
|
|
57
|
-
fontSize: 12,
|
|
58
|
-
paddingStart: 0,
|
|
59
|
-
paddingBottom: 0,
|
|
60
|
-
marginBottom: -0,
|
|
61
|
-
}
|
|
62
|
-
});
|
|
32
|
+
const styles = StyleSheet.create({
|
|
33
|
+
btnOutline: {
|
|
34
|
+
backgroundColor: '#FFF',
|
|
35
|
+
color: theme.colors.primary
|
|
36
|
+
},
|
|
37
|
+
inputStyle: {
|
|
38
|
+
marginBottom: 25,
|
|
39
|
+
borderWidth: 1,
|
|
40
|
+
borderColor: theme.colors.border,
|
|
41
|
+
borderRadius: 8,
|
|
42
|
+
},
|
|
43
|
+
editButton: {
|
|
44
|
+
// flex:0,
|
|
45
|
+
borderRadius: 8,
|
|
46
|
+
borderColor: theme.colors.primary,
|
|
47
|
+
backgroundColor: theme.colors.white,
|
|
48
|
+
borderWidth: 1,
|
|
49
|
+
color: theme.colors.primary,
|
|
50
|
+
// width: 100,
|
|
51
|
+
// height: 50,
|
|
52
|
+
marginVertical: 8,
|
|
53
|
+
// flex: 1,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
63
56
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
const [, t] = useLanguage();
|
|
58
|
+
const [, { showToast }] = useToast();
|
|
59
|
+
const { handleSubmit, control, errors, setValue } = useForm();
|
|
67
60
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
61
|
+
const [{ user }] = useSession()
|
|
62
|
+
const [userPhoneNumber, setUserPhoneNumber] = useState<any>(null)
|
|
63
|
+
const [phoneInputData, setPhoneInputData] = useState({
|
|
64
|
+
error: '',
|
|
65
|
+
phone: {
|
|
66
|
+
country_phone_code: null,
|
|
67
|
+
cellphone: null
|
|
68
|
+
}
|
|
69
|
+
});
|
|
77
70
|
|
|
78
|
-
|
|
79
|
-
validationFields?.fields?.checkout?.cellphone?.enabled ?? false;
|
|
71
|
+
const showInputPhoneNumber = validationFields?.fields?.checkout?.cellphone?.enabled ?? false
|
|
80
72
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
),
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
return rules;
|
|
100
|
-
};
|
|
73
|
+
const getInputRules = (field: any) => {
|
|
74
|
+
const rules: any = {
|
|
75
|
+
required: isRequiredField(field.code)
|
|
76
|
+
? t(`VALIDATION_ERROR_${field.code.toUpperCase()}_REQUIRED`, `${field.name} is required`)
|
|
77
|
+
.replace('_attribute_', t(field.name, field.code))
|
|
78
|
+
: null
|
|
79
|
+
}
|
|
80
|
+
if (field.code && field.code === 'email') {
|
|
81
|
+
rules.pattern = {
|
|
82
|
+
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
|
|
83
|
+
message: t('INVALID_ERROR_EMAIL', 'Invalid email address').replace('_attribute_', t('EMAIL', 'Email'))
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return rules
|
|
87
|
+
}
|
|
101
88
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
89
|
+
const setUserCellPhone = (isEdit = false) => {
|
|
90
|
+
if (userPhoneNumber && !userPhoneNumber.includes('null') && !isEdit) {
|
|
91
|
+
setUserPhoneNumber(userPhoneNumber)
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
if (user?.cellphone) {
|
|
95
|
+
let phone = null
|
|
96
|
+
if (user?.country_phone_code) {
|
|
97
|
+
phone = `+${user?.country_phone_code} ${user?.cellphone}`
|
|
98
|
+
} else {
|
|
99
|
+
phone = user?.cellphone
|
|
100
|
+
}
|
|
101
|
+
setUserPhoneNumber(phone)
|
|
102
|
+
setPhoneInputData({
|
|
103
|
+
...phoneInputData,
|
|
104
|
+
phone: {
|
|
105
|
+
country_phone_code: user?.country_phone_code || null,
|
|
106
|
+
cellphone: user?.cellphone || null
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
setUserPhoneNumber(user?.cellphone || '')
|
|
112
|
+
}
|
|
126
113
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
handleButtonUpdateClick(changes);
|
|
155
|
-
}
|
|
156
|
-
};
|
|
114
|
+
const onSubmit = () => {
|
|
115
|
+
if (phoneInputData.error) {
|
|
116
|
+
showToast(ToastType.Error, phoneInputData.error)
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
if (Object.keys(formState.changes).length > 0) {
|
|
120
|
+
if (
|
|
121
|
+
formState.changes?.cellphone === null &&
|
|
122
|
+
validationFields?.fields?.checkout?.cellphone?.enabled &&
|
|
123
|
+
validationFields?.fields?.checkout?.cellphone?.required
|
|
124
|
+
) {
|
|
125
|
+
showToast(
|
|
126
|
+
ToastType.Error,
|
|
127
|
+
t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Phone Number is required.')
|
|
128
|
+
);
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
let changes = null
|
|
132
|
+
if (user?.cellphone && !userPhoneNumber) {
|
|
133
|
+
changes = {
|
|
134
|
+
country_phone_code: '',
|
|
135
|
+
cellphone: ''
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
handleButtonUpdateClick(changes)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
157
141
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
142
|
+
const handleChangePhoneNumber = (number: any) => {
|
|
143
|
+
setPhoneInputData(number)
|
|
144
|
+
let phoneNumber = {
|
|
145
|
+
country_phone_code: {
|
|
146
|
+
name: 'country_phone_code',
|
|
147
|
+
value: number.phone.country_phone_code
|
|
148
|
+
},
|
|
149
|
+
cellphone: {
|
|
150
|
+
name: 'cellphone',
|
|
151
|
+
value: number.phone.cellphone
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
handleChangeInput(phoneNumber, true)
|
|
155
|
+
}
|
|
172
156
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}, [errors]);
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
if (Object.keys(errors).length > 0) {
|
|
159
|
+
const list = Object.values(errors)
|
|
160
|
+
if (phoneInputData.error) {
|
|
161
|
+
list.push({ message: phoneInputData.error })
|
|
162
|
+
}
|
|
163
|
+
let stringError = ''
|
|
164
|
+
list.map((item: any, i: number) => {
|
|
165
|
+
stringError += (i + 1) === list.length ? `- ${item.message}` : `- ${item.message}\n`
|
|
166
|
+
})
|
|
167
|
+
showToast(ToastType.Error, stringError)
|
|
168
|
+
}
|
|
169
|
+
}, [errors])
|
|
187
170
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
171
|
+
useEffect(() => {
|
|
172
|
+
if ((!formState?.loading && formState?.result?.error)) {
|
|
173
|
+
formState.result?.result && showToast(
|
|
174
|
+
ToastType.Error,
|
|
175
|
+
formState.result?.result[0]
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
}, [formState?.loading])
|
|
194
179
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
field.code !== 'email'
|
|
248
|
-
? setValue(field.code, val.target.value)
|
|
249
|
-
: setValue(
|
|
250
|
-
field.code,
|
|
251
|
-
val.target.value
|
|
252
|
-
.toLowerCase()
|
|
253
|
-
.replace(
|
|
254
|
-
/[&,()%";:ç?<>{}\\[\]\s]/g,
|
|
255
|
-
'',
|
|
256
|
-
),
|
|
257
|
-
);
|
|
258
|
-
field.code !== 'email'
|
|
259
|
-
? handleChangeInput(val)
|
|
260
|
-
: handleChangeInput({
|
|
261
|
-
target: {
|
|
262
|
-
name: 'email',
|
|
263
|
-
value: val.target.value
|
|
264
|
-
.toLowerCase()
|
|
265
|
-
.replace(
|
|
266
|
-
/[&,()%";:ç?<>{}\\[\]\s]/g,
|
|
267
|
-
'',
|
|
268
|
-
),
|
|
269
|
-
},
|
|
270
|
-
});
|
|
271
|
-
}}
|
|
272
|
-
autoCorrect={field.code === 'email' && false}
|
|
273
|
-
type={
|
|
274
|
-
field.code === 'email'
|
|
275
|
-
? 'email-address'
|
|
276
|
-
: 'default'
|
|
277
|
-
}
|
|
278
|
-
returnKeyType="done"
|
|
279
|
-
autoCompleteType={
|
|
280
|
-
field.code === 'email' ? 'email' : 'off'
|
|
281
|
-
}
|
|
282
|
-
/>
|
|
283
|
-
</>
|
|
284
|
-
)}
|
|
285
|
-
name={field.code}
|
|
286
|
-
rules={getInputRules(field)}
|
|
287
|
-
defaultValue={user && user[field.code]}
|
|
288
|
-
/>
|
|
289
|
-
</React.Fragment>
|
|
290
|
-
),
|
|
291
|
-
)}
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
if (!isEdit && onCloseProfile) {
|
|
182
|
+
onCloseProfile()
|
|
183
|
+
}
|
|
184
|
+
if ((user || !isEdit) && !formState?.loading) {
|
|
185
|
+
setUserCellPhone()
|
|
186
|
+
if (!isEdit && !formState?.loading) {
|
|
187
|
+
cleanFormState && cleanFormState({ changes: {} })
|
|
188
|
+
setUserCellPhone(true)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}, [user, isEdit])
|
|
192
|
+
return (
|
|
193
|
+
<>
|
|
194
|
+
<UDForm>
|
|
195
|
+
{!validationFields?.loading &&
|
|
196
|
+
sortInputFields({ values: validationFields?.fields?.checkout }).length > 0 &&
|
|
197
|
+
(
|
|
198
|
+
<UDWrapper>
|
|
199
|
+
{sortInputFields({ values: validationFields.fields?.checkout }).map((field: any) =>
|
|
200
|
+
(
|
|
201
|
+
showField && showField(field.code) && (
|
|
202
|
+
<React.Fragment key={field.id}>
|
|
203
|
+
<Controller
|
|
204
|
+
key={field.id}
|
|
205
|
+
control={control}
|
|
206
|
+
render={() => (
|
|
207
|
+
<OInput
|
|
208
|
+
name={field.code}
|
|
209
|
+
placeholder={t(field.code.toUpperCase(), field?.name)}
|
|
210
|
+
style={styles.inputStyle}
|
|
211
|
+
icon={field.code === 'email' ? theme.images.general.email : theme.images.general.user}
|
|
212
|
+
autoCapitalize={field.code === 'email' ? 'none' : 'sentences'}
|
|
213
|
+
isDisabled={!isEdit}
|
|
214
|
+
value={formState?.changes[field.code] ?? (user && user[field.code]) ?? ''}
|
|
215
|
+
onChange={(val: any) => {
|
|
216
|
+
field.code !== 'email' ? setValue(field.code, val.target.value) : setValue(field.code, val.target.value.toLowerCase().replace(/[&,()%";:ç?<>{}\\[\]\s]/g, ''))
|
|
217
|
+
field.code !== 'email' ? handleChangeInput(val) : handleChangeInput({ target: { name: 'email', value: val.target.value.toLowerCase().replace(/[&,()%";:ç?<>{}\\[\]\s]/g, '') } })
|
|
218
|
+
}}
|
|
219
|
+
autoCorrect={field.code === 'email' && false}
|
|
220
|
+
type={field.code === 'email' ? 'email-address' : 'default'}
|
|
221
|
+
returnKeyType='done'
|
|
222
|
+
autoCompleteType={field.code === 'email' ? 'email' : 'off'}
|
|
223
|
+
/>
|
|
224
|
+
)}
|
|
225
|
+
name={field.code}
|
|
226
|
+
rules={getInputRules(field)}
|
|
227
|
+
defaultValue={user && user[field.code]}
|
|
228
|
+
/>
|
|
229
|
+
</React.Fragment>
|
|
230
|
+
)
|
|
231
|
+
))}
|
|
292
232
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
{phoneUpdate && (
|
|
307
|
-
<OText
|
|
308
|
-
size={10}
|
|
309
|
-
color={theme.colors.error}
|
|
310
|
-
style={{ marginHorizontal: 10, textAlign: 'center' }}>
|
|
311
|
-
{t('YOUR_PREVIOUS_CELLPHONE', 'Your previous cellphone')}:{' '}
|
|
312
|
-
{user?.cellphone}
|
|
313
|
-
</OText>
|
|
314
|
-
)}
|
|
315
|
-
</WrapperPhone>
|
|
316
|
-
)}
|
|
317
|
-
</UDWrapper>
|
|
318
|
-
)}
|
|
319
|
-
{validationFields?.loading && (
|
|
320
|
-
<UDLoader>
|
|
321
|
-
<OText size={12}>{t('LOADING', 'Loading')}</OText>
|
|
322
|
-
</UDLoader>
|
|
323
|
-
)}
|
|
324
|
-
</UDForm>
|
|
325
|
-
{!hideUpdateButton && (
|
|
326
|
-
<>
|
|
327
|
-
{((formState &&
|
|
328
|
-
Object.keys(formState?.changes).length > 0 &&
|
|
329
|
-
isEdit) ||
|
|
330
|
-
formState?.loading) && (
|
|
331
|
-
<OButton
|
|
332
|
-
text={
|
|
333
|
-
formState.loading
|
|
334
|
-
? t('UPDATING', 'Updating...')
|
|
335
|
-
: t('UPDATE', 'Update')
|
|
336
|
-
}
|
|
337
|
-
bgColor={theme.colors.white}
|
|
338
|
-
textStyle={{ color: theme.colors.primary, fontSize: 14 }}
|
|
339
|
-
borderColor={theme.colors.primary}
|
|
340
|
-
isDisabled={formState.loading}
|
|
341
|
-
imgRightSrc={null}
|
|
342
|
-
style={{ borderRadius: 7.6, shadowOpacity: 0, width: '100%', borderWidth: 1, marginTop: 20 }}
|
|
343
|
-
onClick={handleSubmit(onSubmit)}
|
|
344
|
-
/>
|
|
345
|
-
)}
|
|
346
|
-
</>
|
|
347
|
-
)}
|
|
348
|
-
</>
|
|
349
|
-
);
|
|
350
|
-
};
|
|
233
|
+
{!!showInputPhoneNumber && (
|
|
234
|
+
<WrapperPhone>
|
|
235
|
+
<PhoneInputNumber
|
|
236
|
+
data={phoneInputData}
|
|
237
|
+
handleData={(val: any) => handleChangePhoneNumber(val)}
|
|
238
|
+
defaultValue={phoneUpdate ? '' : user?.cellphone}
|
|
239
|
+
defaultCode={user?.country_phone_code || null}
|
|
240
|
+
/>
|
|
241
|
+
{phoneUpdate && (
|
|
242
|
+
<OText color={theme.colors.error} style={{ marginHorizontal: 10, textAlign: 'center' }}>{t('YOUR_PREVIOUS_CELLPHONE', 'Your previous cellphone')}: {user?.cellphone}</OText>
|
|
243
|
+
)}
|
|
244
|
+
</WrapperPhone>
|
|
245
|
+
)}
|
|
351
246
|
|
|
247
|
+
</UDWrapper>
|
|
248
|
+
)}
|
|
249
|
+
{validationFields?.loading && (
|
|
250
|
+
<UDLoader>
|
|
251
|
+
<OText size={20}>
|
|
252
|
+
{t('LOADING', 'Loading')}
|
|
253
|
+
</OText>
|
|
254
|
+
</UDLoader>
|
|
255
|
+
)}
|
|
256
|
+
</UDForm>
|
|
257
|
+
<>
|
|
258
|
+
{!validationFields.loading && !isCheckout && (
|
|
259
|
+
<EditButton>
|
|
260
|
+
<View style={{ flex: 1 }}>
|
|
261
|
+
<OButton
|
|
262
|
+
text={t('CANCEL', 'Cancel')}
|
|
263
|
+
bgColor={theme.colors.white}
|
|
264
|
+
borderColor={theme.colors.primary}
|
|
265
|
+
isDisabled={formState.loading}
|
|
266
|
+
imgRightSrc={null}
|
|
267
|
+
style={{ ...styles.editButton }}
|
|
268
|
+
onClick={handleCancelEdit}
|
|
269
|
+
/>
|
|
270
|
+
</View>
|
|
271
|
+
{((formState &&
|
|
272
|
+
Object.keys(formState?.changes).length > 0 && isEdit) || formState?.loading) &&
|
|
273
|
+
(
|
|
274
|
+
<View style={{ flex: 1, marginLeft: 5 }}>
|
|
275
|
+
<OButton
|
|
276
|
+
text={formState.loading ? t('UPDATING', 'Updating...') : t('UPDATE', 'Update')}
|
|
277
|
+
bgColor={theme.colors.primary}
|
|
278
|
+
textStyle={{ color: formState.loading ? 'black' : 'white' }}
|
|
279
|
+
borderColor={theme.colors.primary}
|
|
280
|
+
isDisabled={formState.loading}
|
|
281
|
+
imgRightSrc={null}
|
|
282
|
+
style={{ ...styles.editButton }}
|
|
283
|
+
onClick={handleSubmit(onSubmit)}
|
|
284
|
+
/>
|
|
285
|
+
</View>
|
|
286
|
+
)}
|
|
287
|
+
</EditButton>
|
|
288
|
+
)}
|
|
289
|
+
{((formState && Object.keys(formState?.changes).length > 0 && isEdit) || formState?.loading) && isCheckout && (
|
|
290
|
+
<OButton
|
|
291
|
+
text={formState.loading ? t('UPDATING', 'Updating...') : t('UPDATE', 'Update')}
|
|
292
|
+
bgColor={theme.colors.primary}
|
|
293
|
+
textStyle={{ color: 'white' }}
|
|
294
|
+
style={{ borderRadius: 8 }}
|
|
295
|
+
borderColor={theme.colors.primary}
|
|
296
|
+
isDisabled={formState.loading}
|
|
297
|
+
imgRightSrc={null}
|
|
298
|
+
onClick={handleSubmit(onSubmit)}
|
|
299
|
+
/>
|
|
300
|
+
)}
|
|
301
|
+
</>
|
|
302
|
+
</>
|
|
303
|
+
)
|
|
304
|
+
}
|
|
@@ -5,7 +5,6 @@ export const UDForm = styled.View`
|
|
|
5
5
|
align-items: center;
|
|
6
6
|
flex-direction: column;
|
|
7
7
|
width: 100%;
|
|
8
|
-
margin-top: 20px;
|
|
9
8
|
`
|
|
10
9
|
|
|
11
10
|
export const UDWrapper = styled.View`
|
|
@@ -14,7 +13,6 @@ export const UDWrapper = styled.View`
|
|
|
14
13
|
flex-direction: column;
|
|
15
14
|
width: 100%;
|
|
16
15
|
margin-top: 20px;
|
|
17
|
-
padding-bottom: 50px;
|
|
18
16
|
`
|
|
19
17
|
|
|
20
18
|
export const UDLoader = styled.View`
|
|
@@ -29,7 +27,11 @@ export const UDLoader = styled.View`
|
|
|
29
27
|
|
|
30
28
|
export const WrapperPhone = styled.View`
|
|
31
29
|
margin-bottom: 25px;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
`
|
|
31
|
+
|
|
32
|
+
export const EditButton = styled.View`
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
flex-direction: row;
|
|
36
|
+
flex: 1;
|
|
35
37
|
`
|
|
@@ -15,7 +15,7 @@ const SafeAreaStyled = styled.SafeAreaView`
|
|
|
15
15
|
export const Container = (props: any) => {
|
|
16
16
|
return (
|
|
17
17
|
<SafeAreaStyled>
|
|
18
|
-
<ContainerStyled keyboardShouldPersistTaps='handled' {
|
|
18
|
+
<ContainerStyled {...props} keyboardShouldPersistTaps='handled' ref={props?.forwardRef} style={{...props.style}}>
|
|
19
19
|
{props.children}
|
|
20
20
|
</ContainerStyled>
|
|
21
21
|
</SafeAreaStyled>
|