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.
Files changed (175) hide show
  1. package/package.json +1 -1
  2. package/themes/single-business/src/components/Cart/index.tsx +91 -15
  3. package/themes/single-business/src/components/Cart/styles.tsx +39 -0
  4. package/themes/single-business/src/components/CartContent/index.tsx +56 -52
  5. package/themes/single-business/src/components/CartContent/styles.tsx +2 -16
  6. package/themes/franchises/index.tsx +0 -111
  7. package/themes/franchises/src/components/ActiveOrders/index.tsx +0 -134
  8. package/themes/franchises/src/components/ActiveOrders/styles.tsx +0 -44
  9. package/themes/franchises/src/components/AddressDetails/index.tsx +0 -77
  10. package/themes/franchises/src/components/AddressDetails/styles.tsx +0 -21
  11. package/themes/franchises/src/components/AddressForm/index.tsx +0 -837
  12. package/themes/franchises/src/components/AddressForm/styles.tsx +0 -27
  13. package/themes/franchises/src/components/AddressList/index.tsx +0 -338
  14. package/themes/franchises/src/components/AddressList/styles.tsx +0 -20
  15. package/themes/franchises/src/components/AppleLogin/index.tsx +0 -149
  16. package/themes/franchises/src/components/AppleLogin/styles.tsx +0 -21
  17. package/themes/franchises/src/components/BottomWrapper/index.tsx +0 -29
  18. package/themes/franchises/src/components/BusinessBasicInformation/index.tsx +0 -310
  19. package/themes/franchises/src/components/BusinessBasicInformation/styles.tsx +0 -66
  20. package/themes/franchises/src/components/BusinessController/index.tsx +0 -184
  21. package/themes/franchises/src/components/BusinessController/styles.tsx +0 -64
  22. package/themes/franchises/src/components/BusinessFeaturedController/index.tsx +0 -189
  23. package/themes/franchises/src/components/BusinessFeaturedController/styles.tsx +0 -50
  24. package/themes/franchises/src/components/BusinessInformation/index.tsx +0 -202
  25. package/themes/franchises/src/components/BusinessInformation/styles.tsx +0 -39
  26. package/themes/franchises/src/components/BusinessItemAccordion/index.tsx +0 -125
  27. package/themes/franchises/src/components/BusinessItemAccordion/styles.tsx +0 -54
  28. package/themes/franchises/src/components/BusinessProductsCategories/index.tsx +0 -87
  29. package/themes/franchises/src/components/BusinessProductsCategories/styles.tsx +0 -8
  30. package/themes/franchises/src/components/BusinessProductsList/index.tsx +0 -199
  31. package/themes/franchises/src/components/BusinessProductsList/styles.tsx +0 -14
  32. package/themes/franchises/src/components/BusinessProductsListing/index.tsx +0 -292
  33. package/themes/franchises/src/components/BusinessProductsListing/styles.tsx +0 -30
  34. package/themes/franchises/src/components/BusinessReviews/index.tsx +0 -249
  35. package/themes/franchises/src/components/BusinessReviews/styles.tsx +0 -59
  36. package/themes/franchises/src/components/BusinessTypeFilter/index.tsx +0 -127
  37. package/themes/franchises/src/components/BusinessTypeFilter/styles.tsx +0 -40
  38. package/themes/franchises/src/components/BusinessesListing/index.tsx +0 -339
  39. package/themes/franchises/src/components/BusinessesListing/styles.tsx +0 -92
  40. package/themes/franchises/src/components/Cart/index.tsx +0 -332
  41. package/themes/franchises/src/components/Cart/styles.tsx +0 -28
  42. package/themes/franchises/src/components/CartContent/index.tsx +0 -60
  43. package/themes/franchises/src/components/CartContent/styles.tsx +0 -19
  44. package/themes/franchises/src/components/Checkout/index.tsx +0 -664
  45. package/themes/franchises/src/components/Checkout/styles.tsx +0 -89
  46. package/themes/franchises/src/components/CouponControl/index.tsx +0 -119
  47. package/themes/franchises/src/components/CouponControl/styles.tsx +0 -22
  48. package/themes/franchises/src/components/DriverTips/index.tsx +0 -167
  49. package/themes/franchises/src/components/DriverTips/styles.tsx +0 -63
  50. package/themes/franchises/src/components/FacebookLogin/index.tsx +0 -107
  51. package/themes/franchises/src/components/FacebookLogin/styles.tsx +0 -21
  52. package/themes/franchises/src/components/FloatingButton/index.tsx +0 -100
  53. package/themes/franchises/src/components/FloatingButton/styles.tsx +0 -26
  54. package/themes/franchises/src/components/ForgotPasswordForm/index.tsx +0 -156
  55. package/themes/franchises/src/components/ForgotPasswordForm/styles.tsx +0 -11
  56. package/themes/franchises/src/components/GPSButton/index.tsx +0 -84
  57. package/themes/franchises/src/components/GPSButton/styles.ts +0 -6
  58. package/themes/franchises/src/components/GoogleLogin/index.tsx +0 -122
  59. package/themes/franchises/src/components/GoogleLogin/styles.tsx +0 -23
  60. package/themes/franchises/src/components/GoogleMap/index.tsx +0 -229
  61. package/themes/franchises/src/components/Help/index.tsx +0 -56
  62. package/themes/franchises/src/components/Help/styles.tsx +0 -11
  63. package/themes/franchises/src/components/HelpAccountAndPayment/index.tsx +0 -68
  64. package/themes/franchises/src/components/HelpAccountAndPayment/styles.tsx +0 -6
  65. package/themes/franchises/src/components/HelpGuide/index.tsx +0 -67
  66. package/themes/franchises/src/components/HelpGuide/styles.tsx +0 -6
  67. package/themes/franchises/src/components/HelpOrder/index.tsx +0 -79
  68. package/themes/franchises/src/components/HelpOrder/styles.tsx +0 -6
  69. package/themes/franchises/src/components/Home/index.tsx +0 -102
  70. package/themes/franchises/src/components/Home/styles.tsx +0 -18
  71. package/themes/franchises/src/components/LanguageSelector/index.tsx +0 -98
  72. package/themes/franchises/src/components/LanguageSelector/styles.tsx +0 -7
  73. package/themes/franchises/src/components/LastOrder/index.tsx +0 -168
  74. package/themes/franchises/src/components/LastOrder/styles.tsx +0 -16
  75. package/themes/franchises/src/components/LastOrders/index.tsx +0 -104
  76. package/themes/franchises/src/components/LastOrders/styles.tsx +0 -17
  77. package/themes/franchises/src/components/LoginForm/index.tsx +0 -512
  78. package/themes/franchises/src/components/LoginForm/styles.tsx +0 -77
  79. package/themes/franchises/src/components/LogoutButton/index.tsx +0 -36
  80. package/themes/franchises/src/components/Messages/index.tsx +0 -359
  81. package/themes/franchises/src/components/Messages/styles.tsx +0 -20
  82. package/themes/franchises/src/components/MomentOption/index.tsx +0 -321
  83. package/themes/franchises/src/components/MomentOption/styles.tsx +0 -66
  84. package/themes/franchises/src/components/NavBar/index.tsx +0 -129
  85. package/themes/franchises/src/components/NotFoundSource/index.tsx +0 -50
  86. package/themes/franchises/src/components/NotFoundSource/styles.tsx +0 -16
  87. package/themes/franchises/src/components/Notifications/index.tsx +0 -120
  88. package/themes/franchises/src/components/Notifications/styles.ts +0 -21
  89. package/themes/franchises/src/components/OrderDetails/index.tsx +0 -828
  90. package/themes/franchises/src/components/OrderDetails/styles.tsx +0 -120
  91. package/themes/franchises/src/components/OrderSummary/index.tsx +0 -266
  92. package/themes/franchises/src/components/OrderSummary/styles.tsx +0 -41
  93. package/themes/franchises/src/components/OrderTypeSelector/index.tsx +0 -92
  94. package/themes/franchises/src/components/OrderTypeSelector/styles.tsx +0 -27
  95. package/themes/franchises/src/components/OrdersOption/index.tsx +0 -243
  96. package/themes/franchises/src/components/OrdersOption/styles.tsx +0 -5
  97. package/themes/franchises/src/components/PaymentOptionCash/index.tsx +0 -102
  98. package/themes/franchises/src/components/PaymentOptionCash/styles.tsx +0 -18
  99. package/themes/franchises/src/components/PaymentOptionStripe/index.tsx +0 -234
  100. package/themes/franchises/src/components/PaymentOptionStripe/styles.tsx +0 -71
  101. package/themes/franchises/src/components/PaymentOptions/index.tsx +0 -430
  102. package/themes/franchises/src/components/PaymentOptions/styles.tsx +0 -77
  103. package/themes/franchises/src/components/PhoneInputNumber/index.tsx +0 -127
  104. package/themes/franchises/src/components/PhoneInputNumber/styles.tsx +0 -3
  105. package/themes/franchises/src/components/PreviousOrders/index.tsx +0 -188
  106. package/themes/franchises/src/components/PreviousOrders/styles.tsx +0 -33
  107. package/themes/franchises/src/components/ProductForm/index.tsx +0 -695
  108. package/themes/franchises/src/components/ProductForm/styles.tsx +0 -78
  109. package/themes/franchises/src/components/ProductIngredient/index.tsx +0 -43
  110. package/themes/franchises/src/components/ProductIngredient/styles.tsx +0 -7
  111. package/themes/franchises/src/components/ProductItemAccordion/index.tsx +0 -276
  112. package/themes/franchises/src/components/ProductItemAccordion/styles.tsx +0 -57
  113. package/themes/franchises/src/components/ProductOption/index.tsx +0 -50
  114. package/themes/franchises/src/components/ProductOption/styles.tsx +0 -11
  115. package/themes/franchises/src/components/ProductOptionSubOption/index.tsx +0 -146
  116. package/themes/franchises/src/components/ProductOptionSubOption/styles.tsx +0 -32
  117. package/themes/franchises/src/components/ReviewDriver/index.tsx +0 -221
  118. package/themes/franchises/src/components/ReviewDriver/styles.tsx +0 -46
  119. package/themes/franchises/src/components/ReviewOrder/index.tsx +0 -325
  120. package/themes/franchises/src/components/ReviewOrder/styles.tsx +0 -46
  121. package/themes/franchises/src/components/ReviewProduct/index.tsx +0 -275
  122. package/themes/franchises/src/components/ReviewProduct/styles.tsx +0 -53
  123. package/themes/franchises/src/components/SearchBar/index.tsx +0 -139
  124. package/themes/franchises/src/components/SignupForm/index.tsx +0 -643
  125. package/themes/franchises/src/components/SignupForm/styles.tsx +0 -27
  126. package/themes/franchises/src/components/SingleProductCard/index.tsx +0 -124
  127. package/themes/franchises/src/components/SingleProductCard/styles.tsx +0 -23
  128. package/themes/franchises/src/components/StripeCardForm/index.tsx +0 -97
  129. package/themes/franchises/src/components/StripeCardForm/naked.tsx +0 -128
  130. package/themes/franchises/src/components/StripeCardForm/styles.tsx +0 -32
  131. package/themes/franchises/src/components/StripeCardsList/index.tsx +0 -182
  132. package/themes/franchises/src/components/StripeElementsForm/index.tsx +0 -204
  133. package/themes/franchises/src/components/StripeElementsForm/naked.tsx +0 -90
  134. package/themes/franchises/src/components/StripeElementsForm/styles.tsx +0 -13
  135. package/themes/franchises/src/components/StripeRedirectForm/index.tsx +0 -159
  136. package/themes/franchises/src/components/StripeRedirectForm/styles.tsx +0 -23
  137. package/themes/franchises/src/components/TagSelector/index.tsx +0 -94
  138. package/themes/franchises/src/components/TagSelector/styles.ts +0 -0
  139. package/themes/franchises/src/components/TaxInformation/index.tsx +0 -51
  140. package/themes/franchises/src/components/TaxInformation/styles.tsx +0 -9
  141. package/themes/franchises/src/components/UpsellingProducts/index.tsx +0 -222
  142. package/themes/franchises/src/components/UpsellingProducts/styles.tsx +0 -50
  143. package/themes/franchises/src/components/UserDetails/index.tsx +0 -134
  144. package/themes/franchises/src/components/UserDetails/styles.tsx +0 -26
  145. package/themes/franchises/src/components/UserFormDetails/index.tsx +0 -351
  146. package/themes/franchises/src/components/UserFormDetails/styles.tsx +0 -35
  147. package/themes/franchises/src/components/UserProfile/index.tsx +0 -179
  148. package/themes/franchises/src/components/UserProfile/styles.ts +0 -42
  149. package/themes/franchises/src/components/UserProfileForm/index.tsx +0 -253
  150. package/themes/franchises/src/components/UserProfileForm/styles.tsx +0 -29
  151. package/themes/franchises/src/components/VerifyPhone/index.tsx +0 -188
  152. package/themes/franchises/src/components/VerifyPhone/styles.tsx +0 -43
  153. package/themes/franchises/src/components/shared/OAlert.tsx +0 -55
  154. package/themes/franchises/src/components/shared/OBottomPopup.tsx +0 -73
  155. package/themes/franchises/src/components/shared/OBottomStickBar.tsx +0 -62
  156. package/themes/franchises/src/components/shared/OButton.tsx +0 -132
  157. package/themes/franchises/src/components/shared/ODropDown.tsx +0 -169
  158. package/themes/franchises/src/components/shared/OIcon.tsx +0 -53
  159. package/themes/franchises/src/components/shared/OIconButton.tsx +0 -127
  160. package/themes/franchises/src/components/shared/OIconText.tsx +0 -54
  161. package/themes/franchises/src/components/shared/OInput.tsx +0 -113
  162. package/themes/franchises/src/components/shared/OKeyButton.tsx +0 -35
  163. package/themes/franchises/src/components/shared/OModal.tsx +0 -172
  164. package/themes/franchises/src/components/shared/OText.tsx +0 -52
  165. package/themes/franchises/src/components/shared/OTextarea.tsx +0 -36
  166. package/themes/franchises/src/components/shared/OToast.tsx +0 -93
  167. package/themes/franchises/src/components/shared/OToggle.tsx +0 -158
  168. package/themes/franchises/src/components/shared/index.tsx +0 -29
  169. package/themes/franchises/src/config/constants.tsx +0 -57
  170. package/themes/franchises/src/layouts/Container.tsx +0 -23
  171. package/themes/franchises/src/layouts/SafeAreaContainer.tsx +0 -6
  172. package/themes/franchises/src/providers/AlertProvider.tsx +0 -43
  173. package/themes/franchises/src/providers/StoreUtil.tsx +0 -50
  174. package/themes/franchises/src/types/index.tsx +0 -445
  175. package/themes/franchises/src/utils/index.tsx +0 -222
@@ -1,643 +0,0 @@
1
- import React, { useEffect, useRef, useState } from 'react';
2
- import { View, Pressable, StyleSheet } 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
-
7
- import { PhoneInputNumber } from '../PhoneInputNumber';
8
- import { FacebookLogin } from '../FacebookLogin';
9
-
10
- import {
11
- SignupForm as SignUpController,
12
- useLanguage,
13
- useConfig,
14
- useSession,
15
- ToastType,
16
- useToast,
17
- } from 'ordering-components/native';
18
- import { useTheme } from 'styled-components/native';
19
- import { FormSide, FormInput, SocialButtons } from './styles';
20
-
21
- import {
22
- ButtonsWrapper,
23
- LoginWith as SignupWith,
24
- OTab,
25
- OTabs,
26
- } from '../LoginForm/styles';
27
-
28
- import NavBar from '../NavBar';
29
- import { VerifyPhone } from '../VerifyPhone';
30
-
31
- import { OText, OButton, OInput, OModal } from '../shared';
32
- import { SignupParams } from '../../types';
33
- import { sortInputFields } from '../../utils';
34
- import { GoogleLogin } from '../GoogleLogin';
35
- import { AppleLogin } from '../AppleLogin';
36
-
37
- const notValidationFields = [
38
- 'coupon',
39
- 'driver_tip',
40
- 'mobile_phone',
41
- 'address',
42
- 'address_notes',
43
- ];
44
-
45
- const SignupFormUI = (props: SignupParams) => {
46
- const {
47
- navigation,
48
- loginButtonText,
49
- signupButtonText,
50
- onNavigationRedirect,
51
- formState,
52
- validationFields,
53
- showField,
54
- isRequiredField,
55
- useChekoutFileds,
56
- useSignupByEmail,
57
- useSignupByCellphone,
58
- handleSuccessSignup,
59
- handleButtonSignupClick,
60
- verifyPhoneState,
61
- checkPhoneCodeState,
62
- setCheckPhoneCodeState,
63
- handleSendVerifyCode,
64
- handleCheckPhoneCode,
65
- } = props;
66
-
67
- const theme = useTheme();
68
-
69
-
70
- const style = StyleSheet.create({
71
- btnOutline: {
72
- backgroundColor: '#FFF',
73
- color: theme.colors.primary,
74
- },
75
- inputStyle: {
76
- marginBottom: 20,
77
- borderWidth: 1,
78
- borderColor: theme.colors.border,
79
- borderRadius: 7.6,
80
- },
81
- wrappText: {
82
- display: 'flex',
83
- flexDirection: 'row',
84
- justifyContent: 'space-between',
85
- marginBottom: 30,
86
- },
87
- line: {
88
- height: 1,
89
- backgroundColor: theme.colors.border,
90
- flexGrow: 1,
91
- marginBottom: 7,
92
- },
93
- });
94
-
95
- const showInputPhoneNumber =
96
- validationFields?.fields?.checkout?.cellphone?.enabled ?? false;
97
-
98
- const [, { showToast }] = useToast();
99
- const [, t] = useLanguage();
100
- const [, { login }] = useSession();
101
- const [{ configs }] = useConfig();
102
- const { control, handleSubmit, errors } = useForm();
103
-
104
- const [passwordSee, setPasswordSee] = useState(false);
105
- const [formValues, setFormValues] = useState(null);
106
- const [isModalVisible, setIsModalVisible] = useState(false);
107
- const [isLoadingVerifyModal, setIsLoadingVerifyModal] = useState(false);
108
- const [signupTab, setSignupTab] = useState(
109
- useSignupByCellphone && !useSignupByEmail ? 'cellphone' : 'email',
110
- );
111
- const [isFBLoading, setIsFBLoading] = useState(false);
112
- const [phoneInputData, setPhoneInputData] = useState({
113
- error: '',
114
- phone: {
115
- country_phone_code: null,
116
- cellphone: null,
117
- },
118
- });
119
-
120
- const nameRef = useRef<any>(null);
121
- const lastnameRef = useRef<any>(null);
122
- const middleNameRef = useRef<any>(null);
123
- const secondLastnameRef = useRef<any>(null);
124
- const emailRef = useRef<any>(null);
125
- const phoneRef = useRef<any>(null);
126
- const passwordRef = useRef<any>(null);
127
-
128
- const handleRefs = (ref: any, code: string) => {
129
- switch (code) {
130
- case 'name': {
131
- nameRef.current = ref;
132
- break;
133
- }
134
- case 'middle_name': {
135
- middleNameRef.current = ref;
136
- }
137
- case 'lastname': {
138
- lastnameRef.current = ref;
139
- break;
140
- }
141
- case 'second_lastname': {
142
- secondLastnameRef.current = ref;
143
- break;
144
- }
145
- case 'email': {
146
- emailRef.current = ref;
147
- break;
148
- }
149
- }
150
- };
151
-
152
- const handleFocusRef = (code: string) => {
153
- switch (code) {
154
- case 'name': {
155
- nameRef?.current?.focus();
156
- break;
157
- }
158
- case 'middle_name': {
159
- middleNameRef?.current?.focus();
160
- break;
161
- }
162
- case 'lastname': {
163
- lastnameRef?.current?.focus();
164
- break;
165
- }
166
- case 'second_lastname': {
167
- secondLastnameRef?.current?.focus();
168
- break;
169
- }
170
- case 'email': {
171
- emailRef?.current?.focus();
172
- break;
173
- }
174
- }
175
- };
176
-
177
- const getNextFieldCode = (index: number) => {
178
- const fields = sortInputFields({
179
- values: validationFields?.fields?.checkout,
180
- })?.filter(
181
- (field: any) =>
182
- !notValidationFields.includes(field.code) && showField(field.code),
183
- );
184
- return fields[index + 1]?.code;
185
- };
186
-
187
- const handleSuccessFacebook = (user: any) => {
188
- login({
189
- user,
190
- token: user.session.access_token,
191
- });
192
- navigation.navigate('Home');
193
- };
194
-
195
- const handleChangeTab = (val: string) => {
196
- setSignupTab(val);
197
- setPasswordSee(false);
198
- };
199
-
200
- const onSubmit = (values: any) => {
201
- if (phoneInputData.error) {
202
- showToast(ToastType.Error, phoneInputData.error);
203
- return;
204
- }
205
- if (
206
- !phoneInputData.phone.country_phone_code &&
207
- !phoneInputData.phone.cellphone &&
208
- validationFields?.fields?.checkout?.cellphone?.enabled &&
209
- validationFields?.fields?.checkout?.cellphone?.required
210
- ) {
211
- showToast(
212
- ToastType.Error,
213
- t(
214
- 'VALIDATION_ERROR_MOBILE_PHONE_REQUIRED',
215
- 'The field Mobile phone is required.',
216
- ),
217
- );
218
- return;
219
- }
220
- if (signupTab === 'email' || !useSignupByCellphone) {
221
- handleButtonSignupClick &&
222
- handleButtonSignupClick({
223
- ...values,
224
- ...phoneInputData.phone,
225
- });
226
- if (
227
- !formState.loading &&
228
- formState.result.result &&
229
- !formState.result.error
230
- ) {
231
- handleSuccessSignup && handleSuccessSignup(formState.result.result);
232
- }
233
- return;
234
- }
235
- setFormValues(values);
236
- handleVerifyCodeClick(values);
237
- };
238
-
239
- const handleVerifyCodeClick = (values: any) => {
240
- const formData = values || formValues;
241
- handleSendVerifyCode &&
242
- handleSendVerifyCode({
243
- ...formData,
244
- ...phoneInputData.phone,
245
- });
246
- setIsLoadingVerifyModal(true);
247
- };
248
-
249
- // get object with rules for hook form inputs
250
- const getInputRules = (field: any) => {
251
- const rules: any = {
252
- required: isRequiredField(field.code)
253
- ? t(
254
- `VALIDATION_ERROR_${field.code.toUpperCase()}_REQUIRED`,
255
- `${field.name} is required`,
256
- ).replace('_attribute_', t(field.name, field.code))
257
- : null,
258
- };
259
- if (field.code && field.code === 'email') {
260
- rules.pattern = {
261
- value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
262
- message: t('INVALID_ERROR_EMAIL', 'Invalid email address').replace(
263
- '_attribute_',
264
- t('EMAIL', 'Email'),
265
- ),
266
- };
267
- }
268
- return rules;
269
- };
270
-
271
- const handleChangeInputEmail = (value: string, onChange: any) => {
272
- onChange(value.toLowerCase().replace(/[&,()%";:ç?<>{}\\[\]\s]/g, ''));
273
- };
274
-
275
- useEffect(() => {
276
- if (!formState.loading && formState.result?.error) {
277
- formState.result?.result &&
278
- showToast(ToastType.Error, formState.result?.result[0]);
279
- setIsLoadingVerifyModal(false);
280
- }
281
- }, [formState]);
282
-
283
- useEffect(() => {
284
- if (Object.keys(errors).length > 0) {
285
- // Convert all errors in one string to show in toast provider
286
- const list = Object.values(errors);
287
- if (phoneInputData.error) {
288
- list.push({ message: phoneInputData.error });
289
- }
290
- if (
291
- !phoneInputData.error &&
292
- !phoneInputData.phone.country_phone_code &&
293
- !phoneInputData.phone.cellphone &&
294
- validationFields?.fields?.checkout?.cellphone?.enabled &&
295
- validationFields?.fields?.checkout?.cellphone?.required
296
- ) {
297
- list.push({
298
- message: t(
299
- 'VALIDATION_ERROR_MOBILE_PHONE_REQUIRED',
300
- 'The field Mobile phone is required.',
301
- ),
302
- });
303
- }
304
- let stringError = '';
305
- list.map((item: any, i: number) => {
306
- stringError +=
307
- i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
308
- });
309
- showToast(ToastType.Error, stringError);
310
- setIsLoadingVerifyModal(false);
311
- }
312
- }, [errors]);
313
-
314
- useEffect(() => {
315
- if (verifyPhoneState && !verifyPhoneState?.loading) {
316
- if (verifyPhoneState.result?.error) {
317
- const message =
318
- typeof verifyPhoneState?.result?.result === 'string'
319
- ? verifyPhoneState?.result?.result
320
- : verifyPhoneState?.result?.result[0];
321
- verifyPhoneState.result?.result && showToast(ToastType.Error, message);
322
- setIsLoadingVerifyModal(false);
323
- return;
324
- }
325
-
326
- const okResult = verifyPhoneState.result?.result === 'OK';
327
- if (okResult) {
328
- !isModalVisible && setIsModalVisible(true);
329
- setIsLoadingVerifyModal(false);
330
- }
331
- }
332
- }, [verifyPhoneState]);
333
-
334
- return (
335
- <View>
336
- <NavBar
337
- title={t('SIGNUP', 'Signup')}
338
- titleAlign={'center'}
339
- onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
340
- showCall={false}
341
- btnStyle={{ paddingLeft: 0 }}
342
- isVertical
343
- />
344
- <FormSide>
345
- {useSignupByEmail &&
346
- useSignupByCellphone &&
347
- configs &&
348
- Object.keys(configs).length > 0 &&
349
- (configs?.twilio_service_enabled?.value === 'true' ||
350
- configs?.twilio_service_enabled?.value === '1') && (
351
- <SignupWith style={{ paddingBottom: 25 }}>
352
- <OTabs>
353
- {useSignupByEmail && (
354
- <Pressable onPress={() => handleChangeTab('email')}>
355
- <OTab>
356
- <OText
357
- size={18}
358
- color={
359
- signupTab === 'email'
360
- ? theme.colors.primary
361
- : theme.colors.disabled
362
- }>
363
- {t('SIGNUP_BY_EMAIL', 'Signup by Email')}
364
- </OText>
365
- </OTab>
366
- </Pressable>
367
- )}
368
- {useSignupByCellphone && (
369
- <Pressable onPress={() => handleChangeTab('cellphone')}>
370
- <OTab>
371
- <OText
372
- size={18}
373
- color={
374
- signupTab === 'cellphone'
375
- ? theme.colors.primary
376
- : theme.colors.disabled
377
- }>
378
- {t('SIGNUP_BY_PHONE', 'Signup by Phone')}
379
- </OText>
380
- </OTab>
381
- </Pressable>
382
- )}
383
- </OTabs>
384
- </SignupWith>
385
- )}
386
- <FormInput>
387
- {!(useChekoutFileds && validationFields?.loading) ? (
388
- <>
389
- {sortInputFields({
390
- values: validationFields?.fields?.checkout,
391
- }).map(
392
- (field: any, i: number) =>
393
- !notValidationFields.includes(field.code) &&
394
- showField &&
395
- showField(field.code) && (
396
- <Controller
397
- key={field.id}
398
- control={control}
399
- render={({ onChange, value }: any) => (
400
- <OInput
401
- placeholder={t(field.name)}
402
- style={style.inputStyle}
403
- icon={
404
- field.code === 'email'
405
- ? theme.images.general.email
406
- : theme.images.general.user
407
- }
408
- value={value}
409
- onChange={(val: any) =>
410
- field.code !== 'email'
411
- ? onChange(val)
412
- : handleChangeInputEmail(val, onChange)
413
- }
414
- autoCapitalize={
415
- field.code === 'email' ? 'none' : 'sentences'
416
- }
417
- autoCorrect={field.code === 'email' && false}
418
- type={
419
- field.code === 'email' ? 'email-address' : 'default'
420
- }
421
- autoCompleteType={
422
- field.code === 'email' ? 'email' : 'off'
423
- }
424
- returnKeyType="next"
425
- blurOnSubmit={false}
426
- forwardRef={(ref: any) => handleRefs(ref, field.code)}
427
- onSubmitEditing={() =>
428
- field.code === 'email'
429
- ? phoneRef?.current?.focus?.()
430
- : handleFocusRef(getNextFieldCode(i))
431
- }
432
- />
433
- )}
434
- name={field.code}
435
- rules={getInputRules(field)}
436
- defaultValue=""
437
- />
438
- ),
439
- )}
440
-
441
- {!!showInputPhoneNumber && (
442
- <View style={{ marginBottom: 25 }}>
443
- <PhoneInputNumber
444
- data={phoneInputData}
445
- handleData={(val: any) => setPhoneInputData(val)}
446
- forwardRef={phoneRef}
447
- textInputProps={{
448
- returnKeyType: 'next',
449
- onSubmitEditing: () => passwordRef?.current?.focus?.(),
450
- }}
451
- />
452
- </View>
453
- )}
454
-
455
- {signupTab !== 'cellphone' && (
456
- <Controller
457
- control={control}
458
- render={({ onChange, value }: any) => (
459
- <OInput
460
- isSecured={!passwordSee ? true : false}
461
- placeholder={t('PASSWORD', 'Password')}
462
- style={style.inputStyle}
463
- icon={theme.images.general.lock}
464
- iconCustomRight={
465
- !passwordSee ? (
466
- <MaterialCommunityIcons
467
- name="eye-outline"
468
- color={theme.colors.disabled}
469
- size={24}
470
- onPress={() => setPasswordSee(!passwordSee)}
471
- />
472
- ) : (
473
- <MaterialCommunityIcons
474
- name="eye-off-outline"
475
- color={theme.colors.disabled}
476
- size={24}
477
- onPress={() => setPasswordSee(!passwordSee)}
478
- />
479
- )
480
- }
481
- value={value}
482
- onChange={(val: any) => onChange(val)}
483
- returnKeyType="done"
484
- onSubmitEditing={handleSubmit(onSubmit)}
485
- blurOnSubmit
486
- forwardRef={passwordRef}
487
- />
488
- )}
489
- name="password"
490
- rules={{
491
- required: isRequiredField('password')
492
- ? t(
493
- 'VALIDATION_ERROR_PASSWORD_REQUIRED',
494
- 'The field Password is required',
495
- ).replace('_attribute_', t('PASSWORD', 'password'))
496
- : null,
497
- minLength: {
498
- value: 8,
499
- message: t(
500
- 'VALIDATION_ERROR_PASSWORD_MIN_STRING',
501
- 'The Password must be at least 8 characters.',
502
- )
503
- .replace('_attribute_', t('PASSWORD', 'Password'))
504
- .replace('_min_', 8),
505
- },
506
- }}
507
- defaultValue=""
508
- />
509
- )}
510
- </>
511
- ) : (
512
- <Spinner visible />
513
- )}
514
-
515
- {signupTab === 'cellphone' &&
516
- useSignupByEmail &&
517
- useSignupByCellphone ? (
518
- <OButton
519
- onClick={handleSubmit(onSubmit)}
520
- text={t('GET_VERIFY_CODE', 'Get Verify Code')}
521
- borderColor={theme.colors.primary}
522
- imgRightSrc={null}
523
- textStyle={{ color: 'white' }}
524
- isLoading={isLoadingVerifyModal}
525
- indicatorColor={theme.colors.white}
526
- style={{ borderRadius: 7.6, marginTop: 6 }}
527
- />
528
- ) : (
529
- <OButton
530
- onClick={handleSubmit(onSubmit)}
531
- text={signupButtonText}
532
- bgColor={theme.colors.primary}
533
- borderColor={theme.colors.primary}
534
- textStyle={{ color: 'white' }}
535
- imgRightSrc={null}
536
- isDisabled={formState.loading || validationFields.loading}
537
- style={{ borderRadius: 7.6, marginTop: 6 }}
538
- />
539
- )}
540
- </FormInput>
541
-
542
- <View
543
- style={{
544
- flexDirection: 'row',
545
- width: '100%',
546
- justifyContent: 'space-between',
547
- alignItems: 'center',
548
- marginVertical: 30,
549
- }}>
550
- <View style={style.line} />
551
- <OText
552
- size={14}
553
- mBottom={10}
554
- style={{ paddingHorizontal: 19 }}
555
- color={theme.colors.disabled}>
556
- {t('OR', 'or')}
557
- </OText>
558
- <View style={style.line} />
559
- </View>
560
-
561
- <ButtonsWrapper>
562
- <SocialButtons>
563
- <FacebookLogin
564
- handleErrors={(err: any) => showToast(ToastType.Error, err)}
565
- handleLoading={(val: boolean) => setIsFBLoading(val)}
566
- handleSuccessFacebookLogin={handleSuccessFacebook}
567
- />
568
- <GoogleLogin
569
- handleErrors={(err: any) => showToast(ToastType.Error, err)}
570
- handleLoading={(val: boolean) => setIsFBLoading(val)}
571
- handleSuccessFacebookLogin={handleSuccessFacebook}
572
- />
573
- <AppleLogin
574
- handleErrors={(err: any) => showToast(ToastType.Error, err)}
575
- handleLoading={(val: boolean) => setIsFBLoading(val)}
576
- handleSuccessFacebookLogin={handleSuccessFacebook}
577
- />
578
- </SocialButtons>
579
- </ButtonsWrapper>
580
-
581
- {/* {
582
- onNavigationRedirect && loginButtonText && (
583
- <View style={style.wrappText}>
584
- <OText size={18} style={{ marginRight: 5 }}>
585
- {t('MOBILE_FRONT_ALREADY_HAVE_AN_ACCOUNT', 'Already have an account?')}
586
- </OText>
587
- <Pressable onPress={() => onNavigationRedirect('Login')}>
588
- <OText size={18} color={theme.colors.primary}>
589
- {loginButtonText}
590
- </OText>
591
- </Pressable>
592
- </View>
593
- )
594
- } */}
595
-
596
- {/* {
597
- configs && Object.keys(configs).length > 0 && (
598
- (configs?.facebook_login?.value === 'true' ||
599
- configs?.facebook_login?.value === '1') &&
600
- configs?.facebook_id?.value &&
601
- (
602
- <ButtonsSection>
603
- <OText size={18} color={theme.colors.disabled}>
604
- {t('SELECT_AN_OPTION_TO_LOGIN', 'Select an option to login')}
605
- </OText>
606
-
607
- <SocialButtons>
608
- <FacebookLogin
609
- handleErrors={(err: any) => showToast(ToastType.Error, err)}
610
- handleLoading={(val: boolean) => setIsFBLoading(val)}
611
- handleSuccessFacebookLogin={handleSuccessFacebook}
612
- />
613
- </SocialButtons>
614
- </ButtonsSection>
615
- )
616
- )
617
- } */}
618
- </FormSide>
619
- <OModal open={isModalVisible} onClose={() => setIsModalVisible(false)}>
620
- <VerifyPhone
621
- phone={phoneInputData.phone}
622
- formValues={formValues}
623
- verifyPhoneState={verifyPhoneState}
624
- checkPhoneCodeState={checkPhoneCodeState}
625
- handleCheckPhoneCode={handleCheckPhoneCode}
626
- setCheckPhoneCodeState={setCheckPhoneCodeState}
627
- handleVerifyCodeClick={onSubmit}
628
- />
629
- </OModal>
630
- <Spinner
631
- visible={formState.loading || validationFields.loading || isFBLoading}
632
- />
633
- </View>
634
- );
635
- };
636
-
637
- export const SignupForm = (props: any) => {
638
- const signupProps = {
639
- ...props,
640
- UIComponent: SignupFormUI,
641
- };
642
- return <SignUpController {...signupProps} />;
643
- };
@@ -1,27 +0,0 @@
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: auto;
9
- `;
10
- export const FormInput = styled.View`
11
- display: flex;
12
- flex-direction: column;
13
- width: 100%;
14
- padding: 20px 0px 15px;
15
- `
16
- export const ButtonsSection = styled.View`
17
- margin: 10px 0px 0px;
18
- width: 100%;
19
- display: flex;
20
- flex-direction: column;
21
- `
22
-
23
- export const SocialButtons = styled.View`
24
- width: 100%;
25
- margin-top: 10px;
26
- padding-bottom: 50px;
27
- `