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,530 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { View, StyleSheet, Keyboard } from 'react-native';
|
|
3
|
+
import { useForm, Controller } from 'react-hook-form';
|
|
4
|
+
import Spinner from 'react-native-loading-spinner-overlay';
|
|
5
|
+
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
|
6
|
+
import {
|
|
7
|
+
SignupForm as SignUpController,
|
|
8
|
+
useLanguage,
|
|
9
|
+
ToastType,
|
|
10
|
+
useToast,
|
|
11
|
+
} from 'ordering-components/native';
|
|
12
|
+
import { useTheme } from 'styled-components/native';
|
|
13
|
+
import { FormInput } from './styles';
|
|
14
|
+
import { PhoneInputNumber } from '../PhoneInputNumber';
|
|
15
|
+
import { VerifyPhone } from '../VerifyPhone';
|
|
16
|
+
import { OButton, OInput, OModal, OIconButton, OText } from '../shared';
|
|
17
|
+
import { _removeStoreData } from '../../providers/StoreUtil';
|
|
18
|
+
import { SignupParams } from '../../types';
|
|
19
|
+
import { sortInputFields } from '../../utils';
|
|
20
|
+
|
|
21
|
+
const SignupFormUI = (props: SignupParams) => {
|
|
22
|
+
const {
|
|
23
|
+
navigation,
|
|
24
|
+
formState,
|
|
25
|
+
validationFields,
|
|
26
|
+
showField,
|
|
27
|
+
isRequiredField,
|
|
28
|
+
useSignupByCellphone,
|
|
29
|
+
handleSuccessSignup,
|
|
30
|
+
handleButtonSignupClick,
|
|
31
|
+
verifyPhoneState,
|
|
32
|
+
checkPhoneCodeState,
|
|
33
|
+
setCheckPhoneCodeState,
|
|
34
|
+
handleSendVerifyCode,
|
|
35
|
+
handleCheckPhoneCode,
|
|
36
|
+
signupLevel,
|
|
37
|
+
// notificationState,
|
|
38
|
+
} = props;
|
|
39
|
+
|
|
40
|
+
const notValidationFields = [
|
|
41
|
+
'coupon',
|
|
42
|
+
'driver_tip',
|
|
43
|
+
'mobile_phone',
|
|
44
|
+
'address',
|
|
45
|
+
'address_notes',
|
|
46
|
+
'middle_name',
|
|
47
|
+
'lastname',
|
|
48
|
+
'second_lastname',
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const showInputPhoneNumber =
|
|
52
|
+
validationFields?.fields?.checkout?.cellphone?.enabled ?? false;
|
|
53
|
+
|
|
54
|
+
const theme = useTheme();
|
|
55
|
+
const [, { showToast }] = useToast();
|
|
56
|
+
const [, t] = useLanguage();
|
|
57
|
+
const { control, handleSubmit, errors } = useForm();
|
|
58
|
+
|
|
59
|
+
const [passwordSee, setPasswordSee] = useState(false);
|
|
60
|
+
const [formValues, setFormValues] = useState(null);
|
|
61
|
+
const [isModalVisible, setIsModalVisible] = useState(false);
|
|
62
|
+
const [isLoadingVerifyModal, setIsLoadingVerifyModal] = useState(false);
|
|
63
|
+
const [phoneInputData, setPhoneInputData] = useState({
|
|
64
|
+
error: '',
|
|
65
|
+
phone: {
|
|
66
|
+
country_phone_code: null,
|
|
67
|
+
cellphone: null,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const nameRef = useRef<any>(null);
|
|
72
|
+
const lastnameRef = useRef<any>(null);
|
|
73
|
+
const middleNameRef = useRef<any>(null);
|
|
74
|
+
const secondLastnameRef = useRef<any>(null);
|
|
75
|
+
const emailRef = useRef<any>(null);
|
|
76
|
+
const phoneRef = useRef<any>(null);
|
|
77
|
+
const passwordRef = useRef<any>(null);
|
|
78
|
+
|
|
79
|
+
const handleRefs = (ref: any, code: string) => {
|
|
80
|
+
switch (code) {
|
|
81
|
+
case 'name': {
|
|
82
|
+
nameRef.current = ref;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
case 'middle_name': {
|
|
86
|
+
middleNameRef.current = ref;
|
|
87
|
+
}
|
|
88
|
+
case 'lastname': {
|
|
89
|
+
lastnameRef.current = ref;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case 'second_lastname': {
|
|
93
|
+
secondLastnameRef.current = ref;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case 'email': {
|
|
97
|
+
emailRef.current = ref;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const handleFocusRef = (code: string) => {
|
|
104
|
+
switch (code) {
|
|
105
|
+
case 'name': {
|
|
106
|
+
nameRef?.current?.focus();
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case 'middle_name': {
|
|
110
|
+
middleNameRef?.current?.focus();
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
case 'lastname': {
|
|
114
|
+
lastnameRef?.current?.focus();
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
case 'second_lastname': {
|
|
118
|
+
secondLastnameRef?.current?.focus();
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case 'email': {
|
|
122
|
+
emailRef?.current?.focus();
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const getNextFieldCode = (index: number) => {
|
|
129
|
+
const fields = sortInputFields({
|
|
130
|
+
values: validationFields?.fields?.checkout,
|
|
131
|
+
})?.filter(
|
|
132
|
+
(field: any) =>
|
|
133
|
+
!notValidationFields.includes(field.code) && showField(field.code),
|
|
134
|
+
);
|
|
135
|
+
return fields[index + 1]?.code;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const handleSignup = () => {
|
|
139
|
+
handleSubmit(onSubmit)();
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const onSubmit = (values: any) => {
|
|
143
|
+
Keyboard.dismiss();
|
|
144
|
+
|
|
145
|
+
if (phoneInputData.error) {
|
|
146
|
+
showToast(ToastType.Error, phoneInputData.error);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (
|
|
151
|
+
!phoneInputData.phone.country_phone_code &&
|
|
152
|
+
!phoneInputData.phone.cellphone &&
|
|
153
|
+
validationFields?.fields?.checkout?.cellphone?.enabled &&
|
|
154
|
+
validationFields?.fields?.checkout?.cellphone?.required
|
|
155
|
+
) {
|
|
156
|
+
showToast(
|
|
157
|
+
ToastType.Error,
|
|
158
|
+
t(
|
|
159
|
+
'VALIDATION_ERROR_MOBILE_PHONE_REQUIRED',
|
|
160
|
+
'The field Mobile phone is required.',
|
|
161
|
+
),
|
|
162
|
+
);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (!useSignupByCellphone) {
|
|
167
|
+
handleButtonSignupClick &&
|
|
168
|
+
handleButtonSignupClick({
|
|
169
|
+
...values,
|
|
170
|
+
...phoneInputData.phone,
|
|
171
|
+
level: signupLevel,
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
if (
|
|
175
|
+
!formState.loading &&
|
|
176
|
+
formState.result.result &&
|
|
177
|
+
!formState.result.error
|
|
178
|
+
) {
|
|
179
|
+
handleSuccessSignup && handleSuccessSignup(formState.result.result);
|
|
180
|
+
}
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
setFormValues(values);
|
|
185
|
+
handleVerifyCodeClick(values);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const handleVerifyCodeClick = (values: any) => {
|
|
189
|
+
const formData = values || formValues;
|
|
190
|
+
|
|
191
|
+
handleSendVerifyCode &&
|
|
192
|
+
handleSendVerifyCode({
|
|
193
|
+
...formData,
|
|
194
|
+
...phoneInputData.phone,
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
setIsLoadingVerifyModal(true);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
// get object with rules for hook form inputs
|
|
201
|
+
const getInputRules = (field: any) => {
|
|
202
|
+
const rules: any = {
|
|
203
|
+
required: isRequiredField(field.code)
|
|
204
|
+
? t(
|
|
205
|
+
`VALIDATION_ERROR_${field.code.toUpperCase()}_REQUIRED`,
|
|
206
|
+
`${field.name} is required`,
|
|
207
|
+
).replace('_attribute_', t(field.name, field.code))
|
|
208
|
+
: null,
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
if (field.code && field.code === 'email') {
|
|
212
|
+
rules.pattern = {
|
|
213
|
+
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
|
|
214
|
+
message: t('INVALID_ERROR_EMAIL', 'Invalid email address').replace(
|
|
215
|
+
'_attribute_',
|
|
216
|
+
t('EMAIL', 'Email'),
|
|
217
|
+
),
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
return rules;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const handleChangeInputEmail = (value: string, onChange: any) => {
|
|
224
|
+
onChange(value.toLowerCase().replace(/[&,()%";:ç?<>{}\\[\]\s]/g, ''));
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
useEffect(() => {
|
|
228
|
+
if (!formState.loading && formState.result?.error) {
|
|
229
|
+
formState.result?.result &&
|
|
230
|
+
showToast(ToastType.Error, formState.result?.result[0]);
|
|
231
|
+
setIsLoadingVerifyModal(false);
|
|
232
|
+
}
|
|
233
|
+
}, [formState]);
|
|
234
|
+
|
|
235
|
+
useEffect(() => {
|
|
236
|
+
if (Object.keys(errors).length > 0) {
|
|
237
|
+
// Convert all errors in one string to show in toast provider
|
|
238
|
+
const list = Object.values(errors);
|
|
239
|
+
|
|
240
|
+
if (phoneInputData.error) {
|
|
241
|
+
list.push({ message: phoneInputData.error });
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (
|
|
245
|
+
!phoneInputData.error &&
|
|
246
|
+
!phoneInputData.phone.country_phone_code &&
|
|
247
|
+
!phoneInputData.phone.cellphone &&
|
|
248
|
+
validationFields?.fields?.checkout?.cellphone?.enabled &&
|
|
249
|
+
validationFields?.fields?.checkout?.cellphone?.required
|
|
250
|
+
) {
|
|
251
|
+
list.push({
|
|
252
|
+
message: t(
|
|
253
|
+
'VALIDATION_ERROR_MOBILE_PHONE_REQUIRED',
|
|
254
|
+
'The field Mobile phone is required.',
|
|
255
|
+
),
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
let stringError = '';
|
|
260
|
+
list.map((item: any, i: number) => {
|
|
261
|
+
stringError +=
|
|
262
|
+
i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
showToast(ToastType.Error, stringError);
|
|
266
|
+
setIsLoadingVerifyModal(false);
|
|
267
|
+
}
|
|
268
|
+
}, [errors]);
|
|
269
|
+
|
|
270
|
+
useEffect(() => {
|
|
271
|
+
if (verifyPhoneState && !verifyPhoneState?.loading) {
|
|
272
|
+
if (verifyPhoneState.result?.error) {
|
|
273
|
+
const message =
|
|
274
|
+
typeof verifyPhoneState?.result?.result === 'string'
|
|
275
|
+
? verifyPhoneState?.result?.result
|
|
276
|
+
: verifyPhoneState?.result?.result[0];
|
|
277
|
+
|
|
278
|
+
verifyPhoneState.result?.result && showToast(ToastType.Error, message);
|
|
279
|
+
setIsLoadingVerifyModal(false);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const okResult = verifyPhoneState.result?.result === 'OK';
|
|
284
|
+
if (okResult) {
|
|
285
|
+
!isModalVisible && setIsModalVisible(true);
|
|
286
|
+
setIsLoadingVerifyModal(false);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}, [verifyPhoneState]);
|
|
290
|
+
|
|
291
|
+
const styles = StyleSheet.create({
|
|
292
|
+
header: {
|
|
293
|
+
marginBottom: 30,
|
|
294
|
+
justifyContent: 'space-between',
|
|
295
|
+
},
|
|
296
|
+
arrowLeft: {
|
|
297
|
+
maxWidth: 40,
|
|
298
|
+
height: 25,
|
|
299
|
+
justifyContent: 'flex-end',
|
|
300
|
+
marginBottom: 25,
|
|
301
|
+
},
|
|
302
|
+
title: {
|
|
303
|
+
fontFamily: 'Poppins',
|
|
304
|
+
fontStyle: 'normal',
|
|
305
|
+
fontWeight: '600',
|
|
306
|
+
fontSize: 26,
|
|
307
|
+
color: theme.colors.textGray,
|
|
308
|
+
},
|
|
309
|
+
btn: {
|
|
310
|
+
borderRadius: 7.6,
|
|
311
|
+
height: 44,
|
|
312
|
+
},
|
|
313
|
+
btnText: {
|
|
314
|
+
color: theme.colors.inputTextColor,
|
|
315
|
+
fontFamily: 'Poppins',
|
|
316
|
+
fontStyle: 'normal',
|
|
317
|
+
fontWeight: 'normal',
|
|
318
|
+
fontSize: 18,
|
|
319
|
+
},
|
|
320
|
+
btnFlag: {
|
|
321
|
+
borderWidth: 1,
|
|
322
|
+
borderRadius: 7.6,
|
|
323
|
+
marginRight: 9,
|
|
324
|
+
borderColor: theme.colors.inputSignup,
|
|
325
|
+
},
|
|
326
|
+
input: {
|
|
327
|
+
color: theme.colors.inputTextColor,
|
|
328
|
+
marginBottom: 20,
|
|
329
|
+
borderWidth: 1,
|
|
330
|
+
borderRadius: 7.6,
|
|
331
|
+
borderColor: theme.colors.inputSignup,
|
|
332
|
+
backgroundColor: theme.colors.transparent,
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
return (
|
|
337
|
+
<View>
|
|
338
|
+
<View style={styles.header}>
|
|
339
|
+
<OIconButton
|
|
340
|
+
icon={theme.images.general.arrow_left}
|
|
341
|
+
borderColor={theme.colors.clear}
|
|
342
|
+
iconStyle={{ width: 20, height: 20 }}
|
|
343
|
+
style={styles.arrowLeft}
|
|
344
|
+
onClick={() => navigation?.canGoBack() && navigation.goBack()}
|
|
345
|
+
/>
|
|
346
|
+
|
|
347
|
+
<OText style={styles.title}>{t('SIGNUP', 'Sign Up')}</OText>
|
|
348
|
+
</View>
|
|
349
|
+
|
|
350
|
+
<FormInput>
|
|
351
|
+
{!(validationFields?.loading && validationFields?.fields?.checkout) ? (
|
|
352
|
+
<>
|
|
353
|
+
{sortInputFields({
|
|
354
|
+
values: validationFields?.fields?.checkout,
|
|
355
|
+
}).map(
|
|
356
|
+
(field: any, i: number) =>
|
|
357
|
+
!notValidationFields.includes(field.code) &&
|
|
358
|
+
showField &&
|
|
359
|
+
showField(field.code) && (
|
|
360
|
+
<Controller
|
|
361
|
+
key={field.id}
|
|
362
|
+
control={control}
|
|
363
|
+
render={({ onChange, value }: any) => (
|
|
364
|
+
<OInput
|
|
365
|
+
placeholder={t(field.name)}
|
|
366
|
+
style={styles.input}
|
|
367
|
+
icon={
|
|
368
|
+
field.code === 'email'
|
|
369
|
+
? theme.images.logos.emailInputIcon
|
|
370
|
+
: theme.images.general.profile
|
|
371
|
+
}
|
|
372
|
+
value={value}
|
|
373
|
+
onChange={(val: any) =>
|
|
374
|
+
field.code !== 'email'
|
|
375
|
+
? onChange(val)
|
|
376
|
+
: handleChangeInputEmail(val, onChange)
|
|
377
|
+
}
|
|
378
|
+
autoCapitalize={
|
|
379
|
+
field.code === 'email' ? 'none' : 'sentences'
|
|
380
|
+
}
|
|
381
|
+
autoCorrect={field.code === 'email' && false}
|
|
382
|
+
type={
|
|
383
|
+
field.code === 'email' ? 'email-address' : 'default'
|
|
384
|
+
}
|
|
385
|
+
autoCompleteType={
|
|
386
|
+
field.code === 'email' ? 'email' : 'off'
|
|
387
|
+
}
|
|
388
|
+
selectionColor={theme.colors.primary}
|
|
389
|
+
color={theme.colors.textGray}
|
|
390
|
+
returnKeyType="next"
|
|
391
|
+
blurOnSubmit={false}
|
|
392
|
+
forwardRef={(ref: any) => handleRefs(ref, field.code)}
|
|
393
|
+
onSubmitEditing={() =>
|
|
394
|
+
field.code === 'email'
|
|
395
|
+
? phoneRef.current.focus()
|
|
396
|
+
: handleFocusRef(getNextFieldCode(i))
|
|
397
|
+
}
|
|
398
|
+
/>
|
|
399
|
+
)}
|
|
400
|
+
name={field.code}
|
|
401
|
+
rules={getInputRules(field)}
|
|
402
|
+
defaultValue=""
|
|
403
|
+
/>
|
|
404
|
+
),
|
|
405
|
+
)}
|
|
406
|
+
|
|
407
|
+
{!!showInputPhoneNumber && (
|
|
408
|
+
<View style={{ marginBottom: 25 }}>
|
|
409
|
+
<PhoneInputNumber
|
|
410
|
+
data={phoneInputData}
|
|
411
|
+
handleData={(val: any) => setPhoneInputData(val)}
|
|
412
|
+
forwardRef={phoneRef}
|
|
413
|
+
flagProps={styles.btnFlag}
|
|
414
|
+
onSubmitEditing={() => null}
|
|
415
|
+
textInputProps={{
|
|
416
|
+
returnKeyType: 'next',
|
|
417
|
+
onSubmitEditing: () => passwordRef.current.focus(),
|
|
418
|
+
}}
|
|
419
|
+
/>
|
|
420
|
+
</View>
|
|
421
|
+
)}
|
|
422
|
+
|
|
423
|
+
<Controller
|
|
424
|
+
control={control}
|
|
425
|
+
render={({ onChange, value }: any) => (
|
|
426
|
+
<OInput
|
|
427
|
+
isSecured={!passwordSee ? true : false}
|
|
428
|
+
placeholder={t('PASSWORD', 'Password')}
|
|
429
|
+
style={styles.input}
|
|
430
|
+
icon={theme.images.logos.passwordInputIcon}
|
|
431
|
+
iconCustomRight={
|
|
432
|
+
!passwordSee ? (
|
|
433
|
+
<MaterialCommunityIcons
|
|
434
|
+
name="eye-outline"
|
|
435
|
+
size={24}
|
|
436
|
+
color={theme.colors.inputSignup}
|
|
437
|
+
onPress={() => setPasswordSee(!passwordSee)}
|
|
438
|
+
/>
|
|
439
|
+
) : (
|
|
440
|
+
<MaterialCommunityIcons
|
|
441
|
+
name="eye-off-outline"
|
|
442
|
+
size={24}
|
|
443
|
+
color={theme.colors.inputSignup}
|
|
444
|
+
onPress={() => setPasswordSee(!passwordSee)}
|
|
445
|
+
/>
|
|
446
|
+
)
|
|
447
|
+
}
|
|
448
|
+
selectionColor={theme.colors.primary}
|
|
449
|
+
color={theme.colors.textGray}
|
|
450
|
+
value={value}
|
|
451
|
+
onChange={(val: any) => onChange(val)}
|
|
452
|
+
returnKeyType="done"
|
|
453
|
+
blurOnSubmit
|
|
454
|
+
forwardRef={passwordRef}
|
|
455
|
+
/>
|
|
456
|
+
)}
|
|
457
|
+
name="password"
|
|
458
|
+
rules={{
|
|
459
|
+
required: isRequiredField('password')
|
|
460
|
+
? t(
|
|
461
|
+
'VALIDATION_ERROR_PASSWORD_REQUIRED',
|
|
462
|
+
'The field Password is required',
|
|
463
|
+
).replace('_attribute_', t('PASSWORD', 'password'))
|
|
464
|
+
: null,
|
|
465
|
+
minLength: {
|
|
466
|
+
value: 8,
|
|
467
|
+
message: t(
|
|
468
|
+
'VALIDATION_ERROR_PASSWORD_MIN_STRING',
|
|
469
|
+
'The Password must be at least 8 characters.',
|
|
470
|
+
)
|
|
471
|
+
.replace('_attribute_', t('PASSWORD', 'Password'))
|
|
472
|
+
.replace('_min_', 8),
|
|
473
|
+
},
|
|
474
|
+
}}
|
|
475
|
+
defaultValue=""
|
|
476
|
+
/>
|
|
477
|
+
</>
|
|
478
|
+
) : (
|
|
479
|
+
<Spinner visible />
|
|
480
|
+
)}
|
|
481
|
+
|
|
482
|
+
{useSignupByCellphone ? (
|
|
483
|
+
<OButton
|
|
484
|
+
onClick={handleSubmit(onSubmit)}
|
|
485
|
+
text={t('GET_VERIFY_CODE', 'Get Verify Code')}
|
|
486
|
+
borderColor={theme.colors.primary}
|
|
487
|
+
textStyle={styles.btnText}
|
|
488
|
+
style={styles.btn}
|
|
489
|
+
imgRightSrc={null}
|
|
490
|
+
isLoading={isLoadingVerifyModal}
|
|
491
|
+
indicatorColor={theme.colors.white}
|
|
492
|
+
/>
|
|
493
|
+
) : (
|
|
494
|
+
<OButton
|
|
495
|
+
onClick={handleSignup}
|
|
496
|
+
text={t('SIGNUP', 'Sign Up')}
|
|
497
|
+
bgColor={theme.colors.primary}
|
|
498
|
+
borderColor={theme.colors.primary}
|
|
499
|
+
textStyle={styles.btnText}
|
|
500
|
+
style={styles.btn}
|
|
501
|
+
imgRightSrc={null}
|
|
502
|
+
isDisabled={formState.loading || validationFields.loading}
|
|
503
|
+
/>
|
|
504
|
+
)}
|
|
505
|
+
</FormInput>
|
|
506
|
+
|
|
507
|
+
<OModal open={isModalVisible} onClose={() => setIsModalVisible(false)}>
|
|
508
|
+
<VerifyPhone
|
|
509
|
+
phone={phoneInputData.phone}
|
|
510
|
+
formValues={formValues}
|
|
511
|
+
verifyPhoneState={verifyPhoneState}
|
|
512
|
+
checkPhoneCodeState={checkPhoneCodeState}
|
|
513
|
+
handleCheckPhoneCode={handleCheckPhoneCode}
|
|
514
|
+
setCheckPhoneCodeState={setCheckPhoneCodeState}
|
|
515
|
+
handleVerifyCodeClick={onSubmit}
|
|
516
|
+
/>
|
|
517
|
+
</OModal>
|
|
518
|
+
|
|
519
|
+
<Spinner visible={formState.loading} />
|
|
520
|
+
</View>
|
|
521
|
+
);
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
export const SignupForm = (props: any) => {
|
|
525
|
+
const signupProps = {
|
|
526
|
+
...props,
|
|
527
|
+
UIComponent: SignupFormUI,
|
|
528
|
+
};
|
|
529
|
+
return <SignUpController {...signupProps} />;
|
|
530
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import styled from 'styled-components/native';
|
|
2
|
+
|
|
3
|
+
export const FormSide = styled.View`
|
|
4
|
+
display: flex;
|
|
5
|
+
width: 100%;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
align-items: center;
|
|
8
|
+
margin-top: 10px;
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export const FormInput = styled.View`
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
width: 100%;
|
|
15
|
+
margin-bottom: 35px;
|
|
16
|
+
`;
|