ordering-ui-react-native 0.12.14 → 0.12.18
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/AddressList/index.tsx +3 -1
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +168 -156
- package/themes/business/src/components/NewOrderNotification/index.tsx +14 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +3 -1
- package/themes/business/src/components/OrdersOption/index.tsx +19 -15
- package/themes/business/src/components 2/AcceptOrRejectOrder/index.tsx +389 -0
- package/themes/business/src/components 2/AcceptOrRejectOrder/styles.tsx +36 -0
- package/themes/business/src/components 2/BusinessController/index.tsx +155 -0
- package/themes/business/src/components 2/BusinessController/styles.tsx +19 -0
- package/themes/business/src/components 2/Chat/index.tsx +1152 -0
- package/themes/business/src/components 2/Chat/styles.tsx +12 -0
- package/themes/business/src/components 2/Contacts/index.tsx +299 -0
- package/themes/business/src/components 2/Contacts/styles.tsx +42 -0
- package/themes/business/src/components 2/DriverMap/index.tsx +525 -0
- package/themes/business/src/components 2/FloatingButton/index.tsx +141 -0
- package/themes/business/src/components 2/FloatingButton/styles.tsx +35 -0
- package/themes/business/src/components 2/ForgotPasswordForm/index.tsx +204 -0
- package/themes/business/src/components 2/ForgotPasswordForm/styles.tsx +11 -0
- package/themes/business/src/components 2/GoogleMap/index.tsx +347 -0
- package/themes/business/src/components 2/Home/index.tsx +111 -0
- package/themes/business/src/components 2/Home/styles.tsx +27 -0
- package/themes/business/src/components 2/LanguageSelector/index.tsx +124 -0
- package/themes/business/src/components 2/LanguageSelector/lang_country.json +152 -0
- package/themes/business/src/components 2/LanguageSelector/styles.tsx +17 -0
- package/themes/business/src/components 2/LoginForm/index.tsx +663 -0
- package/themes/business/src/components 2/LoginForm/styles.tsx +48 -0
- package/themes/business/src/components 2/LogoutButton/index.tsx +63 -0
- package/themes/business/src/components 2/MapView/index.tsx +317 -0
- package/themes/business/src/components 2/MessagesOption/index.tsx +337 -0
- package/themes/business/src/components 2/MessagesOption/styles.tsx +27 -0
- package/themes/business/src/components 2/NewOrderNotification/index.tsx +167 -0
- package/themes/business/src/components 2/NewOrderNotification/styles.tsx +8 -0
- package/themes/business/src/components 2/NotFoundSource/index.tsx +52 -0
- package/themes/business/src/components 2/NotFoundSource/styles.tsx +17 -0
- package/themes/business/src/components 2/OrderDetails/Business.tsx +683 -0
- package/themes/business/src/components 2/OrderDetails/Delivery.tsx +454 -0
- package/themes/business/src/components 2/OrderDetails/OrderContentComponent.tsx +391 -0
- package/themes/business/src/components 2/OrderDetails/OrderHeaderComponent.tsx +148 -0
- package/themes/business/src/components 2/OrderDetails/styles.tsx +84 -0
- package/themes/business/src/components 2/OrderMessage/index.tsx +344 -0
- package/themes/business/src/components 2/OrderMessage/styles.tsx +5 -0
- package/themes/business/src/components 2/OrderSummary/index.tsx +700 -0
- package/themes/business/src/components 2/OrderSummary/styles.tsx +61 -0
- package/themes/business/src/components 2/OrdersOption/index.tsx +755 -0
- package/themes/business/src/components 2/OrdersOption/styles.tsx +54 -0
- package/themes/business/src/components 2/OrdersOptionBusiness/index.tsx +51 -0
- package/themes/business/src/components 2/OrdersOptionBusiness/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionCity/index.tsx +52 -0
- package/themes/business/src/components 2/OrdersOptionCity/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionDate/index.tsx +52 -0
- package/themes/business/src/components 2/OrdersOptionDate/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionDelivery/index.tsx +35 -0
- package/themes/business/src/components 2/OrdersOptionDelivery/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionDriver/index.tsx +50 -0
- package/themes/business/src/components 2/OrdersOptionDriver/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionPaymethod/index.tsx +49 -0
- package/themes/business/src/components 2/OrdersOptionPaymethod/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionStatus/index.tsx +46 -0
- package/themes/business/src/components 2/OrdersOptionStatus/styles.tsx +8 -0
- package/themes/business/src/components 2/PhoneInputNumber/index.tsx +160 -0
- package/themes/business/src/components 2/PhoneInputNumber/styles.tsx +3 -0
- package/themes/business/src/components 2/PreviousMessages/index.tsx +304 -0
- package/themes/business/src/components 2/PreviousMessages/styles.tsx +32 -0
- package/themes/business/src/components 2/PreviousOrders/index.tsx +180 -0
- package/themes/business/src/components 2/PreviousOrders/styles.tsx +38 -0
- package/themes/business/src/components 2/ProductItemAccordion/index.tsx +301 -0
- package/themes/business/src/components 2/ProductItemAccordion/styles.tsx +61 -0
- package/themes/business/src/components 2/SearchBar/index.tsx +112 -0
- package/themes/business/src/components 2/SignupForm/index.tsx +530 -0
- package/themes/business/src/components 2/SignupForm/styles.tsx +16 -0
- package/themes/business/src/components 2/StoresList/index.tsx +208 -0
- package/themes/business/src/components 2/StoresList/styles.tsx +26 -0
- package/themes/business/src/components 2/UserFormDetails/index.tsx +513 -0
- package/themes/business/src/components 2/UserFormDetails/styles.tsx +40 -0
- package/themes/business/src/components 2/UserProfileForm/index.tsx +496 -0
- package/themes/business/src/components 2/UserProfileForm/styles.tsx +36 -0
- package/themes/business/src/components 2/VerifyPhone/index.tsx +201 -0
- package/themes/business/src/components 2/VerifyPhone/styles.tsx +43 -0
- package/themes/business/src/components 2/shared/OAlert.tsx +52 -0
- package/themes/business/src/components 2/shared/OButton.tsx +149 -0
- package/themes/business/src/components 2/shared/OChatBubble.tsx +100 -0
- package/themes/business/src/components 2/shared/ODropDown.tsx +195 -0
- package/themes/business/src/components 2/shared/ODropDownCalendar.tsx +328 -0
- package/themes/business/src/components 2/shared/OFab.tsx +54 -0
- package/themes/business/src/components 2/shared/OIcon.tsx +67 -0
- package/themes/business/src/components 2/shared/OIconButton.tsx +127 -0
- package/themes/business/src/components 2/shared/OInput.tsx +144 -0
- package/themes/business/src/components 2/shared/OLink.tsx +76 -0
- package/themes/business/src/components 2/shared/OModal.tsx +275 -0
- package/themes/business/src/components 2/shared/OSegment.tsx +86 -0
- package/themes/business/src/components 2/shared/OText.tsx +55 -0
- package/themes/business/src/components 2/shared/OTextarea.tsx +46 -0
- package/themes/business/src/components 2/shared/OToast.tsx +92 -0
- package/themes/business/src/components 2/shared/index.tsx +27 -0
- package/themes/business/src/types/index.tsx +4 -1
- package/themes/kiosk/src/components/CategoriesMenu/index.tsx +128 -83
- package/themes/kiosk/src/components/DrawerView/index.tsx +57 -0
- package/themes/kiosk/src/components/DrawerView/styles.tsx +30 -0
- package/themes/kiosk/src/components/LanguageSelector/index.tsx +78 -58
- package/themes/kiosk/src/components/OrderDetails/index.tsx +3 -1
- package/themes/kiosk/src/components/ProductForm/index.tsx +129 -127
- package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
- package/themes/original/src/components/BusinessesListing/index.tsx +9 -6
- package/themes/original/src/components/OrderProgress/index.tsx +32 -18
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import { useForm, Controller } from 'react-hook-form';
|
|
4
|
+
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
|
5
|
+
import { useTheme } from 'styled-components/native';
|
|
6
|
+
import {
|
|
7
|
+
useSession,
|
|
8
|
+
useLanguage,
|
|
9
|
+
ToastType,
|
|
10
|
+
useToast,
|
|
11
|
+
} from 'ordering-components/native';
|
|
12
|
+
import {
|
|
13
|
+
UDForm,
|
|
14
|
+
UDLoader,
|
|
15
|
+
UDWrapper,
|
|
16
|
+
WrapperPhone,
|
|
17
|
+
EditButton,
|
|
18
|
+
} from './styles';
|
|
19
|
+
import { PhoneInputNumber } from '../PhoneInputNumber';
|
|
20
|
+
import { OText, OButton, OInput } from '../shared';
|
|
21
|
+
import { sortInputFields } from '../../utils';
|
|
22
|
+
|
|
23
|
+
export const UserFormDetailsUI = (props: any) => {
|
|
24
|
+
const {
|
|
25
|
+
isEdit,
|
|
26
|
+
formState,
|
|
27
|
+
showField,
|
|
28
|
+
cleanFormState,
|
|
29
|
+
onCloseProfile,
|
|
30
|
+
isRequiredField,
|
|
31
|
+
validationFields,
|
|
32
|
+
handleChangeInput,
|
|
33
|
+
handleButtonUpdateClick,
|
|
34
|
+
phoneUpdate,
|
|
35
|
+
hideUpdateButton,
|
|
36
|
+
handleCancelEdit,
|
|
37
|
+
toggleIsEdit,
|
|
38
|
+
isCheckout,
|
|
39
|
+
} = props;
|
|
40
|
+
|
|
41
|
+
const theme = useTheme();
|
|
42
|
+
const [, t] = useLanguage();
|
|
43
|
+
const [, { showToast }] = useToast();
|
|
44
|
+
const { handleSubmit, control, errors, setValue, watch } = useForm();
|
|
45
|
+
|
|
46
|
+
const [{ user }] = useSession();
|
|
47
|
+
const [passwordSee, setPasswordSee] = useState(false);
|
|
48
|
+
const [confirmSee, setConfirmSee] = useState(false);
|
|
49
|
+
const [userPhoneNumber, setUserPhoneNumber] = useState<any>(null);
|
|
50
|
+
const [phoneInputData, setPhoneInputData] = useState({
|
|
51
|
+
error: '',
|
|
52
|
+
phone: {
|
|
53
|
+
country_phone_code: null,
|
|
54
|
+
cellphone: null,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const watchPassword = watch('password');
|
|
59
|
+
const watchConfirmPassword = watch('confirmPassword');
|
|
60
|
+
|
|
61
|
+
const showInputPhoneNumber =
|
|
62
|
+
validationFields?.fields?.checkout?.cellphone?.enabled ?? false;
|
|
63
|
+
|
|
64
|
+
const getInputRules = (field: any) => {
|
|
65
|
+
const rules: any = {
|
|
66
|
+
required: isRequiredField(field.code)
|
|
67
|
+
? t(
|
|
68
|
+
`VALIDATION_ERROR_${field.code.toUpperCase()}_REQUIRED`,
|
|
69
|
+
`${field.name} is required`,
|
|
70
|
+
).replace('_attribute_', t(field.name, field.code))
|
|
71
|
+
: null,
|
|
72
|
+
};
|
|
73
|
+
if (field.code && field.code === 'email') {
|
|
74
|
+
rules.pattern = {
|
|
75
|
+
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
|
|
76
|
+
message: t('INVALID_ERROR_EMAIL', 'Invalid email address').replace(
|
|
77
|
+
'_attribute_',
|
|
78
|
+
t('EMAIL', 'Email'),
|
|
79
|
+
),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return rules;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const setUserCellPhone = (isEdit = false) => {
|
|
87
|
+
if (userPhoneNumber && !userPhoneNumber.includes('null') && !isEdit) {
|
|
88
|
+
setUserPhoneNumber(userPhoneNumber);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (user?.cellphone) {
|
|
92
|
+
let phone = null;
|
|
93
|
+
if (user?.country_phone_code) {
|
|
94
|
+
phone = `+${user?.country_phone_code} ${user?.cellphone}`;
|
|
95
|
+
} else {
|
|
96
|
+
phone = user?.cellphone;
|
|
97
|
+
}
|
|
98
|
+
setUserPhoneNumber(phone);
|
|
99
|
+
setPhoneInputData({
|
|
100
|
+
...phoneInputData,
|
|
101
|
+
phone: {
|
|
102
|
+
country_phone_code: user?.country_phone_code || null,
|
|
103
|
+
cellphone: user?.cellphone || null,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
setUserPhoneNumber(user?.cellphone || '');
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const onSubmit = (values: any) => {
|
|
112
|
+
if (phoneInputData.error) {
|
|
113
|
+
showToast(ToastType.Error, phoneInputData.error);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (
|
|
117
|
+
Object.keys(formState.changes).length > 0 ||
|
|
118
|
+
(watchPassword.length > 0 && watchConfirmPassword.length > 0)
|
|
119
|
+
) {
|
|
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(
|
|
128
|
+
'VALIDATION_ERROR_MOBILE_PHONE_REQUIRED',
|
|
129
|
+
'The field Phone Number is required.',
|
|
130
|
+
),
|
|
131
|
+
);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
let changes = null;
|
|
135
|
+
if (user?.cellphone && !userPhoneNumber) {
|
|
136
|
+
changes = {
|
|
137
|
+
country_phone_code: '',
|
|
138
|
+
cellphone: '',
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (values.password && values.confirmPassword) {
|
|
143
|
+
changes = {
|
|
144
|
+
password: values.password,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
handleButtonUpdateClick(changes);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const handleChangePhoneNumber = (number: any) => {
|
|
153
|
+
setPhoneInputData(number);
|
|
154
|
+
let phoneNumber = {
|
|
155
|
+
country_phone_code: {
|
|
156
|
+
name: 'country_phone_code',
|
|
157
|
+
value: number.phone.country_phone_code,
|
|
158
|
+
},
|
|
159
|
+
cellphone: {
|
|
160
|
+
name: 'cellphone',
|
|
161
|
+
value: number.phone.cellphone,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
handleChangeInput(phoneNumber, true);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
if (Object.keys(errors).length > 0) {
|
|
169
|
+
const list = Object.values(errors);
|
|
170
|
+
|
|
171
|
+
if (phoneInputData.error) {
|
|
172
|
+
list.push({ message: phoneInputData.error });
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
let stringError = '';
|
|
176
|
+
list.map((item: any, i: number) => {
|
|
177
|
+
stringError +=
|
|
178
|
+
i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
showToast(ToastType.Error, stringError);
|
|
182
|
+
}
|
|
183
|
+
}, [errors]);
|
|
184
|
+
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
if (!formState?.loading && formState?.result?.error) {
|
|
187
|
+
formState.result?.result &&
|
|
188
|
+
showToast(ToastType.Error, formState.result?.result[0]);
|
|
189
|
+
}
|
|
190
|
+
}, [formState?.loading]);
|
|
191
|
+
|
|
192
|
+
useEffect(() => {
|
|
193
|
+
if (!isEdit && onCloseProfile) {
|
|
194
|
+
onCloseProfile();
|
|
195
|
+
}
|
|
196
|
+
if ((user || !isEdit) && !formState?.loading) {
|
|
197
|
+
setUserCellPhone();
|
|
198
|
+
if (!isEdit && !formState?.loading) {
|
|
199
|
+
cleanFormState && cleanFormState({ changes: {} });
|
|
200
|
+
setUserCellPhone(true);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}, [user, isEdit]);
|
|
204
|
+
|
|
205
|
+
const styles = StyleSheet.create({
|
|
206
|
+
btnOutline: {
|
|
207
|
+
backgroundColor: theme.colors.primaryContrast,
|
|
208
|
+
color: theme.colors.primary,
|
|
209
|
+
},
|
|
210
|
+
label: {
|
|
211
|
+
color: theme.colors.textGray,
|
|
212
|
+
fontFamily: 'Poppins',
|
|
213
|
+
fontStyle: 'normal',
|
|
214
|
+
fontWeight: '600',
|
|
215
|
+
},
|
|
216
|
+
errorText: {
|
|
217
|
+
color: theme.colors.error,
|
|
218
|
+
fontFamily: 'Poppins',
|
|
219
|
+
fontStyle: 'normal',
|
|
220
|
+
fontWeight: 'normal',
|
|
221
|
+
fontSize: 16,
|
|
222
|
+
paddingHorizontal: 16,
|
|
223
|
+
marginBottom: 20,
|
|
224
|
+
},
|
|
225
|
+
inputStyle: {
|
|
226
|
+
marginBottom: 25,
|
|
227
|
+
borderWidth: 1,
|
|
228
|
+
borderColor: theme.colors.tabBar,
|
|
229
|
+
borderTopWidth: 0,
|
|
230
|
+
borderRightWidth: 0,
|
|
231
|
+
borderLeftWidth: 0,
|
|
232
|
+
paddingHorizontal: 0,
|
|
233
|
+
borderRadius: 0,
|
|
234
|
+
},
|
|
235
|
+
editButton: {
|
|
236
|
+
height: 44,
|
|
237
|
+
borderRadius: 7.6,
|
|
238
|
+
borderWidth: 1,
|
|
239
|
+
},
|
|
240
|
+
btnText: {
|
|
241
|
+
color: theme.colors.textGray,
|
|
242
|
+
fontFamily: 'Poppins',
|
|
243
|
+
fontStyle: 'normal',
|
|
244
|
+
fontWeight: 'normal',
|
|
245
|
+
fontSize: 16,
|
|
246
|
+
},
|
|
247
|
+
btnFlag: {
|
|
248
|
+
width: 79,
|
|
249
|
+
borderWidth: 1,
|
|
250
|
+
borderRadius: 7.6,
|
|
251
|
+
marginRight: 9,
|
|
252
|
+
borderColor: theme.colors.inputSignup,
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<>
|
|
258
|
+
<UDForm>
|
|
259
|
+
{!validationFields?.loading &&
|
|
260
|
+
sortInputFields({ values: validationFields?.fields?.checkout })
|
|
261
|
+
.length > 0 && (
|
|
262
|
+
<UDWrapper>
|
|
263
|
+
{sortInputFields({
|
|
264
|
+
values: validationFields.fields?.checkout,
|
|
265
|
+
}).map(
|
|
266
|
+
(field: any) =>
|
|
267
|
+
showField &&
|
|
268
|
+
showField(field.code) && (
|
|
269
|
+
<React.Fragment key={field.id}>
|
|
270
|
+
<OText style={styles.label}>
|
|
271
|
+
{t(field?.code.toUpperCase(), field?.name)}
|
|
272
|
+
</OText>
|
|
273
|
+
|
|
274
|
+
<Controller
|
|
275
|
+
key={field.id}
|
|
276
|
+
control={control}
|
|
277
|
+
render={() => (
|
|
278
|
+
<OInput
|
|
279
|
+
name={field.code}
|
|
280
|
+
placeholder={t(
|
|
281
|
+
field.code.toUpperCase(),
|
|
282
|
+
field?.name,
|
|
283
|
+
)}
|
|
284
|
+
placeholderTextColor={theme.colors.arrowColor}
|
|
285
|
+
style={styles.inputStyle}
|
|
286
|
+
icon={
|
|
287
|
+
field.code === 'email'
|
|
288
|
+
? theme.images.general.email
|
|
289
|
+
: theme.images.general.user
|
|
290
|
+
}
|
|
291
|
+
autoCapitalize={
|
|
292
|
+
field.code === 'email' ? 'none' : 'sentences'
|
|
293
|
+
}
|
|
294
|
+
isDisabled={!isEdit}
|
|
295
|
+
value={
|
|
296
|
+
formState?.changes[field.code] ??
|
|
297
|
+
(user && user[field.code]) ??
|
|
298
|
+
''
|
|
299
|
+
}
|
|
300
|
+
onChange={(val: any) => {
|
|
301
|
+
field.code !== 'email'
|
|
302
|
+
? setValue(field.code, val.target.value)
|
|
303
|
+
: setValue(
|
|
304
|
+
field.code,
|
|
305
|
+
val.target.value
|
|
306
|
+
.toLowerCase()
|
|
307
|
+
.replace(/[&,()%";:ç?<>{}\\[\]\s]/g, ''),
|
|
308
|
+
);
|
|
309
|
+
field.code !== 'email'
|
|
310
|
+
? handleChangeInput(val)
|
|
311
|
+
: handleChangeInput({
|
|
312
|
+
target: {
|
|
313
|
+
name: 'email',
|
|
314
|
+
value: val.target.value
|
|
315
|
+
.toLowerCase()
|
|
316
|
+
.replace(
|
|
317
|
+
/[&,()%";:ç?<>{}\\[\]\s]/g,
|
|
318
|
+
'',
|
|
319
|
+
),
|
|
320
|
+
},
|
|
321
|
+
});
|
|
322
|
+
}}
|
|
323
|
+
autoCorrect={field.code === 'email' && false}
|
|
324
|
+
type={
|
|
325
|
+
field.code === 'email'
|
|
326
|
+
? 'email-address'
|
|
327
|
+
: 'default'
|
|
328
|
+
}
|
|
329
|
+
returnKeyType="done"
|
|
330
|
+
autoCompleteType={
|
|
331
|
+
field.code === 'email' ? 'email' : 'off'
|
|
332
|
+
}
|
|
333
|
+
selectionColor={theme.colors.primary}
|
|
334
|
+
color={theme.colors.textGray}
|
|
335
|
+
/>
|
|
336
|
+
)}
|
|
337
|
+
name={field.code}
|
|
338
|
+
rules={getInputRules(field)}
|
|
339
|
+
defaultValue={user && user[field.code]}
|
|
340
|
+
/>
|
|
341
|
+
</React.Fragment>
|
|
342
|
+
),
|
|
343
|
+
)}
|
|
344
|
+
|
|
345
|
+
<OText style={styles.label}>{t('PASSWORD', 'Password')}</OText>
|
|
346
|
+
|
|
347
|
+
<Controller
|
|
348
|
+
control={control}
|
|
349
|
+
render={({ onChange, value }: any) => (
|
|
350
|
+
<OInput
|
|
351
|
+
isSecured={!passwordSee ? true : false}
|
|
352
|
+
placeholder={t('PASSWORD', 'Password')}
|
|
353
|
+
placeholderTextColor={theme.colors.arrowColor}
|
|
354
|
+
style={styles.inputStyle}
|
|
355
|
+
iconCustomRight={
|
|
356
|
+
passwordSee ? (
|
|
357
|
+
<MaterialCommunityIcons
|
|
358
|
+
name="eye-outline"
|
|
359
|
+
color={theme.colors.arrowColor}
|
|
360
|
+
size={24}
|
|
361
|
+
onPress={() => setPasswordSee(!passwordSee)}
|
|
362
|
+
/>
|
|
363
|
+
) : (
|
|
364
|
+
<MaterialCommunityIcons
|
|
365
|
+
name="eye-off-outline"
|
|
366
|
+
color={theme.colors.arrowColor}
|
|
367
|
+
size={24}
|
|
368
|
+
onPress={() => setPasswordSee(!passwordSee)}
|
|
369
|
+
/>
|
|
370
|
+
)
|
|
371
|
+
}
|
|
372
|
+
selectionColor={theme.colors.primary}
|
|
373
|
+
color={theme.colors.textGray}
|
|
374
|
+
value={value}
|
|
375
|
+
onChange={(val: any) => onChange(val)}
|
|
376
|
+
returnKeyType="done"
|
|
377
|
+
blurOnSubmit
|
|
378
|
+
/>
|
|
379
|
+
)}
|
|
380
|
+
name="password"
|
|
381
|
+
defaultValue=""
|
|
382
|
+
/>
|
|
383
|
+
|
|
384
|
+
<OText style={styles.label}>
|
|
385
|
+
{t('MOBILE_CONFIRM_PASSWORD', 'Confirm Password')}
|
|
386
|
+
</OText>
|
|
387
|
+
|
|
388
|
+
<Controller
|
|
389
|
+
control={control}
|
|
390
|
+
render={({ onChange, value }: any) => (
|
|
391
|
+
<OInput
|
|
392
|
+
isSecured={!confirmSee ? true : false}
|
|
393
|
+
placeholder={t(
|
|
394
|
+
'MOBILE_CONFIRM_PASSWORD',
|
|
395
|
+
'Confirm Password',
|
|
396
|
+
)}
|
|
397
|
+
style={styles.inputStyle}
|
|
398
|
+
placeholderTextColor={theme.colors.arrowColor}
|
|
399
|
+
iconCustomRight={
|
|
400
|
+
confirmSee ? (
|
|
401
|
+
<MaterialCommunityIcons
|
|
402
|
+
name="eye-outline"
|
|
403
|
+
color={theme.colors.arrowColor}
|
|
404
|
+
size={24}
|
|
405
|
+
onPress={() => setConfirmSee(!confirmSee)}
|
|
406
|
+
/>
|
|
407
|
+
) : (
|
|
408
|
+
<MaterialCommunityIcons
|
|
409
|
+
name="eye-off-outline"
|
|
410
|
+
color={theme.colors.arrowColor}
|
|
411
|
+
size={24}
|
|
412
|
+
onPress={() => setConfirmSee(!confirmSee)}
|
|
413
|
+
/>
|
|
414
|
+
)
|
|
415
|
+
}
|
|
416
|
+
selectionColor={theme.colors.primary}
|
|
417
|
+
color={theme.colors.textGray}
|
|
418
|
+
value={value}
|
|
419
|
+
onChange={(val: any) => onChange(val)}
|
|
420
|
+
returnKeyType="done"
|
|
421
|
+
blurOnSubmit
|
|
422
|
+
/>
|
|
423
|
+
)}
|
|
424
|
+
rules={{
|
|
425
|
+
validate: (value: any) => {
|
|
426
|
+
return (
|
|
427
|
+
watchPassword === value ||
|
|
428
|
+
t(
|
|
429
|
+
'VALIDATION_ERROR_PASSWORDS_MATCH',
|
|
430
|
+
'The passwords do not match',
|
|
431
|
+
)
|
|
432
|
+
);
|
|
433
|
+
},
|
|
434
|
+
}}
|
|
435
|
+
name="confirmPassword"
|
|
436
|
+
defaultValue=""
|
|
437
|
+
/>
|
|
438
|
+
|
|
439
|
+
{errors.confirmPassword && (
|
|
440
|
+
<OText style={styles.errorText}>
|
|
441
|
+
{errors?.confirmPassword.message}
|
|
442
|
+
</OText>
|
|
443
|
+
)}
|
|
444
|
+
|
|
445
|
+
{!!showInputPhoneNumber && (
|
|
446
|
+
<WrapperPhone>
|
|
447
|
+
<PhoneInputNumber
|
|
448
|
+
data={phoneInputData}
|
|
449
|
+
handleData={(val: any) => handleChangePhoneNumber(val)}
|
|
450
|
+
defaultValue={phoneUpdate ? '' : user?.cellphone}
|
|
451
|
+
defaultCode={user?.country_phone_code || null}
|
|
452
|
+
flagProps={styles.btnFlag}
|
|
453
|
+
/>
|
|
454
|
+
|
|
455
|
+
{phoneUpdate && (
|
|
456
|
+
<OText style={styles.errorText}>
|
|
457
|
+
{t('YOUR_PREVIOUS_CELLPHONE', 'Your previous cellphone')}:{' '}
|
|
458
|
+
{user?.cellphone}
|
|
459
|
+
</OText>
|
|
460
|
+
)}
|
|
461
|
+
</WrapperPhone>
|
|
462
|
+
)}
|
|
463
|
+
</UDWrapper>
|
|
464
|
+
)}
|
|
465
|
+
</UDForm>
|
|
466
|
+
|
|
467
|
+
{!validationFields.loading && !isCheckout && (
|
|
468
|
+
<EditButton>
|
|
469
|
+
<View style={{ flex: 1 }}>
|
|
470
|
+
<OButton
|
|
471
|
+
text={t('CANCEL', 'Cancel')}
|
|
472
|
+
bgColor={theme.colors.white}
|
|
473
|
+
borderColor={theme.colors.primary}
|
|
474
|
+
style={styles.editButton}
|
|
475
|
+
textStyle={styles.btnText}
|
|
476
|
+
isDisabled={formState.loading}
|
|
477
|
+
imgRightSrc={null}
|
|
478
|
+
onClick={handleCancelEdit}
|
|
479
|
+
/>
|
|
480
|
+
</View>
|
|
481
|
+
|
|
482
|
+
{((formState &&
|
|
483
|
+
Object.keys(formState?.changes).length > 0 &&
|
|
484
|
+
isEdit) ||
|
|
485
|
+
(watchPassword?.length > 0 && watchConfirmPassword?.length > 0) ||
|
|
486
|
+
formState?.loading) && (
|
|
487
|
+
<View style={{ flex: 1, marginLeft: 5 }}>
|
|
488
|
+
<OButton
|
|
489
|
+
text={
|
|
490
|
+
formState.loading
|
|
491
|
+
? t('UPDATING', 'Updating')
|
|
492
|
+
: t('UPDATE', 'Update')
|
|
493
|
+
}
|
|
494
|
+
bgColor={theme.colors.primary}
|
|
495
|
+
textStyle={{
|
|
496
|
+
...styles.btnText,
|
|
497
|
+
color: formState.loading
|
|
498
|
+
? theme.colors.textGray
|
|
499
|
+
: theme.colors.white,
|
|
500
|
+
}}
|
|
501
|
+
borderColor={theme.colors.primary}
|
|
502
|
+
isDisabled={formState.loading}
|
|
503
|
+
imgRightSrc={null}
|
|
504
|
+
style={styles.editButton}
|
|
505
|
+
onClick={handleSubmit(onSubmit)}
|
|
506
|
+
/>
|
|
507
|
+
</View>
|
|
508
|
+
)}
|
|
509
|
+
</EditButton>
|
|
510
|
+
)}
|
|
511
|
+
</>
|
|
512
|
+
);
|
|
513
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import styled from 'styled-components/native';
|
|
2
|
+
|
|
3
|
+
export const UDForm = styled.View`
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
width: 100%;
|
|
8
|
+
margin-top: 20px;
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export const UDWrapper = styled.View`
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: flex-start;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
width: 100%;
|
|
16
|
+
margin-top: 20px;
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
export const UDLoader = styled.View`
|
|
20
|
+
width: 100%;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
height: auto;
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-wrap: wrap;
|
|
25
|
+
padding: 0;
|
|
26
|
+
margin-top: 0px;
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
export const WrapperPhone = styled.View`
|
|
30
|
+
margin-bottom: 25px;
|
|
31
|
+
width: 100%;
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
export const EditButton = styled.View`
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
flex-direction: row;
|
|
38
|
+
width: 100%;
|
|
39
|
+
margin-bottom: 25px;
|
|
40
|
+
`;
|